[cffi-devel] Callback Fix Branch

James Bielman jamesjb at jamesjb.com
Fri Jan 6 05:30:41 UTC 2006


Hi all,

I've made some progress updating the callback interface for each
backend to work with callback pointers in a manner that should be safe
when saving/reloading images.

The branch is up at:

    http://slacknet.com/~jamesjb/cffi-callback-fix

which can be obtained via 'darcs get', or pulled into an existing
repository, or browsed over the web.

The only significant visible change is the addition of an exported
%CALLBACK function to the CFFI-SYS layer, which returns a pointer for
a callback defined by %DEFCALLBACK.  CFFI:CALLBACK is implemented in
terms of CFFI-SYS:%CALLBACK instead of using the symbol's property
list.

This should also fix some problems on (at least) OpenMCL where the
native callback was defined with a gensym'ed name, which means
redefinitions of CFFI callbacks would not actually redefine the native
callback.

In CMU CL, almost every test fails from a saved image, with or without
these changes---I'm not sure what's up with that yet.

Allegro, CLISP, OpenMCL, and LispWorks now pass all expected tests
from a saved image.  (In CLISP, you need to reload foreign libraries
by hand after loading the saved image.  We might want to add another
initialization hook to reload libraries loaded by CFFI...)

SBCL passes all tests from a saved image with the PURIFY workaround,
and should work out of the box when the underlying callback bug is
fixed.

I can't get the ECL backend to build, and I don't have access to
Corman, so they are untested.

Jörg, in the CLISP implementation, I'm a little concerned about using
FFI::EXEC-ON-STACK to convert the functions to callbacks, but I
couldn't find another way to get the effect of FFI:WITH-C-VAR at
runtime, given a parsed type.

Comments?

James



More information about the cffi-devel mailing list