home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / lisp / 2254 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  1.7 KB

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