X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fforeign-stack-alignment.impure.lisp;h=91e93781e701474f4e5462bf017ef65c813d601a;hb=d7875c296a4988e9f27e2776237884deb1984c62;hp=0f416e3f2d0aa18834b32c75a014c858dde6ed19;hpb=4e6200853a661da5e73d0843a4afca9077a06fa8;p=sbcl.git diff --git a/tests/foreign-stack-alignment.impure.lisp b/tests/foreign-stack-alignment.impure.lisp index 0f416e3..91e9378 100644 --- a/tests/foreign-stack-alignment.impure.lisp +++ b/tests/foreign-stack-alignment.impure.lisp @@ -22,7 +22,6 @@ (output (with-output-to-string (s) (setf proc (run-program program arguments - :search (not (eql #\. (char program 0))) :output s))))) (unless (zerop (process-exit-code proc)) (error "Bad exit code: ~S~%Output:~% ~S" @@ -32,44 +31,53 @@ (defvar *required-alignment* #+(and ppc darwin) 16 - #+(and ppc linux) 8 + #+(and ppc (not darwin)) 8 #+x86-64 16 #+mips 8 - #+x86 4 - #-(or x86 x86-64 mips (and ppc (or darwin linux))) (error "Unknown platform")) + #+(and x86 (not darwin)) 4 + #+(and x86 darwin) 16 + #+sparc 8 + #-(or x86 x86-64 mips ppc sparc) + (error "Unknown platform")) ;;;; Build the offset-tool as regular excutable, and run it with ;;;; fork/exec, so that no lisp is on the stack. This is our known-good ;;;; number. -(run "cc" - #+(and linux (or x86-64 ppc)) "-fPIC" - "stack-alignment-offset.c" "-o" "stack-alignment-offset") +#-win32 +(progn + (run "/bin/sh" "run-compiler.sh" "-sbcl-pic" + "stack-alignment-offset.c" "-o" "stack-alignment-offset") -(defparameter *good-offset* - (parse-integer (run "./stack-alignment-offset" - (princ-to-string *required-alignment*)))) + (defparameter *good-offset* + (parse-integer (run "./stack-alignment-offset" + (princ-to-string *required-alignment*)))) -;;;; Build the tool again, this time as a shared object, and load it + ;; Build the tool again, this time as a shared object, and load it -(run "cc" "stack-alignment-offset.c" - #+(and linux (or x86-64 ppc)) "-fPIC" - #+darwin "-bundle" #-darwin "-shared" - "-o" "stack-alignment-offset.so") + (run "/bin/sh" "run-compiler.sh" "-sbcl-pic" "-sbcl-shared" + "stack-alignment-offset.c" "-o" "stack-alignment-offset.so") -(load-shared-object "stack-alignment-offset.so") + (load-shared-object (truename "stack-alignment-offset.so")) -(define-alien-routine stack-alignment-offset int (alignment int)) -(define-alien-routine trampoline int (callback (function int))) + (define-alien-routine stack-alignment-offset int (alignment int)) + #+alien-callbacks + (define-alien-routine trampoline int (callback (function int)))) ;;;; Now get the offset by calling from lisp, first with a regular foreign function ;;;; call, then with an intervening callback. -(with-test (:name :regular) +(with-test (:name :regular :fails-on :win32) (assert (= *good-offset* (stack-alignment-offset *required-alignment*)))) -(with-test (:name :callback) - (assert (= *good-offset* (trampoline (alien-lambda int () - (stack-alignment-offset *required-alignment*)))))) +#+alien-callbacks +(with-test (:name :callback :fails-on :win32) + (assert (= *good-offset* + (trampoline (alien-lambda int () + (stack-alignment-offset *required-alignment*)))))) + +(when (probe-file "stack-alignment-offset.so") + (delete-file "stack-alignment-offset") + (delete-file "stack-alignment-offset.so")) ;;;; success!