From: Hoehle, Joerg-C. <Joe...@t-...> - 2003-07-09 16:17:23
|
Grr, this was meant to clisp-devel. >An arg of c-union type may point that ffcall has trouble with >that (though I'm not sure ffcall gets to see that instead of >the first union member)?? It looks like there's some inconsistency in the FFI: At the ffcall level (foreign.d:do_av_call()), a c-union arg is treated like a c-struct parameter. At the Lisp level (convert_to/from_foreign()), the c-union is always ignored and its first component is used instead. So (:arguments (first (c-union (c1 (c-ptr character)) (s (c-array-ptr character)))) invokes av_struct_xyz and possibly a struct passing convention but is just passed what's converted from (c-ptr character). That may be what causes problems on some systems, where the difference matters? It looks like do_av_call() should handle c_union by dereferencing its first slot instead, just like convert_from_foreign() does. But what impact would that have on alignment and the arg_address alloca/malloc pointer? Is :arguments (x (c-union #) actually the only place where a crash is seen, or is it also seen with e.g. (c-ptr (c-union)) where the above thoughts do not apply? Maybe also the testcase is just incorrect, and I should not cast an int (*)(int) --what c-self aka ffi_identity() really is-- into a xyz (*)({union a|b|c}) function? Regards, Jorg hohle. |