Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!bu-cs!mirror!necntc!necis!mrst!sdti!turner From: turner@sdti.SDTI.COM (Prescott K. Turner) Newsgroups: comp.lang.c Subject: Re: portability Summary: But what does WORKING mean? Keywords: ANSI volatile Message-ID: <349@sdti.SDTI.COM> Date: 18 Jan 89 17:42:11 GMT References: <1354@tank.uchicago.edu> <3377@arcturus> <908@ubu.warwick.UUCP> <9414@smoke.BRL.MIL> Reply-To: turner@sdti.UUCP (0006-Prescott K. Turner, Jr.) Organization: Software Development Technologies, Sudbury MA Lines: 29 In article <9414@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <908@ubu.warwick.UUCP> geoff@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@sdti.sdti.com