Luís Oliveira wrote:
Hello Tian,
On 22/09/2007, Chun Tian (binghe) <binghe.lisp@gmail.com> wrote:
+ #-lispworks5 cffi-features:no-long-long
If possible, we should instead use one of the following approaches for checking whether Lispworks has long long support:
* some feature keyword symbol specific to long long support, if Lispworks provides any.
* check for version 5.0 or higher, presuming all platforms support long long as of version 5.0. (does Lispworks provide something like Allegro's :VERSION>=?)
* programmatically check for long long support at read-time, i.e.: (eval-when (<always>) (unless (somehow-check-for-long-long-here) (pushnew 'cffi-features:no-long-long *features*)))
If you could modify the patch to use one of these alternative approaches, that would be great. Thanks.
Attach is a modified patch which I use now, using (fli::64bit-long-p). #! /bin/sh /usr/share/dpatch/dpatch-run ## 10_lispworks.dpatch by <binghe@localhost.localdomain> ## ## 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-22 22:33:06.000000000 +0800 +++ cffi-20070901/src/cffi-lispworks.lisp 2007-09-22 22:35:58.000000000 +0800 @@ -65,12 +65,14 @@ (eval-when (:compile-toplevel :load-toplevel :execute) (mapc (lambda (feature) (pushnew feature *features*)) '(;; Backend mis-features. + #-#.(cl:if (fli::64bit-long-p) '(and) '(or)) 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)) + #+#.(cl:if (fli::64bit-long-p) '(and) '(or)) + (:long-long '(:long :long)) + #+#.(cl:if (fli::64bit-long-p) '(and) '(or)) + (:unsigned-long-long '(:unsigned :long :long)) (:float :float) (:double :double) (:pointer :pointer) @@ -170,7 +176,8 @@ ;;; 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)) +#+#.(cl:if (cl:and (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") + (cl:not (fli::64bit-long-p))) '(and) '(or)) (defun convert-foreign-typed-aref-type (cffi-type) (ecase cffi-type ((:char :short :int :long) @@ -188,7 +195,8 @@ ;;; In LispWorks versions where FLI:FOREIGN-TYPED-AREF is fbound, use ;;; it instead of FLI:DEREFERENCE in the optimizer for %MEM-REF. -#+#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) +#+#.(cl:if (cl:and (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") + (cl:not (fli::64bit-long-p))) '(and) '(or)) (define-compiler-macro %mem-ref (&whole form ptr type &optional (off 0)) (if (constantp type) (let ((type (eval type))) @@ -204,7 +212,8 @@ ;;; Open-code the call to FLI:DEREFERENCE when TYPE is constant at ;;; macroexpansion time, when FLI:FOREIGN-TYPED-AREF is not available. -#-#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) +#-#.(cl:if (cl:and (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") + (cl:not (fli::64bit-long-p))) '(and) '(or)) (define-compiler-macro %mem-ref (&whole form ptr type &optional (off 0)) (if (constantp type) (let ((ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))) @@ -220,7 +229,8 @@ ;;; In LispWorks versions where FLI:FOREIGN-TYPED-AREF is fbound, use ;;; it instead of FLI:DEREFERENCE in the optimizer for %MEM-SET. -#+#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) +#+#.(cl:if (cl:and (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") + (cl:not (fli::64bit-long-p))) '(and) '(or)) (define-compiler-macro %mem-set (&whole form val ptr type &optional (off 0)) (if (constantp type) (once-only (val) @@ -239,7 +249,8 @@ ;;; Open-code the call to (SETF FLI:DEREFERENCE) when TYPE is constant ;;; at macroexpansion time. -#-#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) +#-#.(cl:if (cl:and (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") + (cl:not (fli::64bit-long-p))) '(and) '(or)) (define-compiler-macro %mem-set (&whole form val ptr type &optional (off 0)) (if (constantp type) (once-only (val)