next up previous contents
Next: 8.7.5 Accessing Lisp Arrays Up: 8.7 Alien Function Calls Previous: def-alien-routine Example

8.7.4 Calling Lisp from C

Calling Lisp functions from C is sometimes possible, but is rather hackish. See funcall0 ... funcall3 in the `lisp/arch.h'. The arguments must be valid CMU CL object descriptors (e.g. fixnums must be left-shifted by 2.) See `compiler/generic/objdef.lisp' or the derived file `lisp/internals.h' for details of the object representation. `lisp/internals.h' is mechanically generated, and is not part of the source distribution. It is distributed in the `docs/' directory of the binary distribution.

Note that the garbage collector moves objects, and won't be able to fix up any references in C variables, so either turn GC off or don't keep Lisp pointers in C data unless they are to statically allocated objects. You can use  purify (page gif) to place live data structures in static space so that they won't move during GC.


change_begin


change_end


Raymond Toy
Mon Jul 14 09:11:27 EDT 1997