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 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!g14g2000cwa.googlegroups.com!not-for-mail From: "REH" Newsgroups: comp.lang.ada Subject: Re: volatile vs aliased Date: 6 Oct 2005 12:08:26 -0700 Organization: http://groups.google.com Message-ID: <1128625706.303037.295690@g14g2000cwa.googlegroups.com> References: <1128525722.605730.281980@g43g2000cwa.googlegroups.com> <87mzlnomca.fsf@ludovic-brenta.org> NNTP-Posting-Host: 192.35.35.35 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1128625712 30348 127.0.0.1 (6 Oct 2005 19:08:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 6 Oct 2005 19:08:32 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g14g2000cwa.googlegroups.com; posting-host=192.35.35.35; posting-account=lnUIyw0AAACoRB2fMF2SFTIilm8F10q2 Xref: g2news1.google.com comp.lang.ada:5462 Date: 2005-10-06T12:08:26-07:00 List-Id: Randy Brukardt wrote: > This seems like a good time to mention that I think the explicit use of > System.Address in Ada 95 and Ada 200Y code is usually a mistake. Since > pragma Convention can be used to ensure that general access types have the > appropriate representation, its rare that Address needs to be used for > interfacing. (There is only a handful of uses of Address in Claw, for > example.) > > Moreover, when you *do* need to use it, Address_to_Access_Conversions is the > best way to convert it, not an overlay (which at best blocks optimizations > and at worst won't even work right). > > type T is ...; > > procedure Read_Variable (At_Address : in System.Address; > Into : out T) is > package AAC is new System.Address_to_Access_Conversions (T); > V : AAC.Object_Pointer := AAC.To_Pointer (At_Address); > begin > -- perform my own explicit validation of the pointer's contents, perhaps > -- using 'Valid; then, copy into Into: > Into := V.all; > end Read_Variable; > > But it is better still to declare an appropriate type and never use Address > in the first place: > > type Pointer_T is access all T; > pragma Convention (C, Pointer_T); > > Address clauses should be restricted to mapping to hardware, IMHO. > > Randy. Can you folks point me to some literature (books, websites, etc.) that goes into these gory issues (volatile, aliased, convention, import, export, etc.) in more detail? I have some great books on Ada, but they all seem to gloss over these types of issues. We are in the process of converting all our Ada code to '95. It is very low-level and does a lot of register bit fiddling, OS calls, and such. I'd like to get more informed about these new (to me) features that '95 provides. REH