1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
10 (in-package "SB!ALIEN")
12 (defvar *alien-type-classes* (make-hash-table :test 'eq))
14 (defvar *new-auxiliary-types* nil)
16 ;;; the list of record types that have already been unparsed. This is
17 ;;; used to keep from outputting the slots again if the same structure
19 (defvar *record-types-already-unparsed*)
21 ;;; not documented in CMU CL:-(
23 ;;; reverse engineering observations:
24 ;;; * seems to be set when translating return values
25 ;;; * seems to enable the translation of (VALUES), which is the
26 ;;; Lisp idiom for C's return type "void" (which is likely
27 ;;; why it's set when when translating return values)
28 (defvar *values-type-okay* nil)
30 (defvar *default-c-string-external-format* nil)
32 ;;; Frame pointer, program counter conses. In each thread it's bound
33 ;;; locally or not bound at all.
34 (defvar *saved-fp-and-pcs*)
36 #!+:c-stack-is-control-stack
37 (declaim (inline invoke-with-saved-fp-and-pc))
38 #!+:c-stack-is-control-stack
39 (defun invoke-with-saved-fp-and-pc (fn)
40 (declare #-sb-xc-host (muffle-conditions compiler-note)
42 (let* ((fp-and-pc (cons (sb!kernel:%caller-frame)
43 (sap-int (sb!kernel:%caller-pc)))))
44 (declare (truly-dynamic-extent fp-and-pc))
45 (let ((*saved-fp-and-pcs* (if (boundp '*saved-fp-and-pcs*)
46 (cons fp-and-pc *saved-fp-and-pcs*)
48 (declare (truly-dynamic-extent *saved-fp-and-pcs*))
51 (defun find-saved-fp-and-pc (fp)
52 (when (boundp '*saved-fp-and-pcs*)
53 (dolist (x *saved-fp-and-pcs*)
54 (when (#!+:stack-grows-downward-not-upward
56 #!-:stack-grows-downward-not-upward
58 (int-sap (sb!kernel:get-lisp-obj-address (car x))) fp)
59 (return (values (car x) (cdr x)))))))