comp.lang.ada
 help / color / mirror / Atom feed
From: "REH" <spamjunk@stny.rr.com>
Subject: Re: volatile vs aliased
Date: 6 Oct 2005 12:08:26 -0700
Date: 2005-10-06T12:08:26-07:00	[thread overview]
Message-ID: <1128625706.303037.295690@g14g2000cwa.googlegroups.com> (raw)
In-Reply-To: <p_GdnTN0co2x_tneRVn-uA@megapath.net>


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




  parent reply	other threads:[~2005-10-06 19:08 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-05 15:22 volatile vs aliased REH
2005-10-05 18:22 ` Ludovic Brenta
2005-10-05 18:39   ` REH
2005-10-05 19:46     ` Ludovic Brenta
2005-10-05 20:02       ` REH
2005-10-05 20:11         ` Ludovic Brenta
2005-10-05 20:20           ` REH
2005-10-06  5:21             ` Ludovic Brenta
2005-10-05 20:55       ` Simon Wright
2005-10-06 18:32       ` Jeffrey R. Carter
2005-10-05 23:38   ` Randy Brukardt
2005-10-06  0:02     ` tmoran
2005-10-06 13:40     ` REH
2005-10-06 23:52       ` Randy Brukardt
2005-10-06 18:40     ` Jeffrey R. Carter
2005-10-06 19:37       ` Robert A Duff
2005-10-06 23:56         ` Randy Brukardt
2005-10-06 19:08     ` REH [this message]
2005-10-06 19:21       ` Ed Falis
2005-10-06 19:37         ` REH
2005-10-06 19:46       ` Robert A Duff
2005-10-06  8:05   ` Martin Krischik
2005-10-06  8:52     ` Dmitry A. Kazakov
2005-10-06 11:36     ` Rolf
2005-10-06 18:43       ` Björn Persson
2005-10-06 19:03         ` Niklas Holsti
2005-10-07  6:36         ` Martin Krischik
2005-10-07  6:33       ` Martin Krischik
2005-10-07 15:56         ` Adrian Knoth
2005-10-07 18:48           ` Martin Krischik
2005-10-07 22:44           ` REH
2005-10-08  6:10         ` Simon Wright
2005-10-17  2:16         ` Dave Thompson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox