[Xcb] compiler padding and sync extension

Aaron Young m.aaron.young at gmail.com
Tue Aug 18 20:31:28 PDT 2009


>> 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.

My understanding (which is certainly limited and probably flawed) is
that performance issues would only arise in situations where the
compiler would have previously (before using #pragma pack) padded
certain parts of a structure in order to simplify member access code.
However, if the compiler was previously doing this, that means those
situations are potentially broken anyway as the padding would have
caused the memory representation of those structures to deviate from
the protocol.

-Aaron


More information about the Xcb mailing list