Henrik Motakef <[EMAIL PROTECTED]> writes:
> | * (defun my-symbol-address (symbol-name)
> | (sys:foreign-symbol-address symbol-name))
[...]
> | Error in KERNEL::UNDEFINED-SYMBOL-ERROR-HANDLER:
> | the function SYSTEM:FOREIGN-SYMBOL-CODE-ADDRESS is undefined.
Yup. It turns out that FOREIGN-SYMBOL-CODE-ADDRESS is defined by a
vop, but only for constant strings, while the DEFTRANSFORM for
FOREIGN-SYMBOL-ADDRESS translates to FOREIGN-SYMBOL-ADDRESS
unconditionally.
It should work after compiling & loading this:
(in-package "C")
(deftransform foreign-symbol-address ((symbol &key flavor)
(simple-string &rest *))
#-linkage-table
(when (null flavor)
(give-up))
#+linkage-table
(unless (constant-continuation-p symbol)
(give-up))
(let ((flav (cond ((null flavor) :code)
((not (constant-continuation-p flavor))
(give-up))
(t (continuation-value flavor)))))
(case flav
(:code
`(#+linkage-table foreign-symbol-code-address
#-linkage-table foreign-symbol-address
symbol))
(:data
`(#+linkage-table foreign-symbol-data-address
#-linkage-table foreign-symbol-address
symbol))
(t
(compiler-error
"FOREIGN-SYMBOL-ADDRESS flavor ~S is not :CODE or :DATA")))))