From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCHv4 1/5] x86: provide add_sized() Date: Wed, 13 May 2015 10:35:05 +0100 Message-ID: <55531AC9.7050603@citrix.com> References: <1431355025-20468-1-git-send-email-david.vrabel@citrix.com> <1431355025-20468-2-git-send-email-david.vrabel@citrix.com> <5553343F0200007800079E6D@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YsT4J-0006J8-MI for xen-devel@lists.xenproject.org; Wed, 13 May 2015 09:35:11 +0000 In-Reply-To: <5553343F0200007800079E6D@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Keir Fraser , Ian Campbell , Andrew Cooper , Tim Deegan , Jennifer Herbert , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On 13/05/15 10:23, Jan Beulich wrote: >>>> On 11.05.15 at 16:37, wrote: >> @@ -53,6 +67,19 @@ void __bad_atomic_size(void); >> } \ >> }) >> >> +#define add_sized(p, x) ({ \ >> + typeof(*(p)) __x = (x); \ >> + unsigned long x_ = (unsigned long)__x; \ > > So is there a particular reason you kept this double type conversion? > As said earlier, I can see why write_atomic() wants it, but I don't see > the need here. I kept it in case typeof (*p) wasn't a numeric type (like a struct { u32 a; }) and needed the cast to unsigned long, although in hindsight I'm not sure this really makes any sense. David >> + switch ( sizeof(*(p)) ) \ >> + { \ >> + case 1: add_u8_sized((uint8_t *)(p), x_); break; \ >> + case 2: add_u16_sized((uint16_t *)(p), x_); break; \ >> + case 4: add_u32_sized((uint32_t *)(p), x_); break; \ >> + case 8: add_u64_sized((uint64_t *)(p), x_); break; \ >> + default: __bad_atomic_size(); break; \ >> + } \ >> +}) > >