diff options
author | Peter Zijlstra <peterz@infradead.org> | 2014-04-23 10:12:30 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-08-14 06:48:14 -0400 |
commit | 560cb12a4080a48b84da8b96878cafbd193c4d64 (patch) | |
tree | e0b28be89d66e8a01b164b7c6123e918cafcc79c /include/asm-generic/atomic64.h | |
parent | d4608dd5b4ec13855680b89f719d8d4b2da92411 (diff) |
locking,arch: Rewrite generic atomic support
Rewrite generic atomic support to only require cmpxchg(), generate all
other primitives from that.
Furthermore reduce the endless repetition for all these primitives to
a few CPP macros. This way we get more for less lines.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140508135852.940119622@infradead.org
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David Howells <dhowells@redhat.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/asm-generic/atomic64.h')
-rw-r--r-- | include/asm-generic/atomic64.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h index b18ce4f9ee3d..30ad9c86cebb 100644 --- a/include/asm-generic/atomic64.h +++ b/include/asm-generic/atomic64.h | |||
@@ -20,10 +20,22 @@ typedef struct { | |||
20 | 20 | ||
21 | extern long long atomic64_read(const atomic64_t *v); | 21 | extern long long atomic64_read(const atomic64_t *v); |
22 | extern void atomic64_set(atomic64_t *v, long long i); | 22 | extern void atomic64_set(atomic64_t *v, long long i); |
23 | extern void atomic64_add(long long a, atomic64_t *v); | 23 | |
24 | extern long long atomic64_add_return(long long a, atomic64_t *v); | 24 | #define ATOMIC64_OP(op) \ |
25 | extern void atomic64_sub(long long a, atomic64_t *v); | 25 | extern void atomic64_##op(long long a, atomic64_t *v); |
26 | extern long long atomic64_sub_return(long long a, atomic64_t *v); | 26 | |
27 | #define ATOMIC64_OP_RETURN(op) \ | ||
28 | extern long long atomic64_##op##_return(long long a, atomic64_t *v); | ||
29 | |||
30 | #define ATOMIC64_OPS(op) ATOMIC64_OP(op) ATOMIC64_OP_RETURN(op) | ||
31 | |||
32 | ATOMIC64_OPS(add) | ||
33 | ATOMIC64_OPS(sub) | ||
34 | |||
35 | #undef ATOMIC64_OPS | ||
36 | #undef ATOMIC64_OP_RETURN | ||
37 | #undef ATOMIC64_OP | ||
38 | |||
27 | extern long long atomic64_dec_if_positive(atomic64_t *v); | 39 | extern long long atomic64_dec_if_positive(atomic64_t *v); |
28 | extern long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n); | 40 | extern long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n); |
29 | extern long long atomic64_xchg(atomic64_t *v, long long new); | 41 | extern long long atomic64_xchg(atomic64_t *v, long long new); |