home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!caen!sdd.hp.com!think.com!barmar
- From: barmar@think.com (Barry Margolin)
- Newsgroups: comp.lang.lisp
- Subject: Re: Calling C function from LCL
- Date: 19 Aug 1992 18:23:45 GMT
- Organization: Thinking Machines Corporation, Cambridge MA, USA
- Lines: 31
- Message-ID: <16u3jhINN9m1@early-bird.think.com>
- References: <Bt8G1E.229@iai.kfk.de>
- NNTP-Posting-Host: telecaster.think.com
-
- In article <Bt8G1E.229@iai.kfk.de> harry@issun1.kfk.de writes:
- >1) What is this missing symbol __DYNAMIC
-
- You can ignore that. It's related to Sun's dynamic linking implementation,
- but Lucid's FFI only loads static libraries.
-
- >2) The contents of the array are all multiplied by 4. Has this something
- > to do with the type of the lisp object? I always thought, it is coded in the high order
- > bits of the data.
-
- C ints correspond to Lisp fixnums, but you passed an untyped array. Lucid
- (and many other Lisp implementations) puts some tag bits information in the
- low-order two bits of objects; they're ordinarily unused, since all the
- types that are accessed through pointers require full-word alignment.
- Fixnums have the type tags 00 (positive fixnum) and 11 (negative fixnum);
- this has the property that the tagged value is the result of an arithmetic
- shift of the untagged value, which allows them to be added without
- untagging, and multiplied by shifting the result rather than the arguments.
-
- The arrays you pass to the foreign function must be created with
-
- (make-array 4 :element-type 'fixnum)
-
- >3) What is wrong in my declaration of the foreign function, that make all these things happen?
-
- Nothing.
- --
- Barry Margolin
- System Manager, Thinking Machines Corp.
-
- barmar@think.com {uunet,harvard}!think!barmar
-