FFI with ABI instead of C declaration

Tyson Whitehead twhitehead at gmail.com
Fri Mar 11 17:08:51 CET 2011

On March 11, 2011 09:17:54 Maurício CA wrote:
> I wonder: why, in Haskell and also in other languages like ML, FFI is
> done with C type and code as references? Since, ultimately, compiled
> code goes to, say, ELF files or (in Windows) DLLs, shouldn't foreign
> interfaces be consistent with those?

Having an ELF file, a function name, and knowledge about the parameters for the 
function, is still not sufficient information to invoke it.  I still need to 
know what calling convention is being used.

That is, how to build the stack (which arguments to put on the stack and how 
to put them on), what to do with the registers (which arguments to put in 
them, which ones I can expect to be saved, any ones that are expected to be 
global pointers), how to receive results back (registers, on the stack, 
through a pointer), and, if I am expected to cleanup the stack afterwards.


Cheers!  -Tyson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://www.haskell.org/pipermail/libraries/attachments/20110311/f1f65806/attachment.pgp>

More information about the Libraries mailing list