|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3 4/6] xen: introduce XEN_GUEST_HANDLE_PARAM
>>> On 16.08.12 at 19:08, Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
>>> wrote:
> On Thu, 16 Aug 2012, Jan Beulich wrote:
>> >>> On 16.08.12 at 16:50, Stefano Stabellini
>> >>> <stefano.stabellini@xxxxxxxxxxxxx> wrote:
>> > +#define set_xen_guest_handle_raw(hnd, val) \
>> > + do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \
>>
>> If you made the "normal" handle a union too, you could avoid
>> the explicit cast (which e.g. gcc, when not passed
>> -fno-strict-aliasing, will choke on) and instead use (hnd).q (and
>> at once avoid the double initialization of the low half).
>>
>> Also, the condition to do this could be "sizeof(hnd) > sizeof((hnd).p)",
>> usable at once for 64-bit avoiding a full double initialization there.
>>
>> > + (hnd).p = val; \
>>
>> In a public header you certainly want to avoid evaluating a
>> macro argument twice.
>
> That's a really good suggestion.
> I am going to make both handles unions and therefore
> set_xen_guest_handle_raw becomes:
>
> #define set_xen_guest_handle_raw(hnd, val) \
> do { (hnd).q = 0; \
> (hnd).p = val; \
> } while ( 0 )
But that still doesn't eliminate the double evaluation of "hnd".
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |