My OpenAL code also uses stuff from alc.h, so I modified my binding def:
(defbinding "openal-library" (nicknames "al") (flags "") (include "AL/al.h" "AL/alc.h" "AL/alut.h") (export "alenable" "aldisable") (override ""))
This yielded amongst other good stuff:
(cffi:defcstruct alcdevice-struct)
...on which we get divide-by-zero in CFFI because notice-foreign-struct-definition initializes max-align to zero and that never gets bumped up (because there are no slots and that is when it gets adjusted) and then gets used in a rem to determine padding.
Checking alc.h and the rest of the al includes, I do not see any actual definition for alcdevice-struct. I guess the type is needed to define the functions which get passed a pointer to a device struct, but the actual make-up of the struct is pure internal.
I will let you all fight it out, but it looks as if CFFI needs to be more tolerant? I will try initializing the max-align to 2 and see how much further I get.
On 7/set/2005, at 04:49, Kenny Tilton wrote:
(cffi:defcstruct alcdevice-struct)
[...]
I will let you all fight it out, but it looks as if CFFI needs to be more tolerant? I will try initializing the max-align to 2 and see how much further I get.
CFFI needs bug fixing that's what it is. :-)
Well, I can't find anything specific about empty structures in the ABI docs so I'm going to assume an empty struct indeed has size 0 and alignment 1 (or 0, whatever).
I'll add a test for this too.
Entertainingly enough, the C and C++ ABIs differ in this regard.
C (even C99) says that sizeof(empty-struct) = 0, alignof(empty-struct) = 1 C++ says that sizeof(empty-struct) = 1, alignof(empty-struct) = 1
I say use the C layout, since Verrazano does its own layout for C++ that doesn't depend on what CFFI thinks the sizeof a type is.
Sincerely, Rayiner hashem
On 9/7/05, Luis Oliveira luismbo@gmail.com wrote:
On 7/set/2005, at 04:49, Kenny Tilton wrote:
(cffi:defcstruct alcdevice-struct)
[...]
I will let you all fight it out, but it looks as if CFFI needs to be more tolerant? I will try initializing the max-align to 2 and see how much further I get.
CFFI needs bug fixing that's what it is. :-)
Well, I can't find anything specific about empty structures in the ABI docs so I'm going to assume an empty struct indeed has size 0 and alignment 1 (or 0, whatever).
I'll add a test for this too.
-- Luís Oliveira http://student.dei.uc.pt/~lmoliv/ Equipa Portuguesa do Translation Project http://www2.iro.umontreal.ca/~pinard/po/registry.cgi?team=pt
cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel
Luis Oliveira luismbo@gmail.com writes:
CFFI needs bug fixing that's what it is. :-)
Ah, right. Just above notice-foreign-struct-definition there was this comment of mine:
;;; TODO: figure out what to do with empty structures.
Well, max-align should have been 1.
Kenny, setting max-align to 2 is a bad idea. It'll break structs that have only chars.
So, I've pushed a patch that fixes this and the respective regression test.