[Xcb] compiler padding and sync extension

Josh Triplett josh at joshtriplett.org
Tue Aug 18 07:40:30 PDT 2009


On Mon, Aug 17, 2009 at 09:41:38PM -0500, Aaron Young wrote:
> While playing around with the sync extension using XCB, I've
> apparently come across the same issue mentioned here:
> http://lists.freedesktop.org/archives/xcb/2007-August/002970.html,
> which seems to have fallen between the cracks somewhere.

This does indeed seem to have gotten lost.

> I'm no expert, but I was a little surprised to discover that XCB
> structures weren't already defined with __attribute__ ((packed)),
> #pragma pack(1), etc.  Any reason this approach hasn't been adopted?
> Does the sync extension not get enough use to warrant fixing this?

This does need fixing.  The question becomes: how do we fix it
optimally?  As I understand it, __attribute__((packed)) makes GCC
generate fairly terrible code sometimes; we'd need to check if it does
so in this case.  That would in any case only solve the problem for GCC.
The "solution" of #defining a wire size for structures that disagrees
with sizeof seems even worse, though; on the other hand, given that many
structures have variable-length fields afterward that make sizeof less
useful to the client app, maybe the pain would remain confined to XCB's
accessor functions.

- Josh Triplett


More information about the Xcb mailing list