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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7c0437014cb20f71 X-Google-Attributes: gid103376,public From: nobody@REPLAY.COM (Anonymous) Subject: Re: System.Address_to_Access_Conversions Date: 1998/07/14 Message-ID: <199807141326.PAA17561@basement.replay.com>#1/1 X-Deja-AN: 371328685 Content-Transfer-Encoding: 7bit References: <6odddl$k94$1@nnrp1.dejanews.com> Organization: Replay Associates, L.L.P. Mail-To-News-Contact: postmaster@nym.alias.net X-001: Replay may or may not approve of the content of this posting X-002: Report misuse of this automated service to X-URL: http://www.replay.com/remailer/ Content-Type: text/plain; charset=us-ascii Newsgroups: comp.lang.ada Date: 1998-07-14T00:00:00+00:00 List-Id: On Mon, 13 Jul 1998 16:42:29 GMT, jsanchor@my-dejanews.com wrote: > Hello Everyone: In my program I have some system address and I have to move > data to it. I am using access types to do this. I don't want to use Unchecked > conversion. So I started looking at a new feature Ada95 has > System.Address_to_Access_Conversions. I have > > type Dummy_Type is tagged private; > type Ptr_to_Data_Type is access all Dummy_Type'class; > > private > type Dummy_Type is tagged > record > checksum : Storage_Element; > end record; > > Dummy : Dummy_Type; > Ptr_to_Data : Ptr_to_Data_Type; > > > I want Ptr_to_Data to point to some system address, say, 16#00E00000# > > ... > > I tried using System.Address_to_Access_Conversions, > > package Convert_to_Pointer is new > System.Address_to_Access_Conversions(system.address); This should be instantiated for type Dummy_Type'Class. > > Data_Ptr : Convert_to_Pointer.Object_Pointer; > > Data_Ptr := Convert_to_Pointer(16#00E00000#); --This is my problem!! > -- I need a type Ptr_to_Data_Type, NOT Convert_to_Pointer.Object_Pointer Try using subtype Ptr_To_Data_Type is Convert_to_Pointer.Object_Pointer; If you instantiate Address_to_Access_Conversions for type Dummy_Type'Class, then this gives you what you want (access all Dummy_Type'Class). > > I tried casting > Ptr_to_Data := Ptr_to_Data_Type(Data_Ptr); --It compiled..but when I ran it > SEGMENTATION FAULT ERROR showed up. > Can anybody suggest how do I get the correct access type to point to memory. At this point you have a pointer to System.Address that you've been able (somehow) to convert to pointer to Dummy_Type'Class. That might have something to do with the Segmentation Fault. However, manipulation of arbitrary addresses is tricky; here your operating system is telling you that you are accessing memory outside the area allocated to you. > ... Jeff Carter PGP:1024/440FBE21 My real e-mail address: ( carter @ innocon . com ) "You brightly-colored, mealy-templed, cranberry-smelling, electric donkey-bottom biters." Monty Python & the Holy Grail Posted with Spam Hater - see http://www.compulink.co.uk/~net-services/spam/