[Ecls-list] FFI changes
Juan Jose Garcia Ripoll
jlr at mpq.mpg.de
Mon Oct 10 03:35:19 UTC 2005
Hi,
well, I have committed some changes to fix the bug that Michael pointed
out. However, the fact is that I have been working hard on the FFI in
the last days to conclude a project that Michael initiated short ago,
and whose purpose is to be able to dynamically load and invoke functions
from shared libraries.
Currently, all FFI in ECL is static and it is based on generating C
wrappers which are processed by the C compiler and which act as an
interface between the lisp and the C world.
The goal is to bring what other lisps already have: the possibility of
doing the same, but purely at run-time and without the C compiler. Of
course, the tools for doing that are not portable and this requires a
knowledge of the platform where ECL is going to run (in particular, of
calling conventions, assembler, etc). This makes it difficult for us
developers but I think it is worth the effort.
What you will now find in CVS is both a low level implementation called
SI::CALL-CFUN and changes in DEF-FUNCTION to support loading shared
libraries. CALL-CFUN takes as input a pointer to the function that
should be invoked, the types of the arguments, the type of the output
and the list of arguments. A sample use is below.
All code is rather untested and only works on Intel-32 with the GCC
compiler.
Regards,
Juanjo
ECL (Embeddable Common-Lisp) 0.9g
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help. Top level.
> (si::call-cfun (si::find-foreign-symbol "sin" :default :pointer-void
0)
:double '(:double) '(#.pi))
1.2246063538223773d-16
More information about the ecl-devel
mailing list