portability
Prescott K. Turner
turner at sdti.SDTI.COM
Thu Jan 19 03:42:11 AEST 1989
In article <9414 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <908 at ubu.warwick.UUCP> geoff at emerald.UUCP (Geoff Rimmer) writes:
>>BTW, can anyone tell me if the keyword 'volatile' is part of the ANSI
>>standard? (I mean is it true to say that all ANSI C compilers must
>>have the keyword volatile WORKING (i.e. semantically as well as
>>syntactically)?)
>
>Certainly. What would be the point if it didn't have to work?
X3J3 did the best they could. However, the ANSI definition of WORKING will
certainly differ on occasion from what users expect. In particular,
the standard does not require that when an object is declared volatile,
every access to it will be an atomic operation uninterrupted by other
processes. For example, a compiler is permitted to handle the function
int foo (volatile int * x) {
return * x;
}
by copying from the object pointed to by "x" one byte at a time. If the
object is really volatile, the value returned may differ from any value
ever stored in it.
A good C compiler will make such operations atomic when the hardware has
efficient support for it. And the standard requires implementations to
document how they handle volatile objects.
--
Prescott K. Turner, Jr.
Software Development Technologies, Inc.
375 Dutton Rd., Sudbury, MA 01776 USA (508) 443-5779
UUCP: ...{harvard,mit-eddie}!sdti!turner Internet: turner at sdti.sdti.com
More information about the Comp.lang.c
mailing list