Thanks again to Martin Simmons.

Luís Oliveira wrote:
> Thanks for your tips Martin.
>
> On 24/09/2007, Martin Simmons <[EMAIL PROTECTED]> wrote:
>   
>> Because of this last restriction, if CFFI wants to support :long-long on
>> 32-bit LispWorks platforms, then it can do it for DEFCFUN but not other APIs.
>> A single cffi-feature is not enough to describe this, so it could just 
>> support
>> it on 64-bit platforms by using #-lispworks-64bit to enable
>> cffi-features:no-long-long.
>>     
>
> Tian, since I don't have access to 64-bit lispworks I guess you're on
> your own. If you come up with a patch, though, I'll gladly test it on
> 32-bit lispworks and apply it.
>
>   
Oliveira,

As Martin Simmons' suggest, I made another patch which works for me on
my 64-bit lispworks edition.
Please review it and apply it as your wish, thanks.

Chun Tian (binghe)

#! /bin/sh /usr/share/dpatch/dpatch-run
## 10_lispworks.dpatch by  <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad cffi-20070901~/src/cffi-lispworks.lisp 
cffi-20070901/src/cffi-lispworks.lisp
--- cffi-20070901~/src/cffi-lispworks.lisp      2007-09-25 13:01:10.000000000 
+0800
+++ cffi-20070901/src/cffi-lispworks.lisp       2007-09-25 13:21:52.000000000 
+0800
@@ -65,12 +65,14 @@
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (mapc (lambda (feature) (pushnew feature *features*))
         '(;; Backend mis-features.
+          #-lispworks-64bit
           cffi-features:no-long-long
           ;; OS/CPU features.
           #+darwin  cffi-features:darwin
           #+unix    cffi-features:unix
           #+win32   cffi-features:windows
           #+harp::pc386   cffi-features:x86
+          #+harp::amd64   cffi-features:x86-64
           #+harp::powerpc cffi-features:ppc32
           )))
 
@@ -163,6 +165,10 @@
     (:unsigned-int    '(:unsigned :int))
     (:long            :long)
     (:unsigned-long   '(:unsigned :long))
+    #+lispworks-64bit
+    (:long-long       '(:long :long))
+    #+lispworks-64bit
+    (:unsigned-long-long '(:unsigned :long :long))
     (:float           :float)
     (:double          :double)
     (:pointer         :pointer)
@@ -173,9 +179,10 @@
 #+#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or))
 (defun convert-foreign-typed-aref-type (cffi-type)
   (ecase cffi-type
-    ((:char :short :int :long)
+    ((:char :short :int :long #+lispworks-64bit :long-long)
      `(signed-byte ,(* 8 (%foreign-type-size cffi-type))))
-    ((:unsigned-char :unsigned-short :unsigned-int :unsigned-long)
+    ((:unsigned-char :unsigned-short :unsigned-int :unsigned-long
+                     #+lispworks-64bit :unsigned-long-long)
      `(unsigned-byte ,(* 8 (%foreign-type-size cffi-type))))
     (:float 'single-float)
     (:double 'double-float)))
@@ -192,7 +199,10 @@
 (define-compiler-macro %mem-ref (&whole form ptr type &optional (off 0))
   (if (constantp type)
       (let ((type (eval type)))
-        (if (eql type :pointer)
+        (if (or (eql type :pointer)
+                #+(and lispworks-64bit lispworks5.0)
+               (member type '(:long :unsigned-long
+                               :long-long :unsigned-long-long)))
             (let ((fli-type (convert-foreign-type type))
                   (ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))))
               `(fli:dereference ,ptr-form :type ',fli-type))
@@ -225,7 +235,10 @@
   (if (constantp type)
       (once-only (val)
         (let ((type (eval type)))
-          (if (eql type :pointer)
+          (if (or (eql type :pointer)
+                  #+(and lispworks-64bit lispworks5.0)
+                  (member type '(:long :unsigned-long
+                                 :long-long :unsigned-long-long)))
               (let ((fli-type (convert-foreign-type type))
                     (ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))))
                 `(setf (fli:dereference ,ptr-form :type ',fli-type) ,val))
_______________________________________________
cffi-devel mailing list
cffi-devel@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel

Reply via email to