Dietz)
* bug fix: interrupt handling on NetBSD (thanks to Richard M
Kreuter)
+ * bug fix: saving a core corrupted callbacks on x86/x86-64
* optimization: faster implementation of EQUAL
* fixed segfaults on x86 FreeBSD 7-current (thanks to NIIMI Satoshi)
;; :stack-allocatable-closures
;; The compiler can allocate dynamic-extent closures on stack.
;;
+ ;; :alien-callbacks
+ ;; Alien callbacks have been implemented for this platform.
+ ;;
;; operating system features:
;; :linux = We're intended to run under some version of Linux.
;; :bsd = We're intended to run under some version of BSD Unix. (This
# similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
if [ "$sbcl_arch" = "x86" ]; then
printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
- printf ' :stack-allocatable-closures' >> $ltf
+ printf ' :stack-allocatable-closures :alien-callbacks' >> $ltf
if [ "$sbcl_os" = "linux" ] || [ "$sbcl_os" = "freebsd" ] || [ "$sbcl_os" = "netbsd" ] || [ "$sbcl_os" = "sunos" ]; then
printf ' :linkage-table' >> $ltf
fi
elif [ "$sbcl_arch" = "x86-64" ]; then
printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :linkage-table' >> $ltf
- printf ' :stack-allocatable-closures' >> $ltf
+ printf ' :stack-allocatable-closures :alien-callbacks' >> $ltf
elif [ "$sbcl_arch" = "mips" ]; then
printf ' :linkage-table' >> $ltf
printf ' :stack-allocatable-closures' >> $ltf
elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "darwin" ]; then
printf ' :stack-allocatable-closures' >> $ltf
# We provide a dlopen shim, so a little lie won't hurt
- printf " :os-provides-dlopen :linkage-table" >> $ltf
+ printf " :os-provides-dlopen :linkage-table :alien-callbacks" >> $ltf
# The default stack ulimit under darwin is too small to run PURIFY.
# Best we can do is complain and exit at this stage
if [ "`ulimit -s`" = "512" ]; then
"COMPUTE-NATURALIZE-LAMBDA" "DEFINE-ALIEN-TYPE-CLASS"
"DEFINE-ALIEN-TYPE-METHOD" "DEFINE-ALIEN-TYPE-TRANSLATOR" "DEPORT"
"DEPOSIT-ALIEN-VALUE" "DISPOSE-LOCAL-ALIEN"
- "ENTER-ALIEN-CALLBACK"
+ "*ENTER-ALIEN-CALLBACK*" "ENTER-ALIEN-CALLBACK"
"EXTRACT-ALIEN-VALUE"
"HEAP-ALIEN-INFO" "HEAP-ALIEN-INFO-P" "HEAP-ALIEN-INFO-SAP-FORM"
"HEAP-ALIEN-INFO-TYPE" "INVOKE-ALIEN-TYPE-METHOD" "LOCAL-ALIEN"
return
arguments))
+;;; To ensure that callback wrapper functions continue working even
+;;; if #'ENTER-ALIEN-CALLBACK moves in memory, access to it is indirected
+;;; through the *ENTER-ALIEN-CALLBACK* static symbol. -- JES, 2006-01-01
+(defvar *enter-alien-callback* #'enter-alien-callback)
+
;;;; interface (not public, yet) for alien callbacks
(defmacro alien-callback (specifier function &environment env)
(bug "Unknown alien floating point type: ~S" type)))))
;; arg0 to FUNCALL3 (function)
- (inst mov rdi (get-lisp-obj-address #'enter-alien-callback))
+ ;;
+ ;; Indirect the access to ENTER-ALIEN-CALLBACK through
+ ;; the symbol-value slot of SB-ALIEN::*ENTER-ALIEN-CALLBACK*
+ ;; to ensure it'll work even if the GC moves ENTER-ALIEN-CALLBACK.
+ ;; Skip any SB-THREAD TLS magic, since we don't expecte anyone
+ ;; to rebind the variable. -- JES, 2006-01-01
+ (inst mov rdi (+ nil-value (static-symbol-offset
+ 'sb!alien::*enter-alien-callback*)))
+ (loadw rdi rdi symbol-value-slot other-pointer-lowtag)
;; arg0 to ENTER-ALIEN-CALLBACK (trampoline index)
(inst mov rsi (fixnumize index))
;; arg1 to ENTER-ALIEN-CALLBACK (pointer to argument vector)
;; For GC-AND-SAVE
*restart-lisp-function*
+ ;; Needed for callbacks to work across saving cores. see
+ ;; ALIEN-CALLBACK-ASSEMBLER-WRAPPER in c-call.lisp for gory details.
+ sb!alien::*enter-alien-callback*
+
;; The ..SLOT-UNBOUND.. symbol is static in order to optimise the
;; common slot unbound check.
;;
(inst add eax 16) ; arguments
(inst push eax) ; arg1
(inst push (ash index 2)) ; arg0
- (inst push (get-lisp-obj-address #'enter-alien-callback)) ; function
+
+ ;; Indirect the access to ENTER-ALIEN-CALLBACK through
+ ;; the symbol-value slot of SB-ALIEN::*ENTER-ALIEN-CALLBACK*
+ ;; to ensure it'll work even if the GC moves ENTER-ALIEN-CALLBACK.
+ ;; Skip any SB-THREAD TLS magic, since we don't expecte anyone
+ ;; to rebind the variable. -- JES, 2006-01-01
+ (inst mov eax (+ nil-value (static-symbol-offset
+ 'sb!alien::*enter-alien-callback*)))
+ (loadw eax eax symbol-value-slot other-pointer-lowtag)
+ (inst push eax) ; function
(inst mov eax (foreign-symbol-address "funcall3"))
(inst call eax)
;; now put the result into the right register
;; For GC-AND-SAVE
*restart-lisp-function*
+ ;; Needed for callbacks to work across saving cores. see
+ ;; ALIEN-CALLBACK-ASSEMBLER-WRAPPER in c-call.lisp for gory details.
+ sb!alien::*enter-alien-callback*
+
;; The ..SLOT-UNBOUND.. symbol is static in order to optimise the
;; common slot unbound check.
;;
(in-package :cl-user)
;;; callbacks only on a few platforms
-#-(or (and ppc darwin) x86 x86-64)
+#-alien-callbacks
(quit :unix-status 104)
;;; simple callback for a function
exit 1
fi
+# In sbcl-0.9.8 saving cores with callbacks didn't work on gencgc platforms
+$SBCL <<EOF
+ (defun bar ()
+ (format t "~&Callbacks not supported, skipping~%")
+ (quit :unix-status 42))
+ #+alien-callbacks
+ (progn
+ (sb-alien::define-alien-callback foo int () 42)
+ (defun bar () (quit :unix-status (alien-funcall foo))))
+ (save-lisp-and-die "$tmpcore")
+EOF
+$SBCL_ALLOWING_CORE --core "$tmpcore" \
+--userinit /dev/null --sysinit /dev/null <<EOF
+ (bar)
+EOF
+if [ $? = 42 ]; then
+ echo "/Callbacks after SAVE-LISP-AND-DIE worked, good."
+else
+ echo "failure in basic SAVE-LISP-AND-DIE: $?"
+ exit 1
+fi
+
rm -f $tmpcore
echo "/returning success from core.test.sh"
exit 104
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.8.13"
+"0.9.8.14"