From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Q: How to do memory access with gnat
Date: 1997/07/20
Date: 1997-07-20T00:00:00+00:00 [thread overview]
Message-ID: <EDMCGE.79A.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: easwuowobrigfij.pminews@boavista.berlin.snafu.de
Michael Erdmann (boavista@berlin.snafu.de) wrote:
: 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 ?
You can use an address clause to associate an Ada name with a given
address. E.g.:
Shared : Msg_Data;
for Shared'Address use <arbitrary computation>;
begin
Shared.data(I) := ...
Alternatively, the most direct analogy to the C approach is to declare
an access type, and initialize a variable of the type using
unchecked_conversion or the Address_To_Access_Conversion generic, or by
passing its 'Address to some external routine.
type Msg_Data_Ptr is access all Msg_Data;
Shared : Msg_Data_Ptr;
begin
DosGetSharedMemory(..., Shared'Address, ...);
Shared.data(I) := ...
--
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Burlington, MA USA
next prev parent reply other threads:[~1997-07-20 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-07-20 0:00 Q: How to do memory access with gnat Michael Erdmann
1997-07-20 0:00 ` Tucker Taft [this message]
1997-07-20 0:00 ` Q: How to do memory access with gnat - OS.ADS (1/1) Michael Erdmann
1997-07-20 0:00 ` Q: How to do memory access with gnat - os.ADB (0/1) Michael Erdmann
1997-07-20 0:00 ` Q: How to do memory access with gnat - OS.ADS (0/1) Michael Erdmann
1997-07-20 0:00 ` Q: How to do memory access with gnat Samuel Tardieu
1997-07-20 0:00 ` Michael Erdmann
1997-07-22 0:00 ` Michael Erdmann
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox