[Ecls-list] Problem compiling CFFI
Goffioul Michael
goffioul at imec.be
Fri Oct 21 05:21:48 UTC 2005
> Maybe turning it into an interpreted function, like in the following
> examples:
>
> (setf (fdefinition 'foo)
> (coerce '(ext:lambda-block foo (x) (1+ x) 'function))
>
> (funcall (coerce '(lambda (x) (sin x)) 'function) pi)
>
> Perhaps one could automatically redefine #'COMPILE from within the
> compiler, but that really looks like a hack.
That's what I did, but this required to change non system code in CFFI
using #+/-ecl, I wanted to know if there was another way.
Something else: I modified the load-foreign-library macro to handle
dynamic FFI and suppressed the error with non constant name (otherwise,
CFFI cannot be compiled). The diff is the following:
Index: ffi.lsp
===================================================================
RCS file: /cvsroot/ecls/ecls/src/lsp/ffi.lsp,v
retrieving revision 1.31
diff -u -3 -p -r1.31 ffi.lsp
--- ffi.lsp 19 Oct 2005 07:54:24 -0000 1.31
+++ ffi.lsp 21 Oct 2005 12:17:17 -0000
@@ -625,10 +625,12 @@
(defmacro load-foreign-library (filename &key module supporting-libraries force-load)
(declare (ignore module force-load supporting-libraries))
- (unless (constantp filename)
- (error "~&LOAD-FOREIGN-LIBRARY: ~A is not a constant expression. This is currently not supported." filename))
- `(eval-when (:compile-toplevel)
- (do-load-foreign-library ,filename)))
+ (let ((compile-form (and (constantp filename)
+ `((eval-when (:compile-toplevel)
+ (do-load-foreign-library ,filename)))))
+ (dyn-form #-dffi nil
+ #+dffi `((si:load-foreign-module ,filename))))
+ `(progn , at compile-form , at dyn-form)))
;;;----------------------------------------------------------------------
;;; CALLBACKS
Is it OK?
Michael.
More information about the ecl-devel
mailing list