Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

locking, asm-generic: Add _{relaxed|acquire|release}() variants for 'atomic_long_t'

This patch adds 'atomic_long_t' wrappers for the new relaxed atomic operations.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Waiman.Long@hp.com
Cc: paulmck@linux.vnet.ibm.com
Link: http://lkml.kernel.org/r/1438880084-18856-4-git-send-email-will.deacon@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Will Deacon and committed by
Ingo Molnar
6d79ef2d 586b610e

+59 -27
+59 -27
include/asm-generic/atomic-long.h
··· 34 34 35 35 #endif 36 36 37 - static inline long atomic_long_read(atomic_long_t *l) 38 - { 39 - ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; 40 - 41 - return (long)ATOMIC_LONG_PFX(_read)(v); 37 + #define ATOMIC_LONG_READ_OP(mo) \ 38 + static inline long atomic_long_read##mo(atomic_long_t *l) \ 39 + { \ 40 + ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ 41 + \ 42 + return (long)ATOMIC_LONG_PFX(_read##mo)(v); \ 42 43 } 44 + ATOMIC_LONG_READ_OP() 45 + ATOMIC_LONG_READ_OP(_acquire) 43 46 44 - static inline void atomic_long_set(atomic_long_t *l, long i) 45 - { 46 - ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; 47 + #undef ATOMIC_LONG_READ_OP 47 48 48 - ATOMIC_LONG_PFX(_set)(v, i); 49 + #define ATOMIC_LONG_SET_OP(mo) \ 50 + static inline void atomic_long_set##mo(atomic_long_t *l, long i) \ 51 + { \ 52 + ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ 53 + \ 54 + ATOMIC_LONG_PFX(_set##mo)(v, i); \ 49 55 } 56 + ATOMIC_LONG_SET_OP() 57 + ATOMIC_LONG_SET_OP(_release) 58 + 59 + #undef ATOMIC_LONG_SET_OP 60 + 61 + #define ATOMIC_LONG_ADD_SUB_OP(op, mo) \ 62 + static inline long \ 63 + atomic_long_##op##_return##mo(long i, atomic_long_t *l) \ 64 + { \ 65 + ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ 66 + \ 67 + return (long)ATOMIC_LONG_PFX(_##op##_return##mo)(i, v); \ 68 + } 69 + ATOMIC_LONG_ADD_SUB_OP(add,) 70 + ATOMIC_LONG_ADD_SUB_OP(add, _relaxed) 71 + ATOMIC_LONG_ADD_SUB_OP(add, _acquire) 72 + ATOMIC_LONG_ADD_SUB_OP(add, _release) 73 + ATOMIC_LONG_ADD_SUB_OP(sub,) 74 + ATOMIC_LONG_ADD_SUB_OP(sub, _relaxed) 75 + ATOMIC_LONG_ADD_SUB_OP(sub, _acquire) 76 + ATOMIC_LONG_ADD_SUB_OP(sub, _release) 77 + 78 + #undef ATOMIC_LONG_ADD_SUB_OP 79 + 80 + #define atomic_long_cmpxchg_relaxed(l, old, new) \ 81 + (ATOMIC_LONG_PFX(_cmpxchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(l), \ 82 + (old), (new))) 83 + #define atomic_long_cmpxchg_acquire(l, old, new) \ 84 + (ATOMIC_LONG_PFX(_cmpxchg_acquire)((ATOMIC_LONG_PFX(_t) *)(l), \ 85 + (old), (new))) 86 + #define atomic_long_cmpxchg_release(l, old, new) \ 87 + (ATOMIC_LONG_PFX(_cmpxchg_release)((ATOMIC_LONG_PFX(_t) *)(l), \ 88 + (old), (new))) 89 + #define atomic_long_cmpxchg(l, old, new) \ 90 + (ATOMIC_LONG_PFX(_cmpxchg)((ATOMIC_LONG_PFX(_t) *)(l), (old), (new))) 91 + 92 + #define atomic_long_xchg_relaxed(v, new) \ 93 + (ATOMIC_LONG_PFX(_xchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(v), (new))) 94 + #define atomic_long_xchg_acquire(v, new) \ 95 + (ATOMIC_LONG_PFX(_xchg_acquire)((ATOMIC_LONG_PFX(_t) *)(v), (new))) 96 + #define atomic_long_xchg_release(v, new) \ 97 + (ATOMIC_LONG_PFX(_xchg_release)((ATOMIC_LONG_PFX(_t) *)(v), (new))) 98 + #define atomic_long_xchg(v, new) \ 99 + (ATOMIC_LONG_PFX(_xchg)((ATOMIC_LONG_PFX(_t) *)(v), (new))) 50 100 51 101 static inline void atomic_long_inc(atomic_long_t *l) 52 102 { ··· 154 104 return ATOMIC_LONG_PFX(_add_negative)(i, v); 155 105 } 156 106 157 - static inline long atomic_long_add_return(long i, atomic_long_t *l) 158 - { 159 - ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; 160 - 161 - return (long)ATOMIC_LONG_PFX(_add_return)(i, v); 162 - } 163 - 164 - static inline long atomic_long_sub_return(long i, atomic_long_t *l) 165 - { 166 - ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; 167 - 168 - return (long)ATOMIC_LONG_PFX(_sub_return)(i, v); 169 - } 170 - 171 107 static inline long atomic_long_inc_return(atomic_long_t *l) 172 108 { 173 109 ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; ··· 177 141 178 142 #define atomic_long_inc_not_zero(l) \ 179 143 ATOMIC_LONG_PFX(_inc_not_zero)((ATOMIC_LONG_PFX(_t) *)(l)) 180 - #define atomic_long_cmpxchg(l, old, new) \ 181 - (ATOMIC_LONG_PFX(_cmpxchg)((ATOMIC_LONG_PFX(_t) *)(l), (old), (new))) 182 - #define atomic_long_xchg(v, new) \ 183 - (ATOMIC_LONG_PFX(_xchg)((ATOMIC_LONG_PFX(_t) *)(v), (new))) 184 144 185 145 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */