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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,98e311935a219163 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-24 13:54:00 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Help with Copying Shared Memory to Local Date: 24 May 2002 16:54:08 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3CED51CF.39E26FC6@acm.org> <3CEDA095.61BE6EF6@acm.org> <478AE9B914ED6844.5DEC7C5E64D6473E.909AD32BDF37CFA7@lp.airnews.net> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1022274062 6089 128.183.220.71 (24 May 2002 21:01:02 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 24 May 2002 21:01:02 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:24689 Date: 2002-05-24T21:01:02+00:00 List-Id: "John R. Strohm" writes: > type x is record > csr: byte; > dr: byte; > end record; > for x use record at mod 2; > for x'size use 16; > > Or something of that nature. This says that objects of type x are 16 bits in size, and located on 16 bit boundaries. If we have the following code: declare a : X; b : X; begin a := b; end; The compiler is perfectly free to do two 8 bit copies. On an 8 bit machine, that's what I'd expect! Now consider this: declare a : X; b : X; c : X; d : X; begin a := b; c := d; end; The compiler is perfectly free to do one 32 bit copy. On a 32 bit machine, that's what I'd hope for (not quite expect :). Most compilers, most of the time, will do what you want. But it is _not_ _guarranteed_ by the language. Where I really got bit by this the first time was using a bit-mapped rep spec to access the bits in a hardware register, which is the natural way to do it in Ada. The compiler happily coded 8 bit accesses to get to the bits it needed, and the hardware got thoroughly confused. The only way to get it right was to use machine code to do a 16 bit read to normal RAM, then unchecked convert to the bit-mapped rep spec. Then bit or byte access to the RAM copy was fine. -- -- Stephe