aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/atomic.h
diff options
context:
space:
mode:
authorNick Piggin <nickpiggin@yahoo.com.au>2005-11-13 19:07:25 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-13 21:14:16 -0500
commit8426e1f6af0fd7f44d040af7263750c5a52f3cc3 (patch)
tree827bd2588c2b73d11cea6869de8ff42dba134375 /include/asm-mips/atomic.h
parent4a6dae6d382e9edf3ff440b819e554ed706359bc (diff)
[PATCH] atomic: inc_not_zero
Introduce an atomic_inc_not_zero operation. Make this a special case of atomic_add_unless because lockless pagecache actually wants atomic_inc_not_negativeone due to its offset refcount. Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: "Paul E. McKenney" <paulmck@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-mips/atomic.h')
-rw-r--r--include/asm-mips/atomic.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/asm-mips/atomic.h b/include/asm-mips/atomic.h
index 4fba0d003c99..2c87b41e69ba 100644
--- a/include/asm-mips/atomic.h
+++ b/include/asm-mips/atomic.h
@@ -289,6 +289,25 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
289 289
290#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) 290#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
291 291
292/**
293 * atomic_add_unless - add unless the number is a given value
294 * @v: pointer of type atomic_t
295 * @a: the amount to add to v...
296 * @u: ...unless v is equal to u.
297 *
298 * Atomically adds @a to @v, so long as it was not @u.
299 * Returns non-zero if @v was not @u, and zero otherwise.
300 */
301#define atomic_add_unless(v, a, u) \
302({ \
303 int c, old; \
304 c = atomic_read(v); \
305 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
306 c = old; \
307 c != (u); \
308})
309#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
310
292#define atomic_dec_return(v) atomic_sub_return(1,(v)) 311#define atomic_dec_return(v) atomic_sub_return(1,(v))
293#define atomic_inc_return(v) atomic_add_return(1,(v)) 312#define atomic_inc_return(v) atomic_add_return(1,(v))
294 313