From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30836 invoked by alias); 25 Jan 2007 16:26:18 -0000 Received: (qmail 30827 invoked by uid 22791); 25 Jan 2007 16:26:17 -0000 X-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,FORGED_RCVD_HELO X-Spam-Check-By: sourceware.org Received: from tomts40.bellnexxia.net (HELO tomts40-srv.bellnexxia.net) (209.226.175.97) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 25 Jan 2007 16:26:11 +0000 Received: from krystal.dyndns.org ([67.68.204.133]) by tomts40-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070125162609.TDWF1750.tomts40-srv.bellnexxia.net@krystal.dyndns.org> for ; Thu, 25 Jan 2007 11:26:09 -0500 Received: from localhost (localhost [127.0.0.1]) (uid 1000) by krystal.dyndns.org with local; Thu, 25 Jan 2007 11:15:56 -0500 id 001832D2.45B8D7BC.00003554 From: Mathieu Desnoyers To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Andrew Morton , Ingo Molnar , Greg Kroah-Hartman , Christoph Hellwig , ltt-dev@shafik.org, systemtap@sources.redhat.com, Douglas Niehaus , "Martin J. Bligh" , Thomas Gleixner , Paul Mackerras , Mathieu Desnoyers Subject: [PATCH 06/09] atomic.h : Add atomic64 cmpxchg, xchg and add_unless to parisc Date: Thu, 25 Jan 2007 16:26:00 -0000 Message-Id: <1169741756818-git-send-email-mathieu.desnoyers@polymtl.ca> X-Mailer: git-send-email 1.4.4.3 In-Reply-To: <11697417541743-git-send-email-mathieu.desnoyers@polymtl.ca> References: <11697417541743-git-send-email-mathieu.desnoyers@polymtl.ca> X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2007-q1/txt/msg00205.txt.bz2 atomic.h : Add atomic64 cmpxchg, xchg and add_unless to parisc Signed-off-by: Mathieu Desnoyers --- a/include/asm-parisc/atomic.h +++ b/include/asm-parisc/atomic.h @@ -163,7 +163,8 @@ static __inline__ int atomic_read(const atomic_t *v) } /* exported interface */ -#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_cmpxchg(v, o, n) \ + ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n))) #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) /** @@ -177,7 +178,7 @@ static __inline__ int atomic_read(const atomic_t *v) */ #define atomic_add_unless(v, a, u) \ ({ \ - int c, old; \ + __typeof__((v)->counter) c, old; \ c = atomic_read(v); \ while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ c = old; \ @@ -270,6 +271,31 @@ atomic64_read(const atomic64_t *v) #define atomic64_dec_and_test(v) (atomic64_dec_return(v) == 0) #define atomic64_sub_and_test(i,v) (atomic64_sub_return((i),(v)) == 0) +/* exported interface */ +#define atomic64_cmpxchg(v, o, n) \ + ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n))) +#define atomic64_xchg(v, new) (xchg(&((v)->counter), new)) + +/** + * atomic64_add_unless - add unless the number is a given value + * @v: pointer of type atomic64_t + * @a: the amount to add to v... + * @u: ...unless v is equal to u. + * + * Atomically adds @a to @v, so long as it was not @u. + * Returns non-zero if @v was not @u, and zero otherwise. + */ +#define atomic64_add_unless(v, a, u) \ +({ \ + __typeof__((v)->counter) c, old; \ + c = atomic64_read(v); \ + while (c != (u) && (old = atomic64_cmpxchg((v), c, c + (a))) != c) \ + c = old; \ + c != (u); \ +}) +#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) + + #endif /* __LP64__ */ #include