does it matter how I construct an aggregate struct type if its size is the same?
Hayden Livingston
halivingston@gmail.com
Fri Dec 18 22:16:00 GMT 2015
Sorry, I should have been clearer -- I'm absolutely talking about
passing by value. But isn't it on a per argument basis and on its
size? If you have a data structure that is 9 bytes, after alignment
let's say it's 12, isn't that all that matters?
I mean I'm new to this but it seems that if you have a function
compiled by compiler 1, and let's say it is "exported", i.e. some body
else can call into this code via dlopen/loadlibrary you can't
arbitrarily decide how things should be passed right? It has to be on
an ABI-level, and the ABI I'm guessing says parameter 1 if it's size <
X can be passed on the stack, or use some registers, but does an ABI
also specify that struct member 1 if is less than X size can be passed
in register?
This would mean you have to use only 1 compiler.
While typing this email, a thought occurred to me that probably we
programmers know this, and therefore never make our public
dlopen/loadlibrary APIs take structs that are not completely opaque?
Sorry I'm formulating some of my thoughts .. but I'm new to this.
On Fri, Dec 18, 2015 at 1:42 PM, Jay <jay.krell@cornell.edu> wrote:
> Still beware of alignment.
>
> - Jay
>
> On Dec 18, 2015, at 12:04 PM, Andrew Haley <aph@redhat.com> wrote:
>
>> On 18/12/15 15:16, Hayden Livingston wrote:
>>> Thanks, Andrew. Where is this exception? In ABIs?
>>>
>>> So you're suggesting I use char's to construct my ffi_types?
>>
>> Well, it can be awkward. Some targets pass the components of a
>> struct in registers. But this only matters if you pass a struct
>> by value, which is a fairly unusual thing to do in C. If you're
>> passing a struct by reference, then yes, you can just create a
>> char array of the right size.
>>
>> Andrew.
>>
More information about the Libffi-discuss
mailing list