[cffi-devel] CFFI problem in Lispworks 5.1 32-bit with :long-long emulation

Luís Oliveira luismbo at gmail.com
Wed Dec 23 06:45:48 UTC 2009


On Wed, Dec 23, 2009 at 4:07 AM, Matt Lamari <matt.lamari at gmail.com> wrote:
>
> Sorry for the late response.
>
> I don't have the code/opportunity to test all the cases; but wonder if
> the enclosed patch - touching all the #+lispworks-64bit, is what's
> really needed. . .  ?

Well, could you tell me whether my previous patch works for you and
why you need this one?


> I.e. every 64-bit replaced with (or lispworks5.1 lispworks-64bit)
> or the like
>
>
>
>
> Luís Oliveira wrote:
>> On Thu, Nov 19, 2009 at 5:33 PM, Matt Lamari <matt.lamari at gmail.com> wrote:
>>
>>> (defcfun test :int64)
>>>
>> [...]
>>
>>> The long-long gets through and fails in the lispworks-specific "Ecase"
>>> (that has them removed for non-64-bit lispworks).
>>>
>>
>> Long-long emulation is not implemented for DEFCFUN, DEFCALLBACK, etc.
>> It turns out that Lispworks does in fact support long-long on 32-bit
>> platforms for DEFCFUN at least. Please let me know if the attached
>> patch works for you.
>>
>>
>
>
> --- cffi-lispworks.lisp 2009-06-16 11:20:08.000000000 -0500
> +++ c:\t\cffi-lispworks.lisp    2009-12-22 22:04:10.350220400 -0600
> @@ -62,7 +62,7 @@
>
>  ;;;# Misfeatures
>
> -#-lispworks-64bit (pushnew 'no-long-long *features*)
> +#-(or lispworks5.1 lispworks-64bit) (pushnew 'no-long-long *features*)
>
>  ;;;# Symbol Case
>
> @@ -156,9 +156,9 @@
>     (:unsigned-int       '(:unsigned :int))
>     (:long               :long)
>     (:unsigned-long      '(:unsigned :long))
> -    #+lispworks-64bit
> +    #+(or lispworks5.1 lispworks-64bit)
>     (:long-long          '(:long :long))
> -    #+lispworks-64bit
> +    #+(or lispworks5.1 lispworks-64bit)
>     (:unsigned-long-long '(:unsigned :long :long))
>     (:float              :float)
>     (:double             :double)
> @@ -170,10 +170,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 #+lispworks-64bit :long-long)
> +    ((:char :short :int :long #+(or lispworks5.1 lispworks-64bit) :long-long)
>      `(signed-byte ,(* 8 (%foreign-type-size cffi-type))))
>     ((:unsigned-char :unsigned-short :unsigned-int :unsigned-long
> -      #+lispworks-64bit :unsigned-long-long)
> +      #+(or lispworks5.1 lispworks-64bit) :unsigned-long-long)
>      `(unsigned-byte ,(* 8 (%foreign-type-size cffi-type))))
>     (:float 'single-float)
>     (:double 'double-float)))
> @@ -186,7 +186,7 @@
>
>  ;; Lispworks 5.0 on 64-bit platforms doesn't have [u]int64 support in
>  ;; FOREIGN-TYPED-AREF.  That was implemented in 5.1.
> -#+(and lispworks-64bit lispworks5.0)
> +#+(and (or lispworks5.1 lispworks-64bit) lispworks5.0)
>  (defun 64-bit-type-p (type)
>   (member type '(:long :unsigned-long :long-long :unsigned-long-long)))
>
> @@ -196,7 +196,7 @@
>  (define-compiler-macro %mem-ref (&whole form ptr type &optional (off 0))
>   (if (constantp type)
>       (let ((type (eval type)))
> -        (if (or #+(and lispworks-64bit lispworks5.0) (64-bit-type-p type)
> +        (if (or #+(and (or lispworks5.1 lispworks-64bit) lispworks5.0) (64-bit-type-p type)
>                 (eql type :pointer))
>             (let ((fli-type (convert-foreign-type type))
>                   (ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))))
> @@ -230,7 +230,7 @@
>   (if (constantp type)
>       (once-only (val)
>         (let ((type (eval type)))
> -          (if (or #+(and lispworks-64bit lispworks5.0) (64-bit-type-p type)
> +          (if (or #+(and (or lispworks5.1 lispworks-64bit) lispworks5.0) (64-bit-type-p type)
>                   (eql type :pointer))
>               (let ((fli-type (convert-foreign-type type))
>                     (ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))))
>
>



-- 
Luís Oliveira
http://r42.eu/~luis/




More information about the cffi-devel mailing list