[cffi-devel] foreign-symbol-pointer weirdness

Samium Gromoff _deepfire at mail.ru
Mon Apr 10 21:55:50 UTC 2006


here is the scenario:

(defpackage :lispverse
  (:use :common-lisp :cffi))
   
(in-package :lispverse)
        
(define-foreign-library libverse
    (:unix (:or "/home/deepfire/source/%
EXTRN/uni-verse/=src/verse/libverse.so"))
  (t (:default "libverse")))
(use-foreign-library libverse)

(let ((foreign-ptr (foreign-symbol-pointer
"verse_send_connect_accept" :code)))
  (format t "foreign-ptr contents: ")
  (dotimes (i 16)
    (format t "~2,'0X " (the (unsigned-byte 8) (mem-ref
foreign-ptr :uint8 i))))
  (format t "~%"))

This code gives different printouts on CLISP/CMUCL/SBCL backends:

CLISP:
foreign-ptr contents: 55 89 E5 83 EC 28 8B 45 0C 89 44 24 04 8D 45 F8
CMUCL:
foreign-ptr contents: E9 26 AE C3 F9 90 00 00 00 00 00 00 00 00 00 00
SBCL:
foreign-ptr contents: E9 CE A2 A1 47 90 00 00 00 00 00 00 00 00 00 00

This amounts to foreign-symbol-pointer finding different things
on different lisps, in the same shared library.


The CLISP way appears to be correct, according to objdump:

0001a43b <verse_send_connect_accept>:
   1a43b:       55                      push   %ebp
   1a43c:       89 e5                   mov    %esp,%ebp
   1a43e:       83 ec 28                sub    $0x28,%esp
   1a441:       8b 45 0c                mov    0xc(%ebp),%eax
   1a444:       89 44 24 04             mov    %eax,0x4(%esp)
   1a448:       8d 45 f8                lea    0xfffffff8(%ebp),%eax
   1a44b:       89 04 24                mov    %eax,(%esp)
   ...

libverse.so is attached.

regards, Samium Gromoff

-------------- next part --------------
A non-text attachment was scrubbed...
Name: libverse.so.gz
Type: application/octet-stream
Size: 82996 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20060411/9b1e5863/attachment.obj>


More information about the cffi-devel mailing list