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-23 13:32:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!59ce1190!not-for-mail Message-ID: <3CED51CF.39E26FC6@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Help with Copying Shared Memory to Local References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 23 May 2002 20:32:30 GMT NNTP-Posting-Host: 63.184.20.72 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1022185950 63.184.20.72 (Thu, 23 May 2002 13:32:30 PDT) NNTP-Posting-Date: Thu, 23 May 2002 13:32:30 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:24606 Date: 2002-05-23T20:32:30+00:00 List-Id: John Cupak wrote: > > A colleague asked me to help him solve an memory copy problem. > > The source memory location is in a "shared" area, and the > destination memory location is "local" to the application. > > The original code, written in Ada83, works by copying two bytes > at a time. Evidently, the hardware crashes if they try to access > a single byte. > > Here's the Ada 95 version of the original Ada83 code: > > -- Assumed visibility of Project_Types > procedure Copy_Double_Byte(Destination : in System.Address; > Source : in System.Address; > Length : in Natural) is There's about a 9 out of 10 chance that this system does not need to be dealing with addresses; that this way of doing things was dreamed up by a C person who lacked the necessary familiarity with Ada 83 to be competent to create this specification. I have seen this kind of misuse of the language far too many times for it to be likely that this case is different. You rarely need to use addresses in Ada; this particular example almost certainly did not need to use addresses even in Ada 83. Maybe you're stuck with it, in which case you can probably do Storage_Length : constant Storage_Count := Storage_Count ( (8 * Length + Storage_Unit - 1) / Storage_Unit); -- Convert Length (in 8-bit bytes) to work with Storage_Elements A : Storage_Array (1 .. Storage_Length); for A'Address use Destination; pragma Import (Ada, A); B : Storage_Array (1 .. Storage_Length); for B'Address use Source; pragma Import (Ada, B); ... A := B; -- Jeff Carter "We call your door-opening request a silly thing." Monty Python & the Holy Grail