Subject: [clisp-list] FFI extensions - work in progress - you may try it out!

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Fri Apr 19 04:45:12 2002

Hi,

here is my current set of FFI extensions, which is IMHO taking shape.
To try this out, you'll need
o a fairly recent CLISP, better from CVS, since I fixed some bugs
o probably the dynload module?
o to be able to compile CLISP from sources
o add to modules.h: MODULE(ffimext)

o to walk through the code, esp. ffilext.lisp...

I also included zlib-clisp.lisp, which enables compression for CL-PDF with CLISP. It's unreleased for now.

Monday, this will work (I just changed the macro API once again):
(defun compress-string6 (source)
  "Compress the string SOURCE. Returns an array of bytes
representing the compressed data."
  (let* ((sourcelen (length source))
	 (destlen (+ 12 (ceiling (* sourcelen 1.05)))))
    (ffi::with-c-var (dest `(c-array uint8 ,destlen)) ; no init
      (multiple-value-bind (status actual)
	  (zlib-compress-string (ffi::c-var-address dest) destlen source sourcelen)
	(if (zerop status)
	    ;;(subseq dest 0 actual)
	    ;;ffi:cast not usable because of different size...
	    (ffi:offset dest 0 `(c-array uint8 ,actual))
	  (error "zlib error, code ~d" status))))))

Enjoy,
	Jörg Höhle.

---

From: Peter Wood <[email-masked]>
Date: Fri Apr 19 16:26:02 2002

Hi,

Thanks, Joerg.  Unfortunately, I seem to be missing something:

bash-2.04$ grep -e 'mark_invalid_foreign' clisp/src/*.d
clisp/src/ffimext.d:#  LISPFUNN(mark_invalid_foreign,1)
clisp/src/ffimext.d:#  LISPFUNN(mark_invalid_foreign,1)
clisp/src/ffimext.d:#  LISPSYM(mark_invalid_foreign,"MARK-INVALID-FOREIGN",ffi)

Ie, mark_invalid_foreign seems to be missing (undefined).

Indeed, when I try to compile, everything goes beautifully, but...

In file included from ffimext.d:4:
lispbibl.d: At top level:
lispbibl.d:7097: warning: register used for two global register variables
ffimext.d: In function `C_mark_invalid_foreign':
ffimext.d:15: warning: implicit declaration of function `Hack_mark_invalid_foreign'
ffimext.d: In function `C_complex_malloc':
ffimext.d:16: warning: implicit declaration of function `Hack_complex_malloc'
ffimext.d: In function `C_exec_with_stack1':
ffimext.d:17: warning: implicit declaration of function `Hack_exec_with_stack1'
gcc -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -fomit-frame-pointer -Wno-sign-compare -O2 -fexpensive-optimizations -DUNICODE -DDYNAMIC_FFI -x none sysdll.o spvw.o spvwtabf.o spvwtabs.o spvwtabo.o eval.o control.o encoding.o pathname.o stream.o socket.o io.o array.o hashtabl.o list.o package.o record.o sequence.o charstrg.o debug.o error.o misc.o time.o predtype.o symbol.o lisparit.o i18n.o foreign.o dynload.o ffimext.o unixaux.o ari80386.o modules.o libsigsegv.a libintl.a libiconv.a libreadline.a libavcall.a libcallback.a  -lncurses -ldl  -o lisp.run
ffimext.o: In function `C_mark_invalid_foreign':
ffimext.o(.text+0x4): undefined reference to `Hack_mark_invalid_foreign'
collect2: ld returned 1 exit status
make: *** [lisp.run] Error 1

If you look at the '.o' files, I think you'll agree that I am linking
in everything I ought to be, previous to ffimext.o.

Alternatively, maybe I have forgotten something ... :-) Perhaps I have
not understood how I am supposed to build/prepare ffimext.o?

I have a patch for configure and makemake.in which autocreate rules
for building the extensions which you have posted to the list.  Once
this mark_invalid_foreign problem sorted out, I will post the patch to
the list, and hopefully more people will be able to build and report
back.

I am using cvs Clisp (downloaded Friday evening, CET), and
sysdll-1.7.c, sysdll-1.3.h, and dynload.d.

Regards,
Peter