[Ecls-list] load-foreign-library
Juan Jose Garcia-Ripoll
jjgarcia at users.sourceforge.net
Sat Oct 21 15:32:26 UTC 2006
2006/10/21, Rick Taube <taube at uiuc.edu>:
> im trying to load a foreign library OSX 10.4, ECL 0.9i (cvs) and
> cffi-061012 . from what I understand in the cffi readme this should
> be working if i use a constant string. however the lib doesnt load:
I am right now writing a piece on this, but in short ECL allows for
two kinds of FFI:
+ Static FFI based on compiled C code. You specify the libraries on a
lisp file, together with the lisp code that declares those functions.
These lisp files are compiled with a C compiler and produce a *.fas
file that you can load. This is a extremely portable method
+ Dynamic method. You load a DLL dynamically (as you were doing I
presume) and declare functions with lisp code in a way similar to the
one you would do with the static FFI. However this you can do from
lisp sources, from the command line, from compiled files, etc. When
you call those C functions there is some assembly code doing the magic
for you: converting arguments, preparing the stack, etc.
CFFI is implemented using the dynamic FFI and only some support for
static FFI is provided -- I have to work on it, but the problem is
that CFFI assumes a level of run time customizability that not all
implementations can have.
However, dynamic FFI relies on extremely unportable code (depends on
assembly code and on details of the ABI of an operating system) and
currently has only been implemented for x86-32 bits. I have patches
for x86-64 but they will only be included when I finish the PPC port,
because they are very similar.
Now, after this long speech you understand why what you try to do
might not work and it is time for me to ask whether your platform
allows for a dynamic FFI and whether it has been compiled in (Symbol
:DFFI should be in *FEATURES*). If so, then it might be a bug and I
would need more information.
Juanjo
More information about the ecl-devel
mailing list