From: "Jan Beulich" Subject: Re: [PATCH v3 4/6] xen: introduce XEN_GUEST_HANDLE_PARAM Date: Fri, 17 Aug 2012 10:17:46 +0100 Message-ID: <502E285A0200007800095D04@nat28.tlf.novell.com> References: <1345128612-10323-4-git-send-email-stefano.stabellini@eu.citrix.com> <502D33B8020000780009596B@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Disposition: inline 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: "xen-devel@lists.xensource.com" , "Tim (Xen.org)" , Ian Campbell List-Id: xen-devel@lists.xenproject.org >>> On 16.08.12 at 19:08, Stefano Stabellini wrote: > On Thu, 16 Aug 2012, Jan Beulich wrote: >> >>> On 16.08.12 at 16:50, Stefano Stabellini 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