comp.lang.ada
 help / color / mirror / Atom feed
From: awdorrin <awdorrin@gmail.com>
Subject: Re: Memory Access
Date: Tue, 8 Nov 2011 04:22:05 -0800 (PST)
Date: 2011-11-08T04:22:05-08:00	[thread overview]
Message-ID: <35c7e403-6503-4e26-8764-9783caf84871@e2g2000vbb.googlegroups.com> (raw)
In-Reply-To: f5e21e2b-cf06-47f1-9bce-1811a54060d2@c16g2000pre.googlegroups.com

Thanks for the responses everyone - it will take me a little while to
go through these and make sure I understand everything.

To answer some questions and clarify things a bit: The original code
was written in Ada83, which is probably why this code was implemented
like this in the first place. We have Ada95 capable compilers
available on both platforms. My primary goal is to get this code
functional on Linux under GNAT but the secondary goal would be to
determine a replacement method that would work on both platforms.

I simplified the example I presented above. There is another Ada
Package called 'DataManager' which holds common data structures. The
Get_Object_Pointer and Get_UDP calls are from the DataManager package.

During elaboration of the package that this code is in (RDevice) a
configuration file is read which determines the number of devices that
need to be held in the Dev_Table, this value is set in Num_Devs_Cnst.
A call is made to the DataManager to allocate the memory needed from a
larger memory segment which was previously obtained through a malloc
of several MB. This memory segment is referred to as a 'Unique Data'
area, so the UDP stands for 'Unique Data Pointer.

All of these manipulations are trying to overlay the memory reserved
in the DataManager into the RDevice's Dev_Table so that the RDevice
package can read a data file and populate the records in Dev_Table.

I had originally thought that I could use a declare section and the
for 'Address notation to link the memory (as Adam suggested) - but the
problem with this code is that the Dev_Table is defined as a global
variable within the package and I don't know the memory address until
run time.

I'm not sure if, since Dev_Table is defined as a Dev_Table_Ptr_Type,
which is access of Dev_Table_Type (which is the unconstrained array)
if I could use a declare segment with a for'Address clause on another
temporary variable of Dev_Table_Ptr_Type, and assign that to the
Dev_Table.
Something like:

declare
  tempDevTable : Dev_Table_Ptr_Type := new Dev_Table_Type( 1 ..
Num_Devs_Cnst );
  for tempDevTable'Address use Dev_Data_Obj;
begin
  Dev_Table := tempDevTable;
end

I'm thinking this would not work - too used to C pointers I suppose
where it doesn't matter. ;)

Thanks



  reply	other threads:[~2011-11-08 12:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 20:09 Memory Access awdorrin
2011-11-07 21:26 ` Simon Wright
2011-11-07 22:03 ` anon
2011-11-07 22:21 ` Adam Beneschan
2011-11-07 22:42   ` Adam Beneschan
2011-11-07 23:13   ` Simon Wright
2011-11-07 23:32     ` Adam Beneschan
2011-11-08 12:22       ` awdorrin [this message]
2011-11-08 16:00         ` Adam Beneschan
2011-11-08 17:46           ` awdorrin
2011-11-08 20:11             ` Adam Beneschan
2011-11-08 20:24               ` awdorrin
2011-11-09 14:42                 ` awdorrin
2011-11-08 16:10         ` awdorrin
2011-11-08 18:33           ` Simon Wright
2011-11-08 18:34             ` Simon Wright
2011-11-08 20:18             ` awdorrin
2011-11-08 12:44       ` Simon Wright
2011-11-07 22:26 ` Niklas Holsti
2011-11-07 22:53   ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox