1 Many of the structure offsets and symbolic constants necessary to do
2 FFI vary between architectures and operating systems. To avoid a
3 maintenance nightmare, we derive them automatically by creating and
4 running a small C program. The C program is created by
5 def-to-lisp.lisp with input from a GROVEL-CONSTANTS-FILE
7 The ASDF component type GROVEL-CONSTANTS-FILE has its PERFORM
8 operation defined to write out a C source file, compile it, and run
9 it. The output from this program is Lisp, which is then itself
12 How to use it from your own system
14 1) Create a Lisp package for the foreign constants/functions to go into.
15 It needs to use SB-GROVEL and SB-ALIEN
17 2) Make your system depend on the "sb-grovel" system
19 3) Create a grovel-constants data file - see example-constants.lisp in
22 4) Add it as a component in your system. e.g.
24 (defsystem sbcl-hemlock
25 :depends-on (sb-grovel)
30 (sb-grovel:grovel-constants-file "example-constants"
31 :package :sbcl-hemlock
34 Make sure to specify the package you chose in step 1
40 Note that we assume that the C type char has 8 bits.