This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Is a Pointer identical to a Struct { Pointer }?


I believe the answer is that it depends on the ABI.
Some ABIs might sometimes enregister small structs, making the answer yes.
Some ABIs might never enregister small structs, making the answer no.

- Jay


> Date: Wed, 15 Dec 2010 02:58:23 +0100
> Subject: Is a Pointer identical to a Struct { Pointer }?
> From: marco.devillers@gmail.com
> To: libffi-discuss@sourceware.org
> 
> Hi all,
> 
> This is a bit of a weird question regarding a quick-and-dirty fix.
> 
> In my language I use libffi extensively to interface with C. Since I
> want to support strings in the language I want to discriminate between
> pointers and pointers to characters in the libffi type information of
> C functions called.
> 
> Now one quick-and-dirty hack I came up with is just wrapping a single
> pointer in a structure as an 'encoding' of a char pointer. That
> manner, I could discriminate between pointers and 'encoded' pointers
> to characters easily.Of course, I would like to push values in the
> normal manner to the C function called.
> 
> Now that scheme only works if a structure containing one pointer is
> treated identically to a pointer in most calling conventions of GCC,
> MVC, etc. on most OSes.
> 
> Is the latter true. I.e., is the same stack structure build for a
> pointer, or a structure just holding a pointer? Is there an easier
> manner to solve this?
> 
> Any help appreciated,
> Marco 		 	   		  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]