[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 4/5] xen: Add V4V implementation

On 19/07/12 12:33, Stefano Stabellini wrote:
>>> The problem isn't with the individual fields (they are all correctly
>>> aligned) it is
>>> the the overall structure size which is 64 even so offset of q is 60
>>> (and sizeof q
>>> should be 0).
>>> I think there is no way around it. The structure I have should be
>>> aligned on 64b anyway.
>>> Thanks,
>>> Jean
>> Ah yes - silly me.  I understand your problem now
>> struct b
>> {
>>     uint64_t a;
>>     uint32_t b;
>>     uint16_t c;
>>     uint16_t d;
>>     uint32_t e;
>>     uint32_t f;
>>     uint32_t g;
>>     uint8_t  h[32];
>>     union { uint8_t  q[0]; uint32_t _pad; } u;
>> };
>> This works for me on gcc and gives identical sizeof and offsetof results
>> on both 32 and 64bit.
> Yes, but then the access to q becomes b.u.q unless we use anonymous
> unions that are only available in C11.

Combine it with the Linux style of

#define q u.q

although with rather more sensible names than q and u, or just use a
macro for all accesses to q from b.

Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.