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

Re: [Xen-devel] [PATCH 1/5] xen: improve changes to xen_add_to_physmap



On 7 August 2012 13:27, Stefano Stabellini
<stefano.stabellini@xxxxxxxxxxxxx> wrote:
> On Mon, 6 Aug 2012, Jan Beulich wrote:
>> >>> On 06.08.12 at 17:43, Stefano Stabellini 
>> >>> <stefano.stabellini@xxxxxxxxxxxxx>
>> wrote:
>> > On Mon, 6 Aug 2012, Jan Beulich wrote:
>> >> >>> On 06.08.12 at 16:12, Stefano Stabellini 
>> >> >>> <stefano.stabellini@xxxxxxxxxxxxx>
>> >> wrote:
>> >> > This is an incremental patch on top of
>> >> > c0bc926083b5987a3e9944eec2c12ad0580100e2: in order to retain binary
>> >> > compatibility, it is better to introduce foreign_domid as part of a
>> >> > union containing both size and foreign_domid.
>> >> >
>> >> > Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
>> >> > ---
>> >> >  xen/include/public/memory.h |   11 +++++++----
>> >> >  1 files changed, 7 insertions(+), 4 deletions(-)
>> >> >
>> >> > diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
>> >> > index b2adfbe..b0af2fd 100644
>> >> > --- a/xen/include/public/memory.h
>> >> > +++ b/xen/include/public/memory.h
>> >> > @@ -208,8 +208,12 @@ struct xen_add_to_physmap {
>> >> >      /* Which domain to change the mapping for. */
>> >> >      domid_t domid;
>> >> >
>> >> > -    /* Number of pages to go through for gmfn_range */
>> >> > -    uint16_t    size;
>> >> > +    union {
>> >> > +        /* Number of pages to go through for gmfn_range */
>> >> > +        uint16_t    size;
>> >> > +        /* IFF gmfn_foreign */
>> >> > +        domid_t foreign_domid;
>> >> > +    };
>> >>
>> >> But you're clear that this isn't standard C, and hence can't go
>> >> in this way?
>> >>
>> >
>> > Why? It is c11 if I am not mistaken.
>>
>> Yes. But the common baseline is C89.
>
> Do we need to keep it C89?
> If I am not mistaken anonymous unions have been in GCC for more than 10
> years now.
>

It's a public header so you can't assume that the only consumer will be GCC.

> If we do want to keep it C89, considering that size was introduced only
> recently, do you think that it would be OK for me to change the
> interface and just add size to a union?
> Like this:
>
> union {
>     /* Number of pages to go through for gmfn_range */
>     uint16_t    size;
>     /* IFF gmfn_foreign */
>     domid_t foreign_domid;
> } u;
>

You could probably do something like

#ifdef __GNUC__
# define UNION_NAME
#else
# define UNION_NAME u
#endif
union {
    /* Number of pages to go through for gmfn_range */
    uint16_t    size;
    /* IFF gmfn_foreign */
    domid_t foreign_domid;
} UNION_NAME;

It's not ideal but this way you keep the binary compatibility and you
also the code still cmopatible with GCC.

Jean

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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