From: "Jan Beulich" Subject: Re: [PATCHv4 1/5] x86: provide add_sized() Date: Wed, 13 May 2015 10:48:39 +0100 Message-ID: <55533A170200007800079EA7@mail.emea.novell.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> <55531AC9.7050603@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YsTHO-000751-Mc for xen-devel@lists.xenproject.org; Wed, 13 May 2015 09:48:42 +0000 In-Reply-To: <55531AC9.7050603@citrix.com> 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: David Vrabel 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 at 11:35, wrote: > 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. Indeed - such an attempt of a conversion would result in a compilation error. The only thing that could need this would be pointers, but (as said before) I don't think add_sized makes much sense for pointers (it would be actively misleading for pointers to other than void or 1-byte types). Jan