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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7f18265ce67560b3 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 e2mr1115804pbg.7.1320703391414; Mon, 07 Nov 2011 14:03:11 -0800 (PST) MIME-Version: 1.0 X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.181.72 Path: h5ni10094pba.0!nntp.google.com!news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!nntpfeed.proxad.net!78.192.181.72.MISMATCH!gegeweb.42!gegeweb.eu!gegeweb.org!aioe.org!.POSTED!not-for-mail From: anon@att.net Newsgroups: comp.lang.ada Subject: Re: Memory Access Date: Mon, 7 Nov 2011 22:03:06 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: Reply-To: anon@anon.org NNTP-Posting-Host: PvS+DjwtHl9L/qMvWSy8nQ.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: IBM NewsReader/2 2.0 Xref: news1.google.com comp.lang.ada:18843 Date: 2011-11-07T22:03:06+00:00 List-Id: Normally, Address is used for interfacing other languages and Machine_Code programming. Under Ada the standard is to use the "Access" statements such as Dev_0 := Dev_Table ( index ) 'Access ; then use Dev0.all to reference Dev_Table ( index ) 'Access ; The for Dev_Table'Address use {address_of_memory_array} is to assign a specific address to Dev_Table. Like setting the interrupt table to memory location zero. -- Interrupt_Vector_Type defined as either 32-bit or 64-bit -- Interrupt record. Interrupt_Vector : Interrupt_Vector_Type ( 0 .. 255 ) ; for Interrupt_Vector'Address use System.Null_Address ; -- simplest way because Null_Address (GNAT) is define as Address 0. In , awdorrin writes: >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 >