[Ecls-list] ECL_FOREIGN_DATA_P(), ecl_foreign_data_pointer_safe(), etc

Matthew Mondor mm_lists at pulsar-zone.net
Tue Oct 2 11:14:40 UTC 2012

Hello again,

When reviving my old ecl-unix code, I wanted to isolate the various FFI
hacks I put in it to another file and actually ended mostly
reimplementing them.  This also made me look at the C and assembly
results when for instance looking at what C structure accessors looked

I noticed many calls to ecl_to_pointer() expanding to
ecl_foreign_data_pointer_safe() calls even with (optimize (safety 0)).
But interestingly in cmp/sysfun.lsp, I saw the following line:

(def-inline si:foreign-data-p :always (t) :bool "@0;ECL_FOREIGN_DATA_P(#0)")

Was this an attempt to inline such cases?  Although there seems to be a
difference between data and pointer?

I also noticed that my DECLAIM to inline the accessor functions do not
appear to work, so there also always are function calls made to
access/set structure fields no matter the SPEED/SAFETY level.  This is
not terrible, although if such small functions could be inlined it'd be
nice.  Since the inline declamations appeared to work in other contexts
for small functions, I wondered if perhaps it's a limitation of
functions using C-INLINE.  I also thought about perhaps generating
small C functions with the inline directive via CLINES instead of using
C-INLINE too, which could be another approach (I'd also have to check
how to get those to register CL symbols and be ECL friendly then).

(the aforementioned code is http://cvs.pulsar-zone.net/cgi-bin/cvsweb.cgi/~checkout~/mmondor/mmsoftware/cl/test/mmffi.lisp)


More information about the ecl-devel mailing list