On Wed, 2006-10-11 at 22:20 +0200, Juan Jose Garcia-Ripoll wrote:
I had to play a few tricks because CFFI does not allow us to include headers function declarations and ECL cannot rely on the arguments to FOREIGN-FUNCALL which are most of the time bogus. For instance, :string is an alias to :pointer and when you call (foreign-funcall "strlen" :string .. ) we cannot produce a proper C declaration to strlen that does not collide with the one provided by the header <string.h>.
So in the end I end up always using the routine dlsym() to discover the functions and coerce them to a function pointer created with the information given by CFFI. The outcome is therefore much less efficient than what ECL can potentially do.
In a way, this actually seems like the right thing to me. I think this is roughly what the Lisps that compile directly to native code are doing, except they only perform the dlsym once (via linkage tables or somesuch).
Would it be possible to look up the function address in a LOAD-TIME-VALUE form (not knowing how L-T-V works in compiled ECL code...) or otherwise caching it?
James