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 18:37:26 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Help with Copying Shared Memory to Local Date: Thu, 23 May 2002 20:37:31 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <3CED51CF.39E26FC6@acm.org> X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:24614 Date: 2002-05-23T20:37:31-05:00 List-Id: John Cupak wrote in message ... >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. Humm, I wouldn't expect that code to have the proper memory read/write (16-bits) that you specified. And in any case, even if it works, nothing would require that staying correct. However, you could use pragma Atomic to help convince the compiler to do the appropriate reads and writes. And I doubt that all of that address stuff helps much. :-) Randy. >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 > >