1.0.25.50: detect binding and alien stack exhaustion
[sbcl/llvm.git] / tests / swap-lispobjs.impure.lisp
blobc3cf6f5d8bd31f707e51995be902d2b698eb9c12
1 ;;;; Testing swap_lispobjs.
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; from CMU CL.
9 ;;;;
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
14 (use-package :sb-alien)
16 #-(or x86 x86-64)
17 (sb-ext:quit :unix-status 104)
19 (defun run (program &rest arguments)
20 (let* ((proc nil)
21 (output
22 (with-output-to-string (s)
23 (setf proc (run-program program arguments
24 :search (not (eql #\. (char program 0)))
25 :output s)))))
26 (unless (zerop (process-exit-code proc))
27 (error "Bad exit code: ~S~%Output:~% ~S"
28 (process-exit-code proc)
29 output))
30 output))
32 (run "cc" "-O3"
33 "-I" "../src/runtime/"
34 "swap-lispobjs.c"
35 #+(and (or linux freebsd) (or x86-64 ppc mips)) "-fPIC"
36 #+(and x86-64 darwin) "-arch" #+(and x86-64 darwin) "x86_64"
37 #+darwin "-bundle" #-darwin "-shared"
38 "-o" "swap-lispobjs.so")
40 (load-shared-object (truename "swap-lispobjs.so"))
42 (define-alien-routine try-to-zero-with-swap-lispobjs int
43 (lispobj-adress unsigned-long))
45 (with-test (:name :swap-lispobjs)
46 (let ((x (cons 13 27)))
47 (try-to-zero-with-swap-lispobjs
48 (logandc2 (sb-kernel:get-lisp-obj-address x)
49 sb-vm:lowtag-mask))
50 (assert (equal x (cons 0 27)))))
52 (delete-file "swap-lispobjs.so")