All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Cc: Jan Beulich <JBeulich@suse.com>,
	"Jean Guyader (3P)" <jean.guyader@citrix.com>,
	Jean Guyader <jean.guyader@gmail.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 4/5] xen: Add V4V implementation
Date: Thu, 19 Jul 2012 12:40:46 +0100	[thread overview]
Message-ID: <5007F23E.6070406@citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1207191228360.23783@kaball.uk.xensource.com>

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

  reply	other threads:[~2012-07-19 11:40 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-28 16:26 [PATCH 0/5] RFC: V4V (v2) Jean Guyader
2012-06-28 16:26 ` [PATCH 1/5] xen: add ssize_t Jean Guyader
2012-06-29  8:05   ` Jan Beulich
2012-06-29 10:09     ` Jean Guyader
2012-06-29 10:38       ` Jan Beulich
2012-06-28 16:26 ` [PATCH 2/5] v4v: Introduce VIRQ_V4V Jean Guyader
2012-06-29  8:07   ` Jan Beulich
2012-06-29 10:33     ` Jean Guyader
2012-06-28 16:26 ` [PATCH 3/5] xen: Enforce introduce guest_handle_for_field Jean Guyader
2012-06-29  8:10   ` Jan Beulich
2012-06-28 16:26 ` [PATCH 4/5] xen: Add V4V implementation Jean Guyader
2012-06-29  8:33   ` Jan Beulich
2012-06-29 10:03     ` Jean Guyader
2012-06-29 10:36       ` Jan Beulich
2012-07-18 20:09         ` Jean Guyader
2012-07-19  9:34           ` Andrew Cooper
2012-07-19  9:58             ` Jean Guyader
2012-07-19  9:54               ` Attilio Rao
2012-07-19 10:06                 ` Jean Guyader
2012-07-19 10:04                   ` Attilio Rao
2012-07-19 10:32                     ` Ian Campbell
2012-07-19 10:42               ` Andrew Cooper
2012-07-19 11:33                 ` Stefano Stabellini
2012-07-19 11:40                   ` Andrew Cooper [this message]
2012-07-19 11:58                 ` Jean Guyader
2012-07-23  8:18           ` Jan Beulich
2012-07-05 11:36   ` Tim Deegan
2012-06-28 16:26 ` [PATCH 5/5] v4v: Introduce basic access control to V4V Jean Guyader
2012-07-05 14:23   ` Tim Deegan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5007F23E.6070406@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=jean.guyader@citrix.com \
    --cc=jean.guyader@gmail.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.