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,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-23 06:50:13 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: John_J_Cupak@raytheon.com (John Cupak) Newsgroups: comp.lang.ada Subject: Help with Copying Shared Memory to Local Date: 23 May 2002 06:50:11 -0700 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 199.46.198.231 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1022161811 2563 127.0.0.1 (23 May 2002 13:50:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 23 May 2002 13:50:11 GMT Xref: archiver1.google.com comp.lang.ada:24577 Date: 2002-05-23T13:50:11+00:00 List-Id: 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 Destination_Pointer : Project_Types.Double_Byte_Pointer; Source_Pointer : Project_Types.Double_Byte_Pointer; begin -- Copy_Double_Byte -- Ensure source address in correct range if Source >= System.Addresses.Logical_Address(Project_Types.Virtual_Base_Address) and Source < System.Addresses.Logical_Address(Project_Types.Virtual_Base_Address + 16#200_000#) then -- Must reference memory on double byte boundry -- The number of bytes to copy is specified by the Length parameter for Index in 0..(Length/2) - 1 loop -- Create source and destination pointers from base address plus double byte offsets Destination_Pointer := Project_Types.To_Double_Byte_Pointer( System.Deprecated.Incr_Addr(Destination, Index * 2)); Source_Pointer := Project_Types.To_Double_Byte_Pointer( System.Deprecated.Incr_Addr(Source, Index * 2)); -- Copy contents Destination_Pointer.all := Source_Pointer.all; end loop; end if; -- Source check end Copy_Double_Byte; I found a 1997 reference in this newsgroup (comp.lang.ada) to a similar problem entitled "Q: How to do memory access with gnat" from Michael Erdman (boavista@berlin.snafu.de) with references to the Ada95 System.Address_To_Access_Conversions child package and the System.Storage_Elements child package. So, before I go off and write up a new version of the "memory copy" procedure using these two child packages, has anyone ever implemented such a solution that would be willing to share? Comments and recommendations always appreciated. John Cupak