Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: compudj@krystal.dyndns.org (Mathieu Desnoyers)
Subject: [ltt-dev] [PATCH] uatomic: use generic-size macros for common	implementation of atomic ops
Date: Thu, 9 Jun 2011 10:12:19 -0400	[thread overview]
Message-ID: <BLU0-SMTP683201DEF3F51A0C7F6DC696650@phx.gbl> (raw)
In-Reply-To: <1307627865-31969-1-git-send-email-pbonzini@redhat.com>

* Paolo Bonzini (pbonzini at redhat.com) wrote:
> The definition of _uatomic_cmpxchg is different in x86 and other architectures.
> For x86 it is a 4-argument macro, for other architectures it is a 3-argument
> function.  This patch makes it easier to implement atomic operations
> incrementally (first as a generic version and then in machine-specific code),
> which aids testing and bisectability.

Merged, thanks!

Mathieu

> 
> Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
> ---
> 	Examples will come once I'll be back from my holidays. :P
> 
>  urcu/uatomic_generic.h |   24 ++++++++++++++++--------
>  1 files changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/urcu/uatomic_generic.h b/urcu/uatomic_generic.h
> index cef58f3..337fe40 100644
> --- a/urcu/uatomic_generic.h
> +++ b/urcu/uatomic_generic.h
> @@ -395,7 +395,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
>  		oldt = uatomic_read((unsigned char *)addr);
>  		do {
>  			old = oldt;
> -			oldt = _uatomic_cmpxchg(addr, old, old + val, 1);
> +			oldt = uatomic_cmpxchg((unsigned char *)addr,
> +                                               old, old + val);
>  		} while (oldt != old);
>  
>  		return old + val;
> @@ -409,7 +410,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
>  		oldt = uatomic_read((unsigned short *)addr);
>  		do {
>  			old = oldt;
> -			oldt = _uatomic_cmpxchg(addr, old, old + val, 2);
> +			oldt = uatomic_cmpxchg((unsigned short *)addr,
> +                                               old, old + val);
>  		} while (oldt != old);
>  
>  		return old + val;
> @@ -422,7 +424,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
>  		oldt = uatomic_read((unsigned int *)addr);
>  		do {
>  			old = oldt;
> -			oldt = _uatomic_cmpxchg(addr, old, old + val, 4);
> +			oldt = uatomic_cmpxchg((unsigned int *)addr,
> +                                               old, old + val);
>  		} while (oldt != old);
>  
>  		return old + val;
> @@ -435,7 +438,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
>  		oldt = uatomic_read((unsigned long *)addr);
>  		do {
>  			old = oldt;
> -			oldt = _uatomic_cmpxchg(addr, old, old + val, 8);
> +			oldt = uatomic_cmpxchg((unsigned long *)addr,
> +                                               old, old + val);
>  		} while (oldt != old);
>  
>  		return old + val;
> @@ -467,7 +471,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
>  		oldt = uatomic_read((unsigned char *)addr);
>  		do {
>  			old = oldt;
> -			oldt = _uatomic_cmpxchg(addr, old, val, 1);
> +			oldt = uatomic_cmpxchg((unsigned char *)addr,
> +                                               old, val);
>  		} while (oldt != old);
>  
>  		return old;
> @@ -481,7 +486,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
>  		oldt = uatomic_read((unsigned short *)addr);
>  		do {
>  			old = oldt;
> -			oldt = _uatomic_cmpxchg(addr, old, val, 2);
> +			oldt = uatomic_cmpxchg((unsigned short *)addr,
> +                                               old, val);
>  		} while (oldt != old);
>  
>  		return old;
> @@ -494,7 +500,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
>  		oldt = uatomic_read((unsigned int *)addr);
>  		do {
>  			old = oldt;
> -			oldt = _uatomic_cmpxchg(addr, old, val, 4);
> +			oldt = uatomic_cmpxchg((unsigned int *)addr,
> +                                               old, val);
>  		} while (oldt != old);
>  
>  		return old;
> @@ -507,7 +514,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
>  		oldt = uatomic_read((unsigned long *)addr);
>  		do {
>  			old = oldt;
> -			oldt = _uatomic_cmpxchg(addr, old, val, 8);
> +			oldt = uatomic_cmpxchg((unsigned long *)addr,
> +                                               old, val);
>  		} while (oldt != old);
>  
>  		return old;
> -- 
> 1.7.4.4
> 
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




      reply	other threads:[~2011-06-09 14:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-09 13:57 Paolo Bonzini
2011-06-09 14:12 ` Mathieu Desnoyers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BLU0-SMTP683201DEF3F51A0C7F6DC696650@phx.gbl \
    --to=compudj@krystal.dyndns.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox