Bogus :long-long alignment in Clozure CL
Bug #622339 reported by
Luís Oliveira
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
CFFI |
New
|
High
|
Unassigned |
Bug Description
On Tue, Jun 1, 2010 at 7:55 AM, Helmut Eller <email address hidden> wrote:
> I think there is a bug in CFFI with CCL's 32-bit version:
>
> (cffi:defcunion foo-union
> (int16 :int16 )
> (uint64 :uint64 )
> )
>
> (cffi:defcstruct bar-struct
> (tag :uint8)
> (val foo-union))
>
> (defun foo ()
> (cffi:with-
> (- (cffi:pointer-
> (cffi:pointer-
>
>
> FOO returns 4 in SBCL and Lispworks but with CCL it's 8.
To post a comment you must log in.
This happens with a recent ccl under linux 32 bits env, and not occure under linux 64, etc. type-alignment always returns 64 for the long-long type (of course, it is theoretically true
By this wrong alignment problem, for example, cl-gtk2's demo crashes.
The reason is very clear. As you know, gcc under linux 32 has 64 bits alignment for the long-long type. But
there is an exception that, in a struct or union, it becomes 32 bits alignment. However,
ccl:foreign-
and internally ccl uses proper alignment (=32) for the record type).
Therefore the following patch is needed: openmcl. lisp.org 2012-09-25 00:48:14.000000000 +0900 openmcl. lisp 2012-09-25 00:51:09.000000000 +0900 clozure. com/pipermail/ openmcl- devel/2005- June/002777. html type-alignment (type-keyword) long-long) type-alignment 4))) type-alignment
(ccl:: parse-foreign- type
(convert- foreign- type type-keyword))) 8))
*** ./src/cffi-
--- ./src/cffi-
***************
*** 222,227 ****
--- 222,231 ----
;; http://
(defun %foreign-
"Return the alignment in bytes of a foreign type."
+ #+32-bit-target <= please specify proper condition!
+ (case type-keyword
+ ((:double :long-long :unsigned-
+ (return-from %foreign-
(/ (ccl::foreign-