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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7f18265ce67560b3,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.25.194 with SMTP id e2mr788103pbg.7.1320696591619; Mon, 07 Nov 2011 12:09:51 -0800 (PST) Path: h5ni9779pba.0!nntp.google.com!news2.google.com!postnews.google.com!d17g2000yql.googlegroups.com!not-for-mail From: awdorrin Newsgroups: comp.lang.ada Subject: Memory Access Date: Mon, 7 Nov 2011 12:09:51 -0800 (PST) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 192.91.172.36 Mime-Version: 1.0 X-Trace: posting.google.com 1320696591 7292 127.0.0.1 (7 Nov 2011 20:09:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 Nov 2011 20:09:51 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d17g2000yql.googlegroups.com; posting-host=192.91.172.36; posting-account=YkFdLgoAAADpWnfCBA6ZXMWTz2zHNd0j User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,gzip(gfe) Xref: news2.google.com comp.lang.ada:14327 Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-11-07T12:09:51-08:00 List-Id: I am trying to migrate source code from an older AdaMulti compiler than ran on Solaris to GNAT on Linux. The original program makes use of shared memory and has structures populated in C code that are accessed within Ada code. The original developers used some AdaMulti 'features' that do not appear to exist within GNAT to play some tricks on setting up a pointer as an array of records. For instance: Config_Type is an Ada Record which matches a C struct. A Dev_Table is used as an array of these Config_Type records. The original code has the following statements: type Dev_Table_Type is array (Device_Num_Type range <>) of Config_Type; type Dev_Table_Ptr_Type is access Dev_Table_Type; Dev_Table := Dev_Table_Ptr_Type; Bounds_Ptr : Global_Types.Int_Ptr_Type; Then, in the Ada Procedure we have: Dev_Data_Obj := Get_Object_Pointer( Dev_Data_Obj_Name ); Dev_Table := To_Dev_Table_Ptr( Get_UDP( Dev_Data_Obj) ); Bounds_Ptr := Dev_Table_Ptr_To_Int_Ptr( Dev_Table ); Bounds_Ptr.all := 1; Bounds_Ptr := Int_To_Int_Ptr( Dev_Table_Ptr_To_Int( Dev_Table ) + 4); Bounds_Ptr.all := Int32( Num_Devs_Cnst ); The To_Dev_Table_Ptr, Dev_Table_Ptr_To_Int_Ptr, Int_To_Int_Ptr are all unchecked conversion methods. I understand that the Bounds_Ptr is being used to assign array constraints to the dope vector. But I'm guessing that GNAT doesn't define these dope vectors using this sort of definition. I haven't done much development in Ada, so I'm at a loss here. I'm making the assumption that the way this code was implemented (somewhere between 1992 and 98) was not really the right way to approach this problem. But I'm not sure what method should be used, and haven't had much luck the past few days searching the web and newsgroups. I would have thought I could have defined the Dev_Table differently, perhaps: Dev_Table : Dev_Table_Ptr_Type := new Dev_Table_Type( 1 .. Num_Devs_Cnst ); If I knew the address of pointer at the time of declaration I figured I could do: for Dev_Table'Address use {address_of_memory_array} - but I won't know that until run time, so I'm not sure how I can assign that properly. I hope I'm making sense here - because I'm pretty confused about all of this at the moment... :-) Thanks -Al