[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Pkg-haskell-maintainers] libffi changes - help needed

On Wed, Apr 04, 2012 at 08:15:31PM +0200, Joachim Breitner wrote:
> Hi,
> am I understanding the problem correctly: If one calls a variadic C
> function with libffi, one should use ffi_prep_cif_variadic() instead of
> ffi_prep_cif(), otherwise bad things may happen. Whether the function is
> variadic or not might not be known when looking at the source that calls
> ffi_prep_cif(), e.g. in the implementation of the Haskell Foreign
> Function Interface.
> In GHC itself, ffi_prep_cif is called
>  * in ./rts/Adjustor.c when provding Haskell code to C calls; as Haskell
> functions are never variadic, this is not a problem.
>  * in ./compiler/ghci/LibFFI.hsc in the Haskell function
> prepForeignCall, called by generateCCall
> in ./compiler/ghci/ByteCodeGen.lhs. It seems that this is only relevant
> for ghci.

[-other lists]

Hmm. If ffi_prep_cif is not called by regular (compiled) Haskell code,
how is such code calling foreign functions? Reading ffi(3), it seems
that if using ffi_call, one needs to prepare the call either this or
ffi_prep_cif_variadic, and no way around it.

Apologies if this is obvious to everyone else :)


Reply to: