1 ;;;; support and placeholders for System Area Pointers (SAPs) in the host
2 ;;;; Common Lisp at cross-compile time
4 ;;;; This software is part of the SBCL system. See the README file for
7 ;;;; This software is derived from the CMU CL system, which was
8 ;;;; written at Carnegie Mellon University and released into the
9 ;;;; public domain. The software is in the public domain and is
10 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
11 ;;;; files for more information.
15 ;;; SYSTEM-AREA-POINTER is not a primitive type in ANSI Common Lisp,
16 ;;; so we need a compound type to represent it in the host Common Lisp
17 ;;; at cross-compile time:
18 (defstruct (system-area-pointer (:constructor int-sap
(int))
20 ;; the integer representation of the address
21 (int nil
:type unsigned-byte
:read-only t
))
23 ;;; cross-compilation-host analogues of target-CMU CL primitive SAP operations
25 ,@(mapcar (lambda (info)
26 (destructuring-bind (sap-fun int-fun
) info
27 `(defun ,sap-fun
(x y
)
28 (,int-fun
(sap-int x
) (sap-int y
)))))
29 '((sap< <) (sap<= <=) (sap= =) (sap>= >=) (sap> >) (sap- -
))))
31 ;;; dummies, defined so that we can declare they never return and
32 ;;; thereby eliminate a thundering herd of optimization notes along
33 ;;; the lines of "can't optimize this expression because we don't know
34 ;;; the return type of SAP-REF-8"
35 (defun sap-ref-stub (name)
36 (error "~S doesn't make sense on cross-compilation host." name
))
38 ,@(mapcan (lambda (name)
39 `((declaim (ftype (function (system-area-pointer fixnum
) nil
)
41 (defun ,name
(sap offset
)
42 (declare (ignore sap offset
))
43 (sap-ref-stub ',name
))
44 ,@(let ((setter-stub (gensym "SETTER-STUB-")))
45 `((defun ,setter-stub
(foo sap offset
)
46 (declare (ignore foo sap offset
))
47 (sap-ref-stub '(setf ,name
)))
48 (defsetf ,name
,setter-stub
)))))
61 signed-sap-ref-word
)))