From: "John Cupak" <Jcupak744@attbi.com>
Subject: Re: Help with Copying Shared Memory to Local
Date: Thu, 23 May 2002 21:18:18 GMT
Date: 2002-05-23T21:18:18+00:00 [thread overview]
Message-ID: <u0dH8.6904$AJ5.1584062@typhoon.ne.ipsvc.net> (raw)
In-Reply-To: 3CED51CF.39E26FC6@acm.org
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" <jrcarter@acm.org> 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
next prev parent reply other threads:[~2002-05-23 21:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-23 13:50 Help with Copying Shared Memory to Local John Cupak
2002-05-23 20:32 ` Jeffrey Carter
2002-05-23 21:18 ` John Cupak [this message]
2002-05-24 1:37 ` Randy Brukardt
2002-05-24 2:08 ` Jeffrey Carter
2002-05-24 17:05 ` John R. Strohm
2002-05-24 16:55 ` Stephen Leake
2002-05-24 20:43 ` John R. Strohm
2002-05-24 19:49 ` Pat Rogers
2002-05-24 23:23 ` martin.m.dowie
2002-05-24 20:54 ` Stephen Leake
2002-05-24 19:41 ` Jeffrey Carter
2002-05-26 0:55 ` John Cupak
2002-05-28 17:52 ` John Cupak
2002-05-25 11:23 ` Robert Dewar
2002-05-26 4:48 ` Jeffrey Carter
-- strict thread matches above, loose matches on Subject: below --
2002-05-24 14:22 Beard, Frank [Contractor]
2002-05-24 19:30 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox