diff options
Diffstat (limited to 'include/asm-sparc64/atomic.h')
-rw-r--r-- | include/asm-sparc64/atomic.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h index e175afcf2cde..3789fe315992 100644 --- a/include/asm-sparc64/atomic.h +++ b/include/asm-sparc64/atomic.h | |||
@@ -54,6 +54,7 @@ extern int atomic64_sub_ret(int, atomic64_t *); | |||
54 | * other cases. | 54 | * other cases. |
55 | */ | 55 | */ |
56 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) | 56 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) |
57 | #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0) | ||
57 | 58 | ||
58 | #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0) | 59 | #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0) |
59 | #define atomic64_sub_and_test(i, v) (atomic64_sub_ret(i, v) == 0) | 60 | #define atomic64_sub_and_test(i, v) (atomic64_sub_ret(i, v) == 0) |
@@ -70,6 +71,18 @@ extern int atomic64_sub_ret(int, atomic64_t *); | |||
70 | #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0) | 71 | #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0) |
71 | #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0) | 72 | #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0) |
72 | 73 | ||
74 | #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) | ||
75 | |||
76 | #define atomic_add_unless(v, a, u) \ | ||
77 | ({ \ | ||
78 | int c, old; \ | ||
79 | c = atomic_read(v); \ | ||
80 | while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ | ||
81 | c = old; \ | ||
82 | c != (u); \ | ||
83 | }) | ||
84 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | ||
85 | |||
73 | /* Atomic operations are already serializing */ | 86 | /* Atomic operations are already serializing */ |
74 | #ifdef CONFIG_SMP | 87 | #ifdef CONFIG_SMP |
75 | #define smp_mb__before_atomic_dec() membar_storeload_loadload(); | 88 | #define smp_mb__before_atomic_dec() membar_storeload_loadload(); |