(declaim (type hash-table *static-foreign-symbols*))
(defvar *static-foreign-symbols* (make-hash-table :test 'equal))
(declaim (type hash-table *static-foreign-symbols*))
(defvar *static-foreign-symbols* (make-hash-table :test 'equal))
(ftype (sfunction (string hash-table) (or integer null)) find-foreign-symbol-in-table))
(defun find-foreign-symbol-in-table (name table)
(let ((extern (extern-alien-name name)))
(ftype (sfunction (string hash-table) (or integer null)) find-foreign-symbol-in-table))
(defun find-foreign-symbol-in-table (name table)
(let ((extern (extern-alien-name name)))
(defun find-foreign-symbol-address (name)
"Returns the address of the foreign symbol NAME, or NIL. Does not enter the
(defun find-foreign-symbol-address (name)
"Returns the address of the foreign symbol NAME, or NIL. Does not enter the
(declare (ignorable datap))
(let ((static (find-foreign-symbol-in-table name *static-foreign-symbols*)))
(if static
(declare (ignorable datap))
(let ((static (find-foreign-symbol-in-table name *static-foreign-symbols*)))
(if static
- (values static nil)
- #!+os-provides-dlopen
- (progn
- #-sb-xc-host
- (values #!-linkage-table
- (ensure-dynamic-foreign-symbol-address name)
- #!+linkage-table
- (ensure-foreign-symbol-linkage name datap)
- t)
- #+sb-xc-host
- (error 'undefined-alien-error :name name))
- #!-os-provides-dlopen
- (error 'undefined-alien-error :name name))))
+ (values static nil)
+ #!+os-provides-dlopen
+ (progn
+ #-sb-xc-host
+ (values #!-linkage-table
+ (ensure-dynamic-foreign-symbol-address name)
+ #!+linkage-table
+ (ensure-foreign-symbol-linkage name datap)
+ t)
+ #+sb-xc-host
+ (error 'undefined-alien-error :name name))
+ #!-os-provides-dlopen
+ (error 'undefined-alien-error :name name))))
(defun foreign-symbol-sap (symbol &optional datap)
"Returns a SAP corresponding to the foreign symbol. DATAP must be true if the
(defun foreign-symbol-sap (symbol &optional datap)
"Returns a SAP corresponding to the foreign symbol. DATAP must be true if the
;; we need to do a bit of juggling. It is not the address of the
;; variable, but the address where the real address is stored.
(if (and sharedp datap)
;; we need to do a bit of juggling. It is not the address of the
;; variable, but the address where the real address is stored.
(if (and sharedp datap)
- (let ((table-addr (linkage-info-address info)))
- (when (<= table-addr
- addr
- (+ table-addr sb!vm:linkage-table-entry-size))
- (return-from sap-foreign-symbol (car name-and-datap)))))
- *linkage-info*))
+ (let ((table-addr (linkage-info-address info)))
+ (when (<= table-addr
+ addr
+ (+ table-addr sb!vm:linkage-table-entry-size))
+ (return-from sap-foreign-symbol (car name-and-datap)))))
+ *linkage-info*))
;; FIXME: Even in the absence of dladdr we could search the
;; static foreign symbols (and *linkage-info*, for that matter).
))
;; FIXME: Even in the absence of dladdr we could search the
;; static foreign symbols (and *linkage-info*, for that matter).
))
(defun !foreign-cold-init ()
(dolist (symbol *!initial-foreign-symbols*)
(setf (gethash (car symbol) *static-foreign-symbols*) (cdr symbol)))
(defun !foreign-cold-init ()
(dolist (symbol *!initial-foreign-symbols*)
(setf (gethash (car symbol) *static-foreign-symbols*) (cdr symbol)))