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 14:22:28 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!news-hog.berkeley.edu!ucberkeley!newshub.sdsu.edu!west.cox.net!cox.net!news-east.rr.com!chnws02.ne.ipsvc.net!cyclone.ne.ipsvc.net!24.128.8.70!typhoon.ne.ipsvc.net.POSTED!not-for-mail From: "John Cupak" Newsgroups: comp.lang.ada References: <3CED51CF.39E26FC6@acm.org> Subject: Re: Help with Copying Shared Memory to Local X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Thu, 23 May 2002 21:18:18 GMT NNTP-Posting-Host: 66.31.64.136 X-Complaints-To: abuse@attbi.com X-Trace: typhoon.ne.ipsvc.net 1022188698 66.31.64.136 (Thu, 23 May 2002 17:18:18 EDT) NNTP-Posting-Date: Thu, 23 May 2002 17:18:18 EDT Organization: ATT Broadband Xref: archiver1.google.com comp.lang.ada:24609 Date: 2002-05-23T21:18:18+00:00 List-Id: Jeffrey, What a refreshing solution! I don't know why they're using pointers or addresses, either. Probably, as you noted, a C-hacker trying to write Ada. I've forwarded your suggested solution to the maintenance programmer who brought the problem to my attention. Let's see if it flys. Thanks again - Occam's razor strikes again! John "Jeffrey Carter" wrote in message news:3CED51CF.39E26FC6@acm.org... > 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