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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,18f3577df8d90927 X-Google-Attributes: gid103376,public From: "Michael Erdmann" Subject: Re: Q: How to do memory access with gnat Date: 1997/07/22 Message-ID: #1/1 X-Deja-AN: 258186402 References: Organization: Unlimited Surprise Systems, Berlin Reply-To: "Michael Erdmann" Newsgroups: comp.lang.ada Date: 1997-07-22T00:00:00+00:00 List-Id: On Sun, 20 Jul 97 14:37:05, Michael Erdmann wrote: :>Hi :> :>i like to do something like this in Ada95 (excuse the C-example): :> :> typedef struct { ..,other_data; char data[1]; } Msg_data; :> Msg_Data *shared; :> :> // get some memory from the system :> DosGetSharedMemory( ..., &shared... ) :> :> // copy data into shared memory :> for( i ,,,, ) :> shared->data[i] := some_data[i]; :> :>In Ada95 i am not able to copy data from an Ada object into a some external :>memory. :>Any idea ? :> :> :> If some body is interested how i managed to solve the Problem here is my solution but i dont know if it works for all processor types: with System; use System; with System.Storage_Elements; use System.Storage_Elements; with System.Address_To_Access_Conversions; with Unchecked_Conversion; function TO_Storage_Offset is new Unchecked_Conversion(Source => Integer, Target=>Storage_Offset); package BYTE_Access is new System.Address_To_Access_Conversions( BYTE ); procedure Store_Byte( base : Address ; offset : Integer ; value:BYTE ) is begin BYTE_Access.To_Pointer(base+TO_Storage_Offset(offset) ).all := value; end Store_Byte; function Get_Byte( base: Address; offset : Integer ) return BYTE is begin return BYTE_Access.To_Pointer(base+TO_Storage_Offset(offset)).all; end Get_Byte;