From: "Jan Beulich" Subject: Re: [PATCHv4 1/8] x86: provide arch_fetch_and_add() Date: Thu, 07 May 2015 16:59:15 +0100 Message-ID: <554BA7F30200007800077C32@mail.emea.novell.com> References: <1430408002-30666-1-git-send-email-david.vrabel@citrix.com> <1430408002-30666-2-git-send-email-david.vrabel@citrix.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 1YqOCi-0003YY-UH for xen-devel@lists.xenproject.org; Thu, 07 May 2015 15:59:17 +0000 In-Reply-To: <1430408002-30666-2-git-send-email-david.vrabel@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 30.04.15 at 17:33, wrote: > +static always_inline unsigned long __xadd( > + volatile void *ptr, unsigned long v, int size) > +{ > + switch ( size ) > + { > + case 1: > + asm volatile ( "lock; xaddb %b0,%1" > + : "+r" (v), "+m" (*__xg((volatile void *)ptr)) "ptr" already is "volatile void *", so why the cast? Or is this just an artifact of __xchg() doing the same odd thing? > +#define arch_fetch_and_add(ptr, v) \ > + ({ \ > + (typeof(*(ptr)))__xadd(ptr, (typeof(*(ptr)))(v), sizeof(*(ptr))); \ > + }) It being a single expression inside the braces I don't think you really need the ({}) GNU extension here. Both of course easily adjusted while committing, if you agree. Jan