From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 4/5] xen: Add V4V implementation Date: Thu, 19 Jul 2012 12:40:46 +0100 Message-ID: <5007F23E.6070406@citrix.com> References: <1340900786-21802-1-git-send-email-jean.guyader@citrix.com> <1340900786-21802-5-git-send-email-jean.guyader@citrix.com> <4FED8467020000780008CC68@nat28.tlf.novell.com> <4FEDA13A020000780008CD19@nat28.tlf.novell.com> <5007D4A3.8090908@citrix.com> <5007E4A8.6000807@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: Jan Beulich , "Jean Guyader (3P)" , Jean Guyader , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org 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