[Openmcl-devel] problem building FFI files

Gary Byers gb at clozure.com
Tue May 30 19:05:55 PDT 2006


There was a bug in 1.0: HASH-TABLEs that use non-standard :TEST functions
(such as #'STRING=) didn't work correctly.

For no extraordinarily good reason, the FFI parser creates hash tables
with non-standard :TEST functions.

This was fixed in CVS a while ago, and I believe that it's fixed in
a 1.0 patch image that's available on the FTP server:

<ftp://clozure.com/pub/dppccl-image-1.0-p060223.tar.gz>


If you don't want to wrestle with that, it may be simpler to change
about 10 calls to MAKE-HASH-TABLE in "parse-ffi.lisp" from:

(make-hash-table :test #'string= :hash-function 'sxhash)

to

(make-hash-table :test #'equal)

[Arguably, the real fix is to get 1.1 released ...]


On Tue, 30 May 2006, Kaveh Kardan wrote:

> I'm setting up the process for connecting OpenMCL to some C libraries.
>
> I manage to call the C functions in the following manner:
>
> --
>
> (external-call "_bz_vec_test" :void)
>
> --
>
> I have installed h-to-ffi.sh and run it on a simple .h file:
>
> --
>
> #include <stdlib.h>
> #include <stdio.h>
> #include <math.h>
>
> typedef struct {
>   union {
>     struct {
>       float x, y, z, w;
>     };
>     float vec[4];
>   };
> } bz_vec;
> bz_vec *bz_make_vec();
> void bz_print_vec(bz_vec *v);
> void bz_vec_test();
>
> --
>
> The script parses the contents of the included system .h files as
> well, resulting in a very large .ffi file.  The relevant portion of
> the file seems to be:
>
> --
>
> (struct ("" 0)
> "444_/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.h"
> (("x" (field (float ()) 0 4))
>   ("y" (field (float ()) 4 4))
>   ("z" (field (float ()) 8 4))
>   ("w" (field (float ()) 12 4))))
> (union ("" 0)
> "445_/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.h"
> (("" (field (struct-ref "444_/Users/kaveh/Development/bronze2/build/
> Development/Bronze.framework/Headers/bz_vec.h") 0 16))
>   ("vec" (field (array 4 (float ())) 0 16))))
> (struct ("" 0)
> "447_/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.h"
> (("" (field (union-ref "445_/Users/kaveh/Development/bronze2/build/
> Development/Bronze.framework/Headers/bz_vec.h") 0 16))))
> (type ("/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.h" 12)
> "bz_vec"
> (struct-ref "447_/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.h"))
> (function ("/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.h" 14)
> "bz_make_vec"
> (function
>   ((void ()))
>   (pointer (typedef "bz_vec"))) (extern))
> (function ("/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.h" 15)
> "bz_print_vec"
> (function
>   ((pointer (typedef "bz_vec")) )
>   (void ())) (extern))
> (function ("/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.h" 17)
> "bz_vec_test"
> (function
>   ((void ()))
>   (void ())) (extern))
>
> --
>
> When I try to parse the file, I get an error:
>
> CL-USER> (ccl::parse-standard-ffi-files "bronze")
> #P"/Applications/CommonLisp/ccl/darwin-headers/bronze/C/Users/kaveh/
> Development/bronze2/build/Development/Bronze.framework/Headers/
> bz_vec.ffi" ...
>
>
> value #<Unbound> is not of the expected type (OR STRING SYMBOL
> CHARACTER).
>    [Condition of type TYPE-ERROR]
>
> Restarts:
>   0: [ABORT-REQUEST] Abort handling SLIME request.
>   1: [ABORT-BREAK] Reset this process
>   2: [ABORT] Kill this process
>
> Backtrace:
>   0: (STRING 'NIL)
>   1: (CCL::STRING-START-END "__int8_t" #<Unbound> 0)
>   2: (STRING= "__int8_t" #<Unbound>)
>   3: (CCL::%HASH-PROBE #<HASH-TABLE :TEST STRING= size 0/60
> #x87F1FBE> 'NIL #<HASH-TABLE-VECTOR  #x87F202E>)
>   4: (GETHASH "__int8_t" 'NIL "__int8_t")
>   5: (CCL::FIND-OR-CREATE-FFI-TYPEDEF ':TYPE)
>   6: (CCL::PROCESS-FFI-TYPEDEF '(:TYPE ("/usr/include/ppc/_types.h"
> 31) "__int8_t" (:SIGNED-CHAR NIL)))
>   7: (CCL::PARSE-FFI #P"/Applications/CommonLisp/ccl/darwin-headers/
> bronze/C/Users/kaveh/Development/bronze2/build/Development/
> Bronze.framework/Headers/bz_vec.ffi")
>   8: (CCL::PARSE-STANDARD-FFI-FILES "bronze")
>   9: (CCL::CALL-CHECK-REGS 'CCL::PARSE-STANDARD-FFI-FILES)
>
> --
>
> Anyone have any ideas what I'm doing wrong?
>
>
> Regards,
>
> Kaveh
>
> Kaveh Kardan                 Chief Technologist
> kaveh at hawaii.edu             Academy for Creative Media
> (808)956-5302                University of Hawaii
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list