aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-parisc
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-parisc')
-rw-r--r--include/asm-parisc/atomic.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/include/asm-parisc/atomic.h b/include/asm-parisc/atomic.h
index 7d57d34fcca8..66a0edbb51f4 100644
--- a/include/asm-parisc/atomic.h
+++ b/include/asm-parisc/atomic.h
@@ -6,7 +6,6 @@
6#define _ASM_PARISC_ATOMIC_H_ 6#define _ASM_PARISC_ATOMIC_H_
7 7
8#include <linux/types.h> 8#include <linux/types.h>
9#include <asm/system.h>
10 9
11/* 10/*
12 * Atomic operations that C can't guarantee us. Useful for 11 * Atomic operations that C can't guarantee us. Useful for
@@ -163,7 +162,7 @@ static __inline__ int atomic_read(const atomic_t *v)
163} 162}
164 163
165/* exported interface */ 164/* exported interface */
166#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) 165#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
167#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 166#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
168 167
169/** 168/**
@@ -177,7 +176,7 @@ static __inline__ int atomic_read(const atomic_t *v)
177 */ 176 */
178#define atomic_add_unless(v, a, u) \ 177#define atomic_add_unless(v, a, u) \
179({ \ 178({ \
180 int c, old; \ 179 __typeof__((v)->counter) c, old; \
181 c = atomic_read(v); \ 180 c = atomic_read(v); \
182 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ 181 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
183 c = old; \ 182 c = old; \
@@ -270,6 +269,30 @@ atomic64_read(const atomic64_t *v)
270#define atomic64_dec_and_test(v) (atomic64_dec_return(v) == 0) 269#define atomic64_dec_and_test(v) (atomic64_dec_return(v) == 0)
271#define atomic64_sub_and_test(i,v) (atomic64_sub_return((i),(v)) == 0) 270#define atomic64_sub_and_test(i,v) (atomic64_sub_return((i),(v)) == 0)
272 271
272/* exported interface */
273#define atomic64_cmpxchg(v, o, n) \
274 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
275#define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
276
277/**
278 * atomic64_add_unless - add unless the number is a given value
279 * @v: pointer of type atomic64_t
280 * @a: the amount to add to v...
281 * @u: ...unless v is equal to u.
282 *
283 * Atomically adds @a to @v, so long as it was not @u.
284 * Returns non-zero if @v was not @u, and zero otherwise.
285 */
286#define atomic64_add_unless(v, a, u) \
287({ \
288 __typeof__((v)->counter) c, old; \
289 c = atomic64_read(v); \
290 while (c != (u) && (old = atomic64_cmpxchg((v), c, c + (a))) != c) \
291 c = old; \
292 c != (u); \
293})
294#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
295
273#endif /* CONFIG_64BIT */ 296#endif /* CONFIG_64BIT */
274 297
275#include <asm-generic/atomic.h> 298#include <asm-generic/atomic.h>