FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version



Returns a list whose entries each represent a C (or C-compatible) function to call before garbage collections of any kind. The typical declaration of the C function can be

int mybeforehook(int gctype);

where gctype is passed in as 0 if the current gc is a scavenge and 1 if a global-gc.

The list entry itself is typically an (unsigned-byte 32) array, for 32-bit Lisps, or (unsigned-byte 64) or (signed-byte 64) array, for 64-bit Lisps. The array must have at least 1 entry, and its first entry must be the address of the C function. (signed-byte 32) will also work on 32-bit Lisps if the address is small enough or wrapped, if in the upper half of memory. There is no restriction on using a (signed-byte 64) array on a 64-bit Lisp.

setf can be used to store into the list.

A typical usage of this feature is

;;  This example is for 32-bit Lisps as it uses (unsigned-byte 32)
;;  arrays. For 64-bit Lisps, you can use (unsigned-byte 64) arrays
(let ((myaddr (ff:get-entry-point "mybeforehook")))
 (push (make-array 1 :element-type '(unsigned-byte 32)

:initial-element myaddr)

No gc hooks are saved across dumplisps. All applications are responsible for re-establishing their own gc-before-c-hooks.

See also gc.htm for general information on garbage collection in Allegro CL.

Warning: No before hook should ever call back into lisp. The fact that during the hook call a gc is about to begin means that most likely there is no space in lisp heap. Also, it should never be assumed that the callback will not require lisp heap, even if the lisp function itself does not cons. A program whose before-hook calls into lisp may not fail the majority of the time, but it is likely to fail at some inopportune time with disastrous results.

Copyright (c) 1998-2012, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 9.0. This page was not revised from the 8.2 page.
Created 2012.5.30.

Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version