closure api return value types problem

Sergei Trofimovich slyich@gmail.com
Sat Mar 20 12:22:00 GMT 2010


> Some time ago ghc project[1] switched to libffi to handle
> foreign calls from/to external world. When I tried ghc on
> powerpc64 I got some problems which I believe are result
> of that switch.
> 
> In one of FFI call types ghc uses C code generation and produces
> following code:
> 
> void haskell_closure_called_from_c(
>     void *cif __UNUSED__,
>     void* resp,
>     void** args,
>     void* haskell_runtime)
> {
> HaskellObj ret;
> HsInt32 cret;
> 
> ret = RT_CALL(haskell_runtime(args));
> 
> cret=rts_getInt32(ret);
> *(HsInt32*)resp = cret; /* <- is that corrct code? */
> }

Just looked at cls_ushort.c(and other integrals) test:
  *(ffi_arg*)resp = *(unsigned short *)args[0];
and cls_float.c
   *(float *)resp = *(float *)args[0];

Integrals seem to strangely be casted to 'ffi_arg *'(long *) while FPU ones
are casted to their real type. It's normal (but undocumented) or it's a
horrible inconsistency bug?

Thanks!

-- 

  Sergei
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libffi-discuss/attachments/20100320/7b9baa7a/attachment.sig>


More information about the Libffi-discuss mailing list