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

Re: [Xen-devel] [PATCH for-4.6] xen/public: arm: Use __typeof__ rather than typeof



>>> On 23.10.15 at 16:55, <ian.campbell@xxxxxxxxxx> wrote:
> On Fri, 2015-10-23 at 15:44 +0100, Julien Grall wrote:
>> #define set_xen_guest_handle_raw(hnd, val)                  \
>>     do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0;   \
>>          (hnd).p = val;                                     \
>>     } while ( 0 )
> 
> This evaluates hnd twice, which I assumed we wanted to avoid.

Hmm, that's true. We've got a couple of __GNUC__ dependencies
in the headers already - perhaps this is a reason to add one more
(and then also mirror the gcc alternative to x86), keeping the use
of __typeof__() in that case, thus ...

> But if that is OK for x86 in this situation then there is no harm doing it
> on ARM too[0].

... eliminating the need for [0] perhaps entirely. (I also note val
isn't properly parenthesized.)

> But in that case I think we would just do
>       (hnd).q = val ; (hnd).p = val
> rather than messing with &, casts and *.

If you're sure that val always has the upper 32 bits clear...

> I think x86 does it that way because .q doesn't exist in the
>  __guest_handle_foo, only the __guest_handle_64_foo, but it exists in both
> on ARM.

Right.

Jan

> We also know that sizeof(hnd) == 8 always on both arm subarches. Maybe it
> would be worth checking sizeof(hnd.p) == 8 (i.e. whether the real type
> completely fills the padding container), I don't know.
> 
> Ian.
> 
> [0] But maybe do check for arm specific set_guest_handle(foo++, bar) type
> constructs which slipped in...



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