Following patch lets cffi callbacks survive saving/loading a core on CMUCL, tested on 19dpre2 (also works on 19c with (pushnew #'system::reinitialize-global-table ext:*AFTER-SAVE-INITIALIZATIONS*) not sure if that is something cffi should do for 19c or not though)
diff -rN -u old-cffi/src/cffi-cmucl.lisp new-cffi/src/cffi-cmucl.lisp --- old-cffi/src/cffi-cmucl.lisp 2006-11-12 03:27:51.000000000 -0600 +++ new-cffi/src/cffi-cmucl.lisp 2006-11-12 03:27:51.000000000 -0600 @@ -320,6 +320,18 @@ (error "Undefined callback: ~S" name)) pointer))
+;;; cmucl makes new callback trampolines when it reloads, so we need to +;;; update cffi's copies +(defun reset-callbacks () + (loop + for k being the hash-keys of *CALLBACKS* + do (setf (gethash k *callbacks*) + (alien::symbol-trampoline (cffi-sys::intern-callback k))))) + +;;; needs to be after cmucl's restore-callbacks, so put at the end... +(setf ext:*after-save-initializations* + (append ext:*after-save-initializations* (list 'reset-callbacks))) + ;;;# Loading and Closing Foreign Libraries
;;; Work-around for compiling ffi code without loading the