From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c6acbb9f2027b8c9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mail From: "Rolf" Newsgroups: comp.lang.ada Subject: Re: volatile vs aliased Date: 6 Oct 2005 04:36:44 -0700 Organization: http://groups.google.com Message-ID: <1128598604.142021.239190@g44g2000cwa.googlegroups.com> References: <1128525722.605730.281980@g43g2000cwa.googlegroups.com> <87mzlnomca.fsf@ludovic-brenta.org> <1421562.dbAHjS9XJS@linux1.krischik.com> NNTP-Posting-Host: 195.27.231.129 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1128598609 24365 127.0.0.1 (6 Oct 2005 11:36:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 6 Oct 2005 11:36:49 +0000 (UTC) In-Reply-To: <1421562.dbAHjS9XJS@linux1.krischik.com> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.10) Gecko/20050717 Firefox/1.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g44g2000cwa.googlegroups.com; posting-host=195.27.231.129; posting-account=X6JcNAwAAACCYFUClJvh1OjD0lgttvkm Xref: g2news1.google.com comp.lang.ada:5442 Date: 2005-10-06T04:36:44-07:00 List-Id: Martin Krischik wrote: > Ludovic Brenta wrote: > > > pragma Volatile (Variable) says the compiler must not optimise away > > any reads or writes to that variable, and that it may not add extra > > reads or writes beyond those you explicitly request in your program > > text. You want to use that for hardware registers, where a "read" > > operation may have a side effect such as changing the device's state. > > Interesting! So with pragma Volatile (X) the following two statements are > not the same: > > Y := X * X; > Y := X ** 2; Do we have a difference to C/C++ increment operator here? consider pragma Volatile (x); x := x + 1; -- (1) vs. x++; -- (2) In the Ada case (1) we are forced to have "read from memory", "increment" and "write to memory" instructions, whereas in C/C++ (2) you can get a single "increment memory" instruction (presuming the mentioned assembler instructions exist on a given processor) Rolf