diff options
author | Nick Piggin <nickpiggin@yahoo.com.au> | 2005-11-13 19:07:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-13 21:14:16 -0500 |
commit | 8426e1f6af0fd7f44d040af7263750c5a52f3cc3 (patch) | |
tree | 827bd2588c2b73d11cea6869de8ff42dba134375 /include/asm-sparc/atomic.h | |
parent | 4a6dae6d382e9edf3ff440b819e554ed706359bc (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-sparc/atomic.h')
-rw-r--r-- | include/asm-sparc/atomic.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/asm-sparc/atomic.h b/include/asm-sparc/atomic.h index 52bdd1a895fa..62bec7ad271c 100644 --- a/include/asm-sparc/atomic.h +++ b/include/asm-sparc/atomic.h | |||
@@ -20,6 +20,7 @@ typedef struct { volatile int counter; } atomic_t; | |||
20 | 20 | ||
21 | extern int __atomic_add_return(int, atomic_t *); | 21 | extern int __atomic_add_return(int, atomic_t *); |
22 | extern int atomic_cmpxchg(atomic_t *, int, int); | 22 | extern int atomic_cmpxchg(atomic_t *, int, int); |
23 | extern int atomic_add_unless(atomic_t *, int, int); | ||
23 | extern void atomic_set(atomic_t *, int); | 24 | extern void atomic_set(atomic_t *, int); |
24 | 25 | ||
25 | #define atomic_read(v) ((v)->counter) | 26 | #define atomic_read(v) ((v)->counter) |
@@ -49,6 +50,8 @@ extern void atomic_set(atomic_t *, int); | |||
49 | #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) | 50 | #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) |
50 | #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0) | 51 | #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0) |
51 | 52 | ||
53 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | ||
54 | |||
52 | /* This is the old 24-bit implementation. It's still used internally | 55 | /* This is the old 24-bit implementation. It's still used internally |
53 | * by some sparc-specific code, notably the semaphore implementation. | 56 | * by some sparc-specific code, notably the semaphore implementation. |
54 | */ | 57 | */ |