From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH 16/17] xen: arm: refactor xchg and cmpxchg into their own headers Date: Thu, 20 Mar 2014 17:52:47 +0000 Message-ID: <532B2AEF.5010905@linaro.org> References: <1395330336.3104.12.camel@kazak.uk.xensource.com> <1395330365-9901-16-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1395330365-9901-16-git-send-email-ian.campbell@citrix.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: Ian Campbell Cc: stefano.stabellini@eu.citrix.com, tim@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Hi Ian, On 03/20/2014 03:46 PM, Ian Campbell wrote: > diff --git a/xen/include/asm-arm/arm32/cmpxchg.h b/xen/include/asm-arm/arm32/cmpxchg.h > new file mode 100644 > index 0000000..70c6090 > --- /dev/null > +++ b/xen/include/asm-arm/arm32/cmpxchg.h > +static always_inline unsigned long __cmpxchg( > + volatile void *ptr, unsigned long old, unsigned long new, int size) > +{ > + unsigned long oldval, res; > + > + switch (size) { > + case 1: > + do { > + asm volatile("@ __cmpxchg1\n" > + " ldrexb %1, [%2]\n" > + " mov %0, #0\n" > + " teq %1, %3\n" > + " strexbeq %0, %4, [%2]\n" > + : "=&r" (res), "=&r" (oldval) > + : "r" (ptr), "Ir" (old), "r" (new) > + : "memory", "cc"); > + } while (res); > + break; > + case 2: > + do { > + asm volatile("@ __cmpxchg2\n" > + " ldrexh %1, [%2]\n" > + " mov %0, #0\n" > + " teq %1, %3\n" > + " strexheq %0, %4, [%2]\n" > + : "=&r" (res), "=&r" (oldval) > + : "r" (ptr), "Ir" (old), "r" (new) > + : "memory", "cc"); > + } while (res); > + break; > + case 4: > + do { > + asm volatile("@ __cmpxchg4\n" > + " ldrex %1, [%2]\n" > + " mov %0, #0\n" > + " teq %1, %3\n" > + " strexeq %0, %4, [%2]\n" > + : "=&r" (res), "=&r" (oldval) > + : "r" (ptr), "Ir" (old), "r" (new) > + : "memory", "cc"); > + } while (res); > + break; > +#if 0 > + case 8: > + do { > + asm volatile("@ __cmpxchg8\n" > + " ldrexd %1, [%2]\n" > + " mov %0, #0\n" > + " teq %1, %3\n" > + " strexdeq %0, %4, [%2]\n" > + : "=&r" (res), "=&r" (oldval) > + : "r" (ptr), "Ir" (old), "r" (new) > + : "memory", "cc"); > + } while (res); > + break; > +#endif Is it really useful to let the dead code in the header? Regards, -- Julien Grall