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: [PATCH] Add variadic support


On 23 February 2011 16:56, Chung-Lin Tang <cltang@linaro.org> wrote:
> On 2011/2/24 12:20 AM, David Gilbert wrote:
>> On 23 February 2011 13:25, Chung-Lin Tang <cltang@linaro.org> wrote:
>>> On 2011/2/23 09:11 PM, David Gilbert wrote:
>>>> In ARM's ffi_prep_cif_machdep I have:
>>>>
>>>> +#ifdef __ARM_PCS_VFP
>>>> + ?/* VFP uses the standard ABI for variadic functions */
>>>> + ?if ((cif->abi == FFI_VFP) && (cif->nfixedargs != 0))
>>>> + ? ?cif->abi = FFI_SYSV;
>>>> +#endif
>>>>
>>>> and that's the only active change that's needed.
>>>
>>> I suggest removing the #ifdef __ARM_PCS_VFP #ifdef. ?We always have
>>> support for both FFI_SYSV and FFI_VFP compiled in, so it doesn't make
>>> sense to leave this bit of logic out when we are under __ARM_PCS.
>>
>> I could do, although cif->nfixedargs is also not present except in the
>> VFP case, so
>> it would still need an ifdef.
>>
>> I did that since I thought it best not to change the layout of the CIF
>> structure for
>> existing ARM builds.
>
> Sigh...you're right about the layout issue :(
>
> Still I think it's best we keep the full FFI_SYSV/VFP capabilities in,
> or we'll have the weird case of "FFI_VFP with buggy variadics" under softfp.

Wouldn't it make more sense to ban FFI_VFP under softfp?

> I suggest moving the nfixedargs field into the ARM FFI_EXTRA_CIF_FIELDS,
> placed after the current VFP fields; this means doing away with the
> FFI_TARGET_SPECIFIC_VARIADIC symbol, and probably having a
> machine-specific ffi_prep_cif_var_machdep() function, analogous to the
> current ffi_prep_cif_machdep().

That would mean changing every back end to add that function or again
ifdefing for it, and the belief is that storing the nfixedargs value
is likely to
be useful to some backends who have to do different calling conventions for
variadics anyway.

> ffi_prep_cif_var_machdep() can then save things like 'number of fixed
> arguments' from the ffi_prep_cif_var() arguments if it is necessary for
> that architecture.
>
> Chung-Lin
>

Dave


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