2008/4/5 Chun Tian (binghe) <[EMAIL PROTECTED]>:
>  I ... think CFFI should support LispWorks 5.0 for long-long
[...]
>  Since it's not hard to consider both versions, I (personal) hope you can
> support them both, and that will be perfect.

Can you test the attached patch (diffed against cffi+lotsastuff) and
see if it works for both LW 5.1 and 5.0? I only have the 32-bit
Personal Edition so I can't test long-long support myself.

By the way, foreign strings seem completely broken. Do the string
tests pass for you?

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/
--- old-cffi+lotsastuff/src/cffi-lispworks.lisp	2008-04-05 18:05:13.000000000 +0100
+++ new-cffi+lotsastuff/src/cffi-lispworks.lisp	2008-04-05 18:05:13.000000000 +0100
@@ -64,7 +64,7 @@
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (mapc (lambda (feature) (pushnew feature *features*))
-        '(cffi-features:no-long-long)))
+        '(#-lispworks-64bit cffi-features:no-long-long)))
 
 ;;;# Symbol Case
 
@@ -147,27 +147,32 @@
 (defun convert-foreign-type (cffi-type)
   "Convert a CFFI type keyword to an FLI type."
   (ecase cffi-type
-    (:char            :byte)
-    (:unsigned-char   '(:unsigned :byte))
-    (:short           :short)
-    (:unsigned-short  '(:unsigned :short))
-    (:int             :int)
-    (:unsigned-int    '(:unsigned :int))
-    (:long            :long)
-    (:unsigned-long   '(:unsigned :long))
-    (:float           :float)
-    (:double          :double)
-    (:pointer         :pointer)
-    (:void            :void)))
+    (:char               :byte)
+    (:unsigned-char      '(:unsigned :byte))
+    (:short              :short)
+    (:unsigned-short     '(:unsigned :short))
+    (:int                :int)
+    (: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)
+    (:void               :void)))
 
 ;;; Convert a CFFI type keyword to a symbol suitable for passing to
 ;;; FLI:FOREIGN-TYPED-AREF.
 #+#.(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)))
@@ -184,6 +189,12 @@
 (define-compiler-macro %mem-ref (&whole form ptr type &optional (off 0))
   (if (constantp type)
       (let ((type (eval type)))
+        ;; Lispworks 5.0 on 64-bit platforms doesn't have long-long in
+        ;; FOREIGN-TYPED-AREF.  That was implemented in 5.1.
+        #+(and lispworks-64bit lispworks5.0)
+        (when (or (eql type :unsigned-long-long)
+                  (eql type :long-long))
+          (return-from %mem-ref form))
         (if (eql type :pointer)
             (let ((fli-type (convert-foreign-type type))
                   (ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))))
@@ -217,6 +228,12 @@
   (if (constantp type)
       (once-only (val)
         (let ((type (eval type)))
+          ;; Lispworks 5.0 on 64-bit platforms doesn't have long-long in
+          ;; FOREIGN-TYPED-AREF.  That was implemented in 5.1.
+          #+(and lispworks-64bit lispworks5.0)
+          (when (or (eql type :unsigned-long-long)
+                    (eql type :long-long))
+            (return-from %mem-ref form))
           (if (eql type :pointer)
               (let ((fli-type (convert-foreign-type type))
                     (ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))))

_______________________________________________
cffi-devel mailing list
cffi-devel@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel

Reply via email to