diff options
Diffstat (limited to 'include/asm-generic/atomic-long.h')
-rw-r--r-- | include/asm-generic/atomic-long.h | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h index a94cbebbc33d..eb1973bad80b 100644 --- a/include/asm-generic/atomic-long.h +++ b/include/asm-generic/atomic-long.h | |||
@@ -35,7 +35,7 @@ typedef atomic_t atomic_long_t; | |||
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #define ATOMIC_LONG_READ_OP(mo) \ | 37 | #define ATOMIC_LONG_READ_OP(mo) \ |
38 | static inline long atomic_long_read##mo(atomic_long_t *l) \ | 38 | static inline long atomic_long_read##mo(const atomic_long_t *l) \ |
39 | { \ | 39 | { \ |
40 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ | 40 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ |
41 | \ | 41 | \ |
@@ -112,19 +112,23 @@ static inline void atomic_long_dec(atomic_long_t *l) | |||
112 | ATOMIC_LONG_PFX(_dec)(v); | 112 | ATOMIC_LONG_PFX(_dec)(v); |
113 | } | 113 | } |
114 | 114 | ||
115 | static inline void atomic_long_add(long i, atomic_long_t *l) | 115 | #define ATOMIC_LONG_OP(op) \ |
116 | { | 116 | static inline void \ |
117 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 117 | atomic_long_##op(long i, atomic_long_t *l) \ |
118 | 118 | { \ | |
119 | ATOMIC_LONG_PFX(_add)(i, v); | 119 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ |
120 | \ | ||
121 | ATOMIC_LONG_PFX(_##op)(i, v); \ | ||
120 | } | 122 | } |
121 | 123 | ||
122 | static inline void atomic_long_sub(long i, atomic_long_t *l) | 124 | ATOMIC_LONG_OP(add) |
123 | { | 125 | ATOMIC_LONG_OP(sub) |
124 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 126 | ATOMIC_LONG_OP(and) |
127 | ATOMIC_LONG_OP(or) | ||
128 | ATOMIC_LONG_OP(xor) | ||
129 | ATOMIC_LONG_OP(andnot) | ||
125 | 130 | ||
126 | ATOMIC_LONG_PFX(_sub)(i, v); | 131 | #undef ATOMIC_LONG_OP |
127 | } | ||
128 | 132 | ||
129 | static inline int atomic_long_sub_and_test(long i, atomic_long_t *l) | 133 | static inline int atomic_long_sub_and_test(long i, atomic_long_t *l) |
130 | { | 134 | { |
@@ -154,19 +158,24 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l) | |||
154 | return ATOMIC_LONG_PFX(_add_negative)(i, v); | 158 | return ATOMIC_LONG_PFX(_add_negative)(i, v); |
155 | } | 159 | } |
156 | 160 | ||
157 | static inline long atomic_long_inc_return(atomic_long_t *l) | 161 | #define ATOMIC_LONG_INC_DEC_OP(op, mo) \ |
158 | { | 162 | static inline long \ |
159 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 163 | atomic_long_##op##_return##mo(atomic_long_t *l) \ |
160 | 164 | { \ | |
161 | return (long)ATOMIC_LONG_PFX(_inc_return)(v); | 165 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ |
162 | } | 166 | \ |
163 | 167 | return (long)ATOMIC_LONG_PFX(_##op##_return##mo)(v); \ | |
164 | static inline long atomic_long_dec_return(atomic_long_t *l) | ||
165 | { | ||
166 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | ||
167 | |||
168 | return (long)ATOMIC_LONG_PFX(_dec_return)(v); | ||
169 | } | 168 | } |
169 | ATOMIC_LONG_INC_DEC_OP(inc,) | ||
170 | ATOMIC_LONG_INC_DEC_OP(inc, _relaxed) | ||
171 | ATOMIC_LONG_INC_DEC_OP(inc, _acquire) | ||
172 | ATOMIC_LONG_INC_DEC_OP(inc, _release) | ||
173 | ATOMIC_LONG_INC_DEC_OP(dec,) | ||
174 | ATOMIC_LONG_INC_DEC_OP(dec, _relaxed) | ||
175 | ATOMIC_LONG_INC_DEC_OP(dec, _acquire) | ||
176 | ATOMIC_LONG_INC_DEC_OP(dec, _release) | ||
177 | |||
178 | #undef ATOMIC_LONG_INC_DEC_OP | ||
170 | 179 | ||
171 | static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u) | 180 | static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u) |
172 | { | 181 | { |