From: John Morrison <jm@ma...> - 2005-05-20 16:27:17
Short Version: How can I tell what foreign symbols are "undefined"
even though they have addresses?
* (SB-SYS:GET-DYNAMIC-FOREIGN-SYMBOL-ADDRESS "_ZNSt9exceptionC1Ev")
STYLE-WARNING: Undefined alien: "_ZNSt9exceptionC1Ev"
Longer Version: GCCXML emits records for everything, including the
above (constructor for std::exception). However, when I try to
define-alien-routine, it errors. What's the right way to "sniff"
foreign symbols before I generate any errors by attempting to
define-alien-routine them? Something of the form:
(zerop (sap-int (dlsym *runtime-dlhandle* "_ZNSt9exceptionC1Ev")))
How do I get the right *runtime-dlhandle* when I'm loading or I have
loaded multiple shared libraries?
==== John Morrison
==== MAK Technologies Inc.
==== 10 Fawcett Street, Cambridge, MA 02138
==== vox:617-876-8085 x115
On Fri, 20 May 2005, John Morrison wrote:
> * (SB-SYS:GET-DYNAMIC-FOREIGN-SYMBOL-ADDRESS "_ZNSt9exceptionC1Ev")
> STYLE-WARNING: Undefined alien: "_ZNSt9exceptionC1Ev"
> Longer Version: GCCXML emits records for everything, including the
> above (constructor for std::exception). However, when I try to
> define-alien-routine, it errors.
What do you mean by errors? The intention is that DEFINE-ALIEN-ROUTINE
should just give the same undefined-alien style-warning, and only actually
_calling_ it should signal an error.
What version of SBCL are you using?
This is SBCL 0.9.0.28, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (define-alien-routine foobar int)
; caught STYLE-WARNING:
; Undefined alien: "foobar"
; compilation unit finished
; caught 1 STYLE-WARNING condition
debugger invoked on a SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR in thread
Attempt to call an undefined alien function.
As for you actual question, I think maybe we should and could provide
SB-ALIEN:ALIEN-SYMBOL-ADDRESS (or -SAP?), that would accept an optional
argument to indicate what should be done if the symbol cannot be found.
Currently, you would need to write your own using
GET-DYNAMIC-FOREIGN-SYMBOL-ADDRESS as a starting point.
-- Nikodemus Schemer: "Buddha is small, clean, and serious."
Lispnik: "Buddha is big, has hairy armpits, and laughs."