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.9 required=5.0 tests=BAYES_00,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c1efbfe18e91d24 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-04 09:56:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!server1.netnews.ja.net!pegasus.csx.cam.ac.uk!solway.cl.cam.ac.uk!sjm217 From: news01+Steven.Murdoch@cl.cam.ac.uk (Steven Murdoch) Newsgroups: comp.lang.ada Subject: Re: Size of a pointer to a tagged record Date: 4 Dec 2002 17:56:01 GMT Organization: University of Cambridge, England Sender: sjm217@solway.cl.cam.ac.uk (Steven Murdoch) Message-ID: References: NNTP-Posting-Host: solway.cl.cam.ac.uk X-Newsreader: xrn 9.02 Xref: archiver1.google.com comp.lang.ada:31439 Date: 2002-12-04T17:56:01+00:00 List-Id: In article , Robert A Duff writes: >> >> addr:=Get_Void_Pointer; --Void* from C >> >> param:=Parameter_Access(User_Data_Convert.To_Pointer(Address)); >> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> >That code is wrong, so I'm not sure what you mean. >> >> Well it compiles. > >I see nothing called User_Data_Convert in the above code. >Perhaps you meant Convert? Yes, sorry (I forgot to simplify that when I pasted it in) >Also, the result of To_Pointer is Parameter_Access, >so you don't need to additionally convert to Parameter_Access >(by saying "Parameter_Access(...)"). That would compile, >but it's silly to convert from a type to itself. If I take out the "Parameter_Access(...)" I get the following error message: lua.adb:172:35: expected type "Parameter_Access" defined at lua.ads:13 lua.adb:172:35: found type "System.Address_To_Access_Conversions.Object_Pointer" from instance at line 36 so it seems that the result of To_Pointer is Object_Pointer rather than Parameter_Access. >> >Anyway, why not declare Get_Void_Pointer to return the access type? >> >I see no need for Address_To_Access_Conversions. >> >> What would it's type in C be in that case? > >void * OK, I will try that, it would clean up my code substantially. >> On GNAT 3.13p it is 32 (I assume bytes) which is indeed the same >> size as System.Address. > >'Size is in bits, not bytes. Sorry, that's what I meant. 32 byte addresses would be a rather larger address space that would be necessary :-) >One thing you might think about is taking 'Size on the Ada side, >converting that to bytes (using System.Storage_Unit), and passing >that to the C code at some point. The C code might be able to >use that size, or else assert that it is correct. I will try that too, the size is set during run time so there should not be any problem setting it. IIRC Malloc takes a number of octets so I could use a variant of Jeff Carters suggestion such as (Parameter_Access'Size + 7) / 8 This should be the right thing to pass in, even if Storage_Unit is not 8 Thanks again, Steven Murdoch.