diff options
author | Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | 2007-05-08 03:34:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:19 -0400 |
commit | bb2382c3e4395ab595278cc7b92ac3f2eaf23f66 (patch) | |
tree | 9a162bcdff0bc8a19b1ca26ac954a27b0178fb2c /include/asm-generic | |
parent | e96e69942312314c061eb2fdd947a7a1211d62f8 (diff) |
atomic.h: complete atomic_long operations in asm-generic
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/atomic.h | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h index b7e4a0467cb1..5ae6dce1cba2 100644 --- a/include/asm-generic/atomic.h +++ b/include/asm-generic/atomic.h | |||
@@ -9,6 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <asm/types.h> | 11 | #include <asm/types.h> |
12 | #include <asm/system.h> | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * Suppport for atomic_long_t | 15 | * Suppport for atomic_long_t |
@@ -66,6 +67,72 @@ static inline void atomic_long_sub(long i, atomic_long_t *l) | |||
66 | atomic64_sub(i, v); | 67 | atomic64_sub(i, v); |
67 | } | 68 | } |
68 | 69 | ||
70 | static inline int atomic_long_sub_and_test(long i, atomic_long_t *l) | ||
71 | { | ||
72 | atomic64_t *v = (atomic64_t *)l; | ||
73 | |||
74 | return atomic64_sub_and_test(i, v); | ||
75 | } | ||
76 | |||
77 | static inline int atomic_long_dec_and_test(atomic_long_t *l) | ||
78 | { | ||
79 | atomic64_t *v = (atomic64_t *)l; | ||
80 | |||
81 | return atomic64_dec_and_test(v); | ||
82 | } | ||
83 | |||
84 | static inline int atomic_long_inc_and_test(atomic_long_t *l) | ||
85 | { | ||
86 | atomic64_t *v = (atomic64_t *)l; | ||
87 | |||
88 | return atomic64_inc_and_test(v); | ||
89 | } | ||
90 | |||
91 | static inline int atomic_long_add_negative(long i, atomic_long_t *l) | ||
92 | { | ||
93 | atomic64_t *v = (atomic64_t *)l; | ||
94 | |||
95 | return atomic64_add_negative(i, v); | ||
96 | } | ||
97 | |||
98 | static inline long atomic_long_add_return(long i, atomic_long_t *l) | ||
99 | { | ||
100 | atomic64_t *v = (atomic64_t *)l; | ||
101 | |||
102 | return (long)atomic64_add_return(i, v); | ||
103 | } | ||
104 | |||
105 | static inline long atomic_long_sub_return(long i, atomic_long_t *l) | ||
106 | { | ||
107 | atomic64_t *v = (atomic64_t *)l; | ||
108 | |||
109 | return (long)atomic64_sub_return(i, v); | ||
110 | } | ||
111 | |||
112 | static inline long atomic_long_inc_return(atomic_long_t *l) | ||
113 | { | ||
114 | atomic64_t *v = (atomic64_t *)l; | ||
115 | |||
116 | return (long)atomic64_inc_return(v); | ||
117 | } | ||
118 | |||
119 | static inline long atomic_long_dec_return(atomic_long_t *l) | ||
120 | { | ||
121 | atomic64_t *v = (atomic64_t *)l; | ||
122 | |||
123 | return (long)atomic64_dec_return(v); | ||
124 | } | ||
125 | |||
126 | #define atomic_long_add_unless(l, a, u) \ | ||
127 | atomic64_add_unless((atomic64_t *)(l), (a), (u)) | ||
128 | |||
129 | #define atomic_long_inc_not_zero(l) atomic64_inc_not_zero((atomic64_t *)(l)) | ||
130 | |||
131 | #define atomic_long_cmpxchg(l, old, new) \ | ||
132 | (atomic_cmpxchg((atomic64_t *)(l), (old), (new))) | ||
133 | #define atomic_long_xchg(v, new) \ | ||
134 | (atomic_xchg((atomic64_t *)(l), (new))) | ||
135 | |||
69 | #else /* BITS_PER_LONG == 64 */ | 136 | #else /* BITS_PER_LONG == 64 */ |
70 | 137 | ||
71 | typedef atomic_t atomic_long_t; | 138 | typedef atomic_t atomic_long_t; |
@@ -113,6 +180,72 @@ static inline void atomic_long_sub(long i, atomic_long_t *l) | |||
113 | atomic_sub(i, v); | 180 | atomic_sub(i, v); |
114 | } | 181 | } |
115 | 182 | ||
183 | static inline int atomic_long_sub_and_test(long i, atomic_long_t *l) | ||
184 | { | ||
185 | atomic_t *v = (atomic_t *)l; | ||
186 | |||
187 | return atomic_sub_and_test(i, v); | ||
188 | } | ||
189 | |||
190 | static inline int atomic_long_dec_and_test(atomic_long_t *l) | ||
191 | { | ||
192 | atomic_t *v = (atomic_t *)l; | ||
193 | |||
194 | return atomic_dec_and_test(v); | ||
195 | } | ||
196 | |||
197 | static inline int atomic_long_inc_and_test(atomic_long_t *l) | ||
198 | { | ||
199 | atomic_t *v = (atomic_t *)l; | ||
200 | |||
201 | return atomic_inc_and_test(v); | ||
202 | } | ||
203 | |||
204 | static inline int atomic_long_add_negative(long i, atomic_long_t *l) | ||
205 | { | ||
206 | atomic_t *v = (atomic_t *)l; | ||
207 | |||
208 | return atomic_add_negative(i, v); | ||
209 | } | ||
210 | |||
211 | static inline long atomic_long_add_return(long i, atomic_long_t *l) | ||
212 | { | ||
213 | atomic_t *v = (atomic_t *)l; | ||
214 | |||
215 | return (long)atomic_add_return(i, v); | ||
216 | } | ||
217 | |||
218 | static inline long atomic_long_sub_return(long i, atomic_long_t *l) | ||
219 | { | ||
220 | atomic_t *v = (atomic_t *)l; | ||
221 | |||
222 | return (long)atomic_sub_return(i, v); | ||
223 | } | ||
224 | |||
225 | static inline long atomic_long_inc_return(atomic_long_t *l) | ||
226 | { | ||
227 | atomic_t *v = (atomic_t *)l; | ||
228 | |||
229 | return (long)atomic_inc_return(v); | ||
230 | } | ||
231 | |||
232 | static inline long atomic_long_dec_return(atomic_long_t *l) | ||
233 | { | ||
234 | atomic_t *v = (atomic_t *)l; | ||
235 | |||
236 | return (long)atomic_dec_return(v); | ||
237 | } | ||
238 | |||
239 | #define atomic_long_add_unless(l, a, u) \ | ||
240 | atomic_add_unless((atomic_t *)(l), (a), (u)) | ||
241 | |||
242 | #define atomic_long_inc_not_zero(l) atomic_inc_not_zero((atomic_t *)(l)) | ||
243 | |||
244 | #define atomic_long_cmpxchg(l, old, new) \ | ||
245 | (atomic_cmpxchg((atomic_t *)(l), (old), (new))) | ||
246 | #define atomic_long_xchg(v, new) \ | ||
247 | (atomic_xchg((atomic_t *)(l), (new))) | ||
248 | |||
116 | #endif /* BITS_PER_LONG == 64 */ | 249 | #endif /* BITS_PER_LONG == 64 */ |
117 | 250 | ||
118 | #endif /* _ASM_GENERIC_ATOMIC_H */ | 251 | #endif /* _ASM_GENERIC_ATOMIC_H */ |