From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCHv4 2/5] arm: provide add_sized() Date: Mon, 11 May 2015 15:45:23 +0100 Message-ID: <5550C083.2080106@citrix.com> References: <1431355025-20468-1-git-send-email-david.vrabel@citrix.com> <1431355025-20468-3-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.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YroxV-0007qo-6d for xen-devel@lists.xenproject.org; Mon, 11 May 2015 14:45:29 +0000 In-Reply-To: <1431355025-20468-3-git-send-email-david.vrabel@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: David Vrabel , xen-devel@lists.xenproject.org Cc: Keir Fraser , Ian Campbell , Andrew Cooper , Jennifer Herbert , Tim Deegan , Jan Beulich List-Id: xen-devel@lists.xenproject.org On 11/05/15 15:37, David Vrabel wrote: > add_sized(ptr, inc) adds inc to the value at ptr using only the correct > size of loads and stores for the type of *ptr. The add is /not/ atomic. > > This is needed for ticket locks to ensure the increment of the head ticket > does not affect the tail ticket. [...] > > +#define add_sized(p, x) ({ \ > + typeof(*p) __x = (x); \ > + switch ( sizeof(*p) ) \ > + { \ > + case 1: add_u8_sized((uint8_t *)p, (uint8_t)__x); break; \ > + case 2: add_u16_sized((uint16_t *)p, (uint16_t)__x); break; \ > + case 4: add_u32_sized((uint32_t *)p, (uint32_t)__x); break; \ > + default: __bad_atomic_size(); break; \ > + } \ > + __x; \ I should have cleaned up this arm implementation in the same way I did x86. Please drop this "__x;" before committing, or I can resubmit if it is preferred. Sorry. David