[Ecls-list] DFFI on x86_64

Marco Gidde marco.gidde at tiscali.de
Mon Feb 5 22:41:51 UTC 2007

"Juan Jose Garcia-Ripoll" <juanjose.garciaripoll at googlemail.com> writes:
> 2007/2/5, Marco Gidde <marco.gidde at tiscali.de>:
>> recently I tried to build a lisp wrapper around a C-library with CFFI
>> and got some strange crashes with ECL. The appended patch is probably
>> not quite correct but works here and should give you an idea of what
>> is still missing.
> Thanks. I am not very fluent with the 64 bit extensions. In particular
> the big number of registers and the conventions for variable number of
> arguments calling make it complicated. I hope the interface will get
> more polished once I find time to work on the PPC port.

I haven't a clue about all this. The last registers that I knew quite
well were those of the 6510 in my old Commodore 64, so be *very*
cautious with the patch - it will probably break something else :-)

>> Another issue occurred when I tried callbacks with an ECL built with
>> the --with-cxx option (also via CFFI). While C allows to cast a void*
>> to any kind of function pointer, C++ doesn't. Maybe a reinterpret_cast
>> in the generated C-code might help, but I'm not sure and haven't
>> testet this.
> I will look into this. Does it happen in the ECL core or in compiled code?

It only happens in compiled code which uses CFFI, the ECL core seems
to be clean (and probably is for quite a while now). I built a small
example to test the effect. It compiles and loads nicely with C-ECL
but breaks when compiling with C++-ECL. The error message looks like

> ;;; Calling the C compiler...
> ;;; Note: Invoking external command:
> ;;; g++  -D_GNU_SOURCE -g -O2 -fPIC  -fstrict-aliasing -Dlinux -O "-I/home/local/lib/ecl/" -w -c "/home/mg/LANG/LISP/MG/Aprol/SWIG/ecl-test/test.c" -o "/home/mg/LANG/LISP/MG/Aprol/SWIG/ecl-test/test.o"

> /home/mg/LANG/LISP/MG/Aprol/SWIG/ecl-test/test.c: In function ‘void init_fas_CODE(cl_lispunion*)’:
> /home/mg/LANG/LISP/MG/Aprol/SWIG/ecl-test/test.c:61: error: invalid conversion from ‘void (*)()’ to ‘void*’
> /home/mg/LANG/LISP/MG/Aprol/SWIG/ecl-test/test.c:61: error:   initializing argument 3 of ‘cl_lispunion* ecl_make_foreign_data(cl_lispunion*, cl_index, void*)’
> An error occurred during initialization:

The generated C-file is also attached. gcc --version gives

> gcc (GCC) 4.1.2 20061115 (prerelease) (SUSE Linux)

I hope it's not a gcc issue. gcc recently got very picky concerning
standards. :-/



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.lisp
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20070205/17df0266/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 2230 bytes
Desc: test.c
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20070205/17df0266/attachment.c>

More information about the ecl-devel mailing list