diff options
author | Mark Rutland <mark.rutland@arm.com> | 2018-09-04 06:48:27 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-11-01 06:00:55 -0400 |
commit | b5d47ef9ea5c5fe31d7eabeb79f697629bd9e2cb (patch) | |
tree | 4bd29d5a65797332263a9e47079e65cac101eafd | |
parent | 9fa45070a2e59a871e1cd3370173369f3a4f61e2 (diff) |
locking/atomics: Switch to generated atomic-long
As a step towards ensuring the atomic* APIs are consistent, let's switch
to wrappers generated by gen-atomic-long.h, using the same table that
gen-atomic-fallbacks.h uses to fill in gaps in the atomic_* and
atomic64_* APIs.
These are checked in rather than generated with Kbuild, since:
* This allows inspection of the atomics with git grep and ctags on a
pristine tree, which Linus strongly prefers being able to do.
* The fallbacks are not affected by machine details or configuration
options, so it is not necessary to regenerate them to take these into
account.
* These are included by files required *very* early in the build process
(e.g. for generating bounds.h), and we'd rather not complicate the
top-level Kbuild file with dependencies.
Other than *_INIT() and *_cond_read_acquire(), all API functions are
implemented as static inline C functions, ensuring consistent type
promotion and/or truncation without requiring explicit casts to be
applied to parameters or return values.
Since we typedef atomic_long_t to either atomic_t or atomic64_t, we know
these types are equivalent, and don't require explicit casts between
them. However, as the try_cmpxchg*() functions take a pointer for the
'old' parameter, which may be an int or s64, an explicit cast is
generated for this.
There should be no functional change as a result of this patch (i.e.
existing code should not be affected). However, this introduces a number
of functions into the atomic_long_* API, bringing it into line with the
atomic_* and atomic64_* APIs.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: catalin.marinas@arm.com
Cc: linuxdrivers@attotech.com
Cc: dvyukov@google.com
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: aryabinin@virtuozzo.com
Cc: glider@google.com
Link: http://lkml.kernel.org/r/20180904104830.2975-4-mark.rutland@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | include/asm-generic/atomic-long.h | 1173 |
1 files changed, 958 insertions, 215 deletions
diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h index 87d14476edc2..a833d385a70b 100644 --- a/include/asm-generic/atomic-long.h +++ b/include/asm-generic/atomic-long.h | |||
@@ -1,269 +1,1012 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | |||
3 | // Generated by scripts/atomic/gen-atomic-long.sh | ||
4 | // DO NOT MODIFY THIS FILE DIRECTLY | ||
5 | |||
2 | #ifndef _ASM_GENERIC_ATOMIC_LONG_H | 6 | #ifndef _ASM_GENERIC_ATOMIC_LONG_H |
3 | #define _ASM_GENERIC_ATOMIC_LONG_H | 7 | #define _ASM_GENERIC_ATOMIC_LONG_H |
4 | /* | ||
5 | * Copyright (C) 2005 Silicon Graphics, Inc. | ||
6 | * Christoph Lameter | ||
7 | * | ||
8 | * Allows to provide arch independent atomic definitions without the need to | ||
9 | * edit all arch specific atomic.h files. | ||
10 | */ | ||
11 | 8 | ||
12 | #include <asm/types.h> | 9 | #include <asm/types.h> |
13 | 10 | ||
14 | /* | 11 | #ifdef CONFIG_64BIT |
15 | * Suppport for atomic_long_t | 12 | typedef atomic64_t atomic_long_t; |
16 | * | 13 | #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i) |
17 | * Casts for parameters are avoided for existing atomic functions in order to | 14 | #define atomic_long_cond_read_acquire atomic64_cond_read_acquire |
18 | * avoid issues with cast-as-lval under gcc 4.x and other limitations that the | 15 | #define atomic_long_cond_read_relaxed atomic64_cond_read_relaxed |
19 | * macros of a platform may have. | 16 | #else |
20 | */ | 17 | typedef atomic_t atomic_long_t; |
18 | #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i) | ||
19 | #define atomic_long_cond_read_acquire atomic_cond_read_acquire | ||
20 | #define atomic_long_cond_read_relaxed atomic_cond_read_relaxed | ||
21 | #endif | ||
21 | 22 | ||
22 | #if BITS_PER_LONG == 64 | 23 | #ifdef CONFIG_64BIT |
23 | 24 | ||
24 | typedef atomic64_t atomic_long_t; | 25 | static inline long |
26 | atomic_long_read(const atomic_long_t *v) | ||
27 | { | ||
28 | return atomic64_read(v); | ||
29 | } | ||
25 | 30 | ||
26 | #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i) | 31 | static inline long |
27 | #define ATOMIC_LONG_PFX(x) atomic64 ## x | 32 | atomic_long_read_acquire(const atomic_long_t *v) |
28 | #define ATOMIC_LONG_TYPE s64 | 33 | { |
34 | return atomic64_read_acquire(v); | ||
35 | } | ||
29 | 36 | ||
30 | #else | 37 | static inline void |
38 | atomic_long_set(atomic_long_t *v, long i) | ||
39 | { | ||
40 | atomic64_set(v, i); | ||
41 | } | ||
31 | 42 | ||
32 | typedef atomic_t atomic_long_t; | 43 | static inline void |
44 | atomic_long_set_release(atomic_long_t *v, long i) | ||
45 | { | ||
46 | atomic64_set_release(v, i); | ||
47 | } | ||
33 | 48 | ||
34 | #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i) | 49 | static inline void |
35 | #define ATOMIC_LONG_PFX(x) atomic ## x | 50 | atomic_long_add(long i, atomic_long_t *v) |
36 | #define ATOMIC_LONG_TYPE int | 51 | { |
52 | atomic64_add(i, v); | ||
53 | } | ||
37 | 54 | ||
38 | #endif | 55 | static inline long |
56 | atomic_long_add_return(long i, atomic_long_t *v) | ||
57 | { | ||
58 | return atomic64_add_return(i, v); | ||
59 | } | ||
60 | |||
61 | static inline long | ||
62 | atomic_long_add_return_acquire(long i, atomic_long_t *v) | ||
63 | { | ||
64 | return atomic64_add_return_acquire(i, v); | ||
65 | } | ||
66 | |||
67 | static inline long | ||
68 | atomic_long_add_return_release(long i, atomic_long_t *v) | ||
69 | { | ||
70 | return atomic64_add_return_release(i, v); | ||
71 | } | ||
72 | |||
73 | static inline long | ||
74 | atomic_long_add_return_relaxed(long i, atomic_long_t *v) | ||
75 | { | ||
76 | return atomic64_add_return_relaxed(i, v); | ||
77 | } | ||
78 | |||
79 | static inline long | ||
80 | atomic_long_fetch_add(long i, atomic_long_t *v) | ||
81 | { | ||
82 | return atomic64_fetch_add(i, v); | ||
83 | } | ||
84 | |||
85 | static inline long | ||
86 | atomic_long_fetch_add_acquire(long i, atomic_long_t *v) | ||
87 | { | ||
88 | return atomic64_fetch_add_acquire(i, v); | ||
89 | } | ||
90 | |||
91 | static inline long | ||
92 | atomic_long_fetch_add_release(long i, atomic_long_t *v) | ||
93 | { | ||
94 | return atomic64_fetch_add_release(i, v); | ||
95 | } | ||
96 | |||
97 | static inline long | ||
98 | atomic_long_fetch_add_relaxed(long i, atomic_long_t *v) | ||
99 | { | ||
100 | return atomic64_fetch_add_relaxed(i, v); | ||
101 | } | ||
102 | |||
103 | static inline void | ||
104 | atomic_long_sub(long i, atomic_long_t *v) | ||
105 | { | ||
106 | atomic64_sub(i, v); | ||
107 | } | ||
108 | |||
109 | static inline long | ||
110 | atomic_long_sub_return(long i, atomic_long_t *v) | ||
111 | { | ||
112 | return atomic64_sub_return(i, v); | ||
113 | } | ||
114 | |||
115 | static inline long | ||
116 | atomic_long_sub_return_acquire(long i, atomic_long_t *v) | ||
117 | { | ||
118 | return atomic64_sub_return_acquire(i, v); | ||
119 | } | ||
120 | |||
121 | static inline long | ||
122 | atomic_long_sub_return_release(long i, atomic_long_t *v) | ||
123 | { | ||
124 | return atomic64_sub_return_release(i, v); | ||
125 | } | ||
126 | |||
127 | static inline long | ||
128 | atomic_long_sub_return_relaxed(long i, atomic_long_t *v) | ||
129 | { | ||
130 | return atomic64_sub_return_relaxed(i, v); | ||
131 | } | ||
132 | |||
133 | static inline long | ||
134 | atomic_long_fetch_sub(long i, atomic_long_t *v) | ||
135 | { | ||
136 | return atomic64_fetch_sub(i, v); | ||
137 | } | ||
138 | |||
139 | static inline long | ||
140 | atomic_long_fetch_sub_acquire(long i, atomic_long_t *v) | ||
141 | { | ||
142 | return atomic64_fetch_sub_acquire(i, v); | ||
143 | } | ||
144 | |||
145 | static inline long | ||
146 | atomic_long_fetch_sub_release(long i, atomic_long_t *v) | ||
147 | { | ||
148 | return atomic64_fetch_sub_release(i, v); | ||
149 | } | ||
150 | |||
151 | static inline long | ||
152 | atomic_long_fetch_sub_relaxed(long i, atomic_long_t *v) | ||
153 | { | ||
154 | return atomic64_fetch_sub_relaxed(i, v); | ||
155 | } | ||
156 | |||
157 | static inline void | ||
158 | atomic_long_inc(atomic_long_t *v) | ||
159 | { | ||
160 | atomic64_inc(v); | ||
161 | } | ||
162 | |||
163 | static inline long | ||
164 | atomic_long_inc_return(atomic_long_t *v) | ||
165 | { | ||
166 | return atomic64_inc_return(v); | ||
167 | } | ||
168 | |||
169 | static inline long | ||
170 | atomic_long_inc_return_acquire(atomic_long_t *v) | ||
171 | { | ||
172 | return atomic64_inc_return_acquire(v); | ||
173 | } | ||
174 | |||
175 | static inline long | ||
176 | atomic_long_inc_return_release(atomic_long_t *v) | ||
177 | { | ||
178 | return atomic64_inc_return_release(v); | ||
179 | } | ||
180 | |||
181 | static inline long | ||
182 | atomic_long_inc_return_relaxed(atomic_long_t *v) | ||
183 | { | ||
184 | return atomic64_inc_return_relaxed(v); | ||
185 | } | ||
186 | |||
187 | static inline long | ||
188 | atomic_long_fetch_inc(atomic_long_t *v) | ||
189 | { | ||
190 | return atomic64_fetch_inc(v); | ||
191 | } | ||
192 | |||
193 | static inline long | ||
194 | atomic_long_fetch_inc_acquire(atomic_long_t *v) | ||
195 | { | ||
196 | return atomic64_fetch_inc_acquire(v); | ||
197 | } | ||
198 | |||
199 | static inline long | ||
200 | atomic_long_fetch_inc_release(atomic_long_t *v) | ||
201 | { | ||
202 | return atomic64_fetch_inc_release(v); | ||
203 | } | ||
204 | |||
205 | static inline long | ||
206 | atomic_long_fetch_inc_relaxed(atomic_long_t *v) | ||
207 | { | ||
208 | return atomic64_fetch_inc_relaxed(v); | ||
209 | } | ||
210 | |||
211 | static inline void | ||
212 | atomic_long_dec(atomic_long_t *v) | ||
213 | { | ||
214 | atomic64_dec(v); | ||
215 | } | ||
216 | |||
217 | static inline long | ||
218 | atomic_long_dec_return(atomic_long_t *v) | ||
219 | { | ||
220 | return atomic64_dec_return(v); | ||
221 | } | ||
222 | |||
223 | static inline long | ||
224 | atomic_long_dec_return_acquire(atomic_long_t *v) | ||
225 | { | ||
226 | return atomic64_dec_return_acquire(v); | ||
227 | } | ||
228 | |||
229 | static inline long | ||
230 | atomic_long_dec_return_release(atomic_long_t *v) | ||
231 | { | ||
232 | return atomic64_dec_return_release(v); | ||
233 | } | ||
234 | |||
235 | static inline long | ||
236 | atomic_long_dec_return_relaxed(atomic_long_t *v) | ||
237 | { | ||
238 | return atomic64_dec_return_relaxed(v); | ||
239 | } | ||
240 | |||
241 | static inline long | ||
242 | atomic_long_fetch_dec(atomic_long_t *v) | ||
243 | { | ||
244 | return atomic64_fetch_dec(v); | ||
245 | } | ||
246 | |||
247 | static inline long | ||
248 | atomic_long_fetch_dec_acquire(atomic_long_t *v) | ||
249 | { | ||
250 | return atomic64_fetch_dec_acquire(v); | ||
251 | } | ||
252 | |||
253 | static inline long | ||
254 | atomic_long_fetch_dec_release(atomic_long_t *v) | ||
255 | { | ||
256 | return atomic64_fetch_dec_release(v); | ||
257 | } | ||
258 | |||
259 | static inline long | ||
260 | atomic_long_fetch_dec_relaxed(atomic_long_t *v) | ||
261 | { | ||
262 | return atomic64_fetch_dec_relaxed(v); | ||
263 | } | ||
264 | |||
265 | static inline void | ||
266 | atomic_long_and(long i, atomic_long_t *v) | ||
267 | { | ||
268 | atomic64_and(i, v); | ||
269 | } | ||
270 | |||
271 | static inline long | ||
272 | atomic_long_fetch_and(long i, atomic_long_t *v) | ||
273 | { | ||
274 | return atomic64_fetch_and(i, v); | ||
275 | } | ||
276 | |||
277 | static inline long | ||
278 | atomic_long_fetch_and_acquire(long i, atomic_long_t *v) | ||
279 | { | ||
280 | return atomic64_fetch_and_acquire(i, v); | ||
281 | } | ||
282 | |||
283 | static inline long | ||
284 | atomic_long_fetch_and_release(long i, atomic_long_t *v) | ||
285 | { | ||
286 | return atomic64_fetch_and_release(i, v); | ||
287 | } | ||
288 | |||
289 | static inline long | ||
290 | atomic_long_fetch_and_relaxed(long i, atomic_long_t *v) | ||
291 | { | ||
292 | return atomic64_fetch_and_relaxed(i, v); | ||
293 | } | ||
294 | |||
295 | static inline void | ||
296 | atomic_long_andnot(long i, atomic_long_t *v) | ||
297 | { | ||
298 | atomic64_andnot(i, v); | ||
299 | } | ||
300 | |||
301 | static inline long | ||
302 | atomic_long_fetch_andnot(long i, atomic_long_t *v) | ||
303 | { | ||
304 | return atomic64_fetch_andnot(i, v); | ||
305 | } | ||
306 | |||
307 | static inline long | ||
308 | atomic_long_fetch_andnot_acquire(long i, atomic_long_t *v) | ||
309 | { | ||
310 | return atomic64_fetch_andnot_acquire(i, v); | ||
311 | } | ||
312 | |||
313 | static inline long | ||
314 | atomic_long_fetch_andnot_release(long i, atomic_long_t *v) | ||
315 | { | ||
316 | return atomic64_fetch_andnot_release(i, v); | ||
317 | } | ||
318 | |||
319 | static inline long | ||
320 | atomic_long_fetch_andnot_relaxed(long i, atomic_long_t *v) | ||
321 | { | ||
322 | return atomic64_fetch_andnot_relaxed(i, v); | ||
323 | } | ||
324 | |||
325 | static inline void | ||
326 | atomic_long_or(long i, atomic_long_t *v) | ||
327 | { | ||
328 | atomic64_or(i, v); | ||
329 | } | ||
330 | |||
331 | static inline long | ||
332 | atomic_long_fetch_or(long i, atomic_long_t *v) | ||
333 | { | ||
334 | return atomic64_fetch_or(i, v); | ||
335 | } | ||
336 | |||
337 | static inline long | ||
338 | atomic_long_fetch_or_acquire(long i, atomic_long_t *v) | ||
339 | { | ||
340 | return atomic64_fetch_or_acquire(i, v); | ||
341 | } | ||
342 | |||
343 | static inline long | ||
344 | atomic_long_fetch_or_release(long i, atomic_long_t *v) | ||
345 | { | ||
346 | return atomic64_fetch_or_release(i, v); | ||
347 | } | ||
348 | |||
349 | static inline long | ||
350 | atomic_long_fetch_or_relaxed(long i, atomic_long_t *v) | ||
351 | { | ||
352 | return atomic64_fetch_or_relaxed(i, v); | ||
353 | } | ||
354 | |||
355 | static inline void | ||
356 | atomic_long_xor(long i, atomic_long_t *v) | ||
357 | { | ||
358 | atomic64_xor(i, v); | ||
359 | } | ||
360 | |||
361 | static inline long | ||
362 | atomic_long_fetch_xor(long i, atomic_long_t *v) | ||
363 | { | ||
364 | return atomic64_fetch_xor(i, v); | ||
365 | } | ||
366 | |||
367 | static inline long | ||
368 | atomic_long_fetch_xor_acquire(long i, atomic_long_t *v) | ||
369 | { | ||
370 | return atomic64_fetch_xor_acquire(i, v); | ||
371 | } | ||
372 | |||
373 | static inline long | ||
374 | atomic_long_fetch_xor_release(long i, atomic_long_t *v) | ||
375 | { | ||
376 | return atomic64_fetch_xor_release(i, v); | ||
377 | } | ||
378 | |||
379 | static inline long | ||
380 | atomic_long_fetch_xor_relaxed(long i, atomic_long_t *v) | ||
381 | { | ||
382 | return atomic64_fetch_xor_relaxed(i, v); | ||
383 | } | ||
384 | |||
385 | static inline long | ||
386 | atomic_long_xchg(atomic_long_t *v, long i) | ||
387 | { | ||
388 | return atomic64_xchg(v, i); | ||
389 | } | ||
390 | |||
391 | static inline long | ||
392 | atomic_long_xchg_acquire(atomic_long_t *v, long i) | ||
393 | { | ||
394 | return atomic64_xchg_acquire(v, i); | ||
395 | } | ||
396 | |||
397 | static inline long | ||
398 | atomic_long_xchg_release(atomic_long_t *v, long i) | ||
399 | { | ||
400 | return atomic64_xchg_release(v, i); | ||
401 | } | ||
402 | |||
403 | static inline long | ||
404 | atomic_long_xchg_relaxed(atomic_long_t *v, long i) | ||
405 | { | ||
406 | return atomic64_xchg_relaxed(v, i); | ||
407 | } | ||
408 | |||
409 | static inline long | ||
410 | atomic_long_cmpxchg(atomic_long_t *v, long old, long new) | ||
411 | { | ||
412 | return atomic64_cmpxchg(v, old, new); | ||
413 | } | ||
414 | |||
415 | static inline long | ||
416 | atomic_long_cmpxchg_acquire(atomic_long_t *v, long old, long new) | ||
417 | { | ||
418 | return atomic64_cmpxchg_acquire(v, old, new); | ||
419 | } | ||
420 | |||
421 | static inline long | ||
422 | atomic_long_cmpxchg_release(atomic_long_t *v, long old, long new) | ||
423 | { | ||
424 | return atomic64_cmpxchg_release(v, old, new); | ||
425 | } | ||
426 | |||
427 | static inline long | ||
428 | atomic_long_cmpxchg_relaxed(atomic_long_t *v, long old, long new) | ||
429 | { | ||
430 | return atomic64_cmpxchg_relaxed(v, old, new); | ||
431 | } | ||
432 | |||
433 | static inline bool | ||
434 | atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new) | ||
435 | { | ||
436 | return atomic64_try_cmpxchg(v, (s64 *)old, new); | ||
437 | } | ||
438 | |||
439 | static inline bool | ||
440 | atomic_long_try_cmpxchg_acquire(atomic_long_t *v, long *old, long new) | ||
441 | { | ||
442 | return atomic64_try_cmpxchg_acquire(v, (s64 *)old, new); | ||
443 | } | ||
444 | |||
445 | static inline bool | ||
446 | atomic_long_try_cmpxchg_release(atomic_long_t *v, long *old, long new) | ||
447 | { | ||
448 | return atomic64_try_cmpxchg_release(v, (s64 *)old, new); | ||
449 | } | ||
450 | |||
451 | static inline bool | ||
452 | atomic_long_try_cmpxchg_relaxed(atomic_long_t *v, long *old, long new) | ||
453 | { | ||
454 | return atomic64_try_cmpxchg_relaxed(v, (s64 *)old, new); | ||
455 | } | ||
456 | |||
457 | static inline bool | ||
458 | atomic_long_sub_and_test(long i, atomic_long_t *v) | ||
459 | { | ||
460 | return atomic64_sub_and_test(i, v); | ||
461 | } | ||
462 | |||
463 | static inline bool | ||
464 | atomic_long_dec_and_test(atomic_long_t *v) | ||
465 | { | ||
466 | return atomic64_dec_and_test(v); | ||
467 | } | ||
468 | |||
469 | static inline bool | ||
470 | atomic_long_inc_and_test(atomic_long_t *v) | ||
471 | { | ||
472 | return atomic64_inc_and_test(v); | ||
473 | } | ||
474 | |||
475 | static inline bool | ||
476 | atomic_long_add_negative(long i, atomic_long_t *v) | ||
477 | { | ||
478 | return atomic64_add_negative(i, v); | ||
479 | } | ||
480 | |||
481 | static inline long | ||
482 | atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u) | ||
483 | { | ||
484 | return atomic64_fetch_add_unless(v, a, u); | ||
485 | } | ||
486 | |||
487 | static inline bool | ||
488 | atomic_long_add_unless(atomic_long_t *v, long a, long u) | ||
489 | { | ||
490 | return atomic64_add_unless(v, a, u); | ||
491 | } | ||
492 | |||
493 | static inline bool | ||
494 | atomic_long_inc_not_zero(atomic_long_t *v) | ||
495 | { | ||
496 | return atomic64_inc_not_zero(v); | ||
497 | } | ||
498 | |||
499 | static inline bool | ||
500 | atomic_long_inc_unless_negative(atomic_long_t *v) | ||
501 | { | ||
502 | return atomic64_inc_unless_negative(v); | ||
503 | } | ||
504 | |||
505 | static inline bool | ||
506 | atomic_long_dec_unless_positive(atomic_long_t *v) | ||
507 | { | ||
508 | return atomic64_dec_unless_positive(v); | ||
509 | } | ||
510 | |||
511 | static inline long | ||
512 | atomic_long_dec_if_positive(atomic_long_t *v) | ||
513 | { | ||
514 | return atomic64_dec_if_positive(v); | ||
515 | } | ||
516 | |||
517 | #else /* CONFIG_64BIT */ | ||
518 | |||
519 | static inline long | ||
520 | atomic_long_read(const atomic_long_t *v) | ||
521 | { | ||
522 | return atomic_read(v); | ||
523 | } | ||
524 | |||
525 | static inline long | ||
526 | atomic_long_read_acquire(const atomic_long_t *v) | ||
527 | { | ||
528 | return atomic_read_acquire(v); | ||
529 | } | ||
530 | |||
531 | static inline void | ||
532 | atomic_long_set(atomic_long_t *v, long i) | ||
533 | { | ||
534 | atomic_set(v, i); | ||
535 | } | ||
536 | |||
537 | static inline void | ||
538 | atomic_long_set_release(atomic_long_t *v, long i) | ||
539 | { | ||
540 | atomic_set_release(v, i); | ||
541 | } | ||
542 | |||
543 | static inline void | ||
544 | atomic_long_add(long i, atomic_long_t *v) | ||
545 | { | ||
546 | atomic_add(i, v); | ||
547 | } | ||
548 | |||
549 | static inline long | ||
550 | atomic_long_add_return(long i, atomic_long_t *v) | ||
551 | { | ||
552 | return atomic_add_return(i, v); | ||
553 | } | ||
554 | |||
555 | static inline long | ||
556 | atomic_long_add_return_acquire(long i, atomic_long_t *v) | ||
557 | { | ||
558 | return atomic_add_return_acquire(i, v); | ||
559 | } | ||
560 | |||
561 | static inline long | ||
562 | atomic_long_add_return_release(long i, atomic_long_t *v) | ||
563 | { | ||
564 | return atomic_add_return_release(i, v); | ||
565 | } | ||
566 | |||
567 | static inline long | ||
568 | atomic_long_add_return_relaxed(long i, atomic_long_t *v) | ||
569 | { | ||
570 | return atomic_add_return_relaxed(i, v); | ||
571 | } | ||
572 | |||
573 | static inline long | ||
574 | atomic_long_fetch_add(long i, atomic_long_t *v) | ||
575 | { | ||
576 | return atomic_fetch_add(i, v); | ||
577 | } | ||
578 | |||
579 | static inline long | ||
580 | atomic_long_fetch_add_acquire(long i, atomic_long_t *v) | ||
581 | { | ||
582 | return atomic_fetch_add_acquire(i, v); | ||
583 | } | ||
584 | |||
585 | static inline long | ||
586 | atomic_long_fetch_add_release(long i, atomic_long_t *v) | ||
587 | { | ||
588 | return atomic_fetch_add_release(i, v); | ||
589 | } | ||
590 | |||
591 | static inline long | ||
592 | atomic_long_fetch_add_relaxed(long i, atomic_long_t *v) | ||
593 | { | ||
594 | return atomic_fetch_add_relaxed(i, v); | ||
595 | } | ||
596 | |||
597 | static inline void | ||
598 | atomic_long_sub(long i, atomic_long_t *v) | ||
599 | { | ||
600 | atomic_sub(i, v); | ||
601 | } | ||
602 | |||
603 | static inline long | ||
604 | atomic_long_sub_return(long i, atomic_long_t *v) | ||
605 | { | ||
606 | return atomic_sub_return(i, v); | ||
607 | } | ||
608 | |||
609 | static inline long | ||
610 | atomic_long_sub_return_acquire(long i, atomic_long_t *v) | ||
611 | { | ||
612 | return atomic_sub_return_acquire(i, v); | ||
613 | } | ||
614 | |||
615 | static inline long | ||
616 | atomic_long_sub_return_release(long i, atomic_long_t *v) | ||
617 | { | ||
618 | return atomic_sub_return_release(i, v); | ||
619 | } | ||
620 | |||
621 | static inline long | ||
622 | atomic_long_sub_return_relaxed(long i, atomic_long_t *v) | ||
623 | { | ||
624 | return atomic_sub_return_relaxed(i, v); | ||
625 | } | ||
626 | |||
627 | static inline long | ||
628 | atomic_long_fetch_sub(long i, atomic_long_t *v) | ||
629 | { | ||
630 | return atomic_fetch_sub(i, v); | ||
631 | } | ||
632 | |||
633 | static inline long | ||
634 | atomic_long_fetch_sub_acquire(long i, atomic_long_t *v) | ||
635 | { | ||
636 | return atomic_fetch_sub_acquire(i, v); | ||
637 | } | ||
638 | |||
639 | static inline long | ||
640 | atomic_long_fetch_sub_release(long i, atomic_long_t *v) | ||
641 | { | ||
642 | return atomic_fetch_sub_release(i, v); | ||
643 | } | ||
644 | |||
645 | static inline long | ||
646 | atomic_long_fetch_sub_relaxed(long i, atomic_long_t *v) | ||
647 | { | ||
648 | return atomic_fetch_sub_relaxed(i, v); | ||
649 | } | ||
650 | |||
651 | static inline void | ||
652 | atomic_long_inc(atomic_long_t *v) | ||
653 | { | ||
654 | atomic_inc(v); | ||
655 | } | ||
656 | |||
657 | static inline long | ||
658 | atomic_long_inc_return(atomic_long_t *v) | ||
659 | { | ||
660 | return atomic_inc_return(v); | ||
661 | } | ||
662 | |||
663 | static inline long | ||
664 | atomic_long_inc_return_acquire(atomic_long_t *v) | ||
665 | { | ||
666 | return atomic_inc_return_acquire(v); | ||
667 | } | ||
668 | |||
669 | static inline long | ||
670 | atomic_long_inc_return_release(atomic_long_t *v) | ||
671 | { | ||
672 | return atomic_inc_return_release(v); | ||
673 | } | ||
674 | |||
675 | static inline long | ||
676 | atomic_long_inc_return_relaxed(atomic_long_t *v) | ||
677 | { | ||
678 | return atomic_inc_return_relaxed(v); | ||
679 | } | ||
680 | |||
681 | static inline long | ||
682 | atomic_long_fetch_inc(atomic_long_t *v) | ||
683 | { | ||
684 | return atomic_fetch_inc(v); | ||
685 | } | ||
686 | |||
687 | static inline long | ||
688 | atomic_long_fetch_inc_acquire(atomic_long_t *v) | ||
689 | { | ||
690 | return atomic_fetch_inc_acquire(v); | ||
691 | } | ||
692 | |||
693 | static inline long | ||
694 | atomic_long_fetch_inc_release(atomic_long_t *v) | ||
695 | { | ||
696 | return atomic_fetch_inc_release(v); | ||
697 | } | ||
698 | |||
699 | static inline long | ||
700 | atomic_long_fetch_inc_relaxed(atomic_long_t *v) | ||
701 | { | ||
702 | return atomic_fetch_inc_relaxed(v); | ||
703 | } | ||
704 | |||
705 | static inline void | ||
706 | atomic_long_dec(atomic_long_t *v) | ||
707 | { | ||
708 | atomic_dec(v); | ||
709 | } | ||
710 | |||
711 | static inline long | ||
712 | atomic_long_dec_return(atomic_long_t *v) | ||
713 | { | ||
714 | return atomic_dec_return(v); | ||
715 | } | ||
716 | |||
717 | static inline long | ||
718 | atomic_long_dec_return_acquire(atomic_long_t *v) | ||
719 | { | ||
720 | return atomic_dec_return_acquire(v); | ||
721 | } | ||
722 | |||
723 | static inline long | ||
724 | atomic_long_dec_return_release(atomic_long_t *v) | ||
725 | { | ||
726 | return atomic_dec_return_release(v); | ||
727 | } | ||
728 | |||
729 | static inline long | ||
730 | atomic_long_dec_return_relaxed(atomic_long_t *v) | ||
731 | { | ||
732 | return atomic_dec_return_relaxed(v); | ||
733 | } | ||
734 | |||
735 | static inline long | ||
736 | atomic_long_fetch_dec(atomic_long_t *v) | ||
737 | { | ||
738 | return atomic_fetch_dec(v); | ||
739 | } | ||
740 | |||
741 | static inline long | ||
742 | atomic_long_fetch_dec_acquire(atomic_long_t *v) | ||
743 | { | ||
744 | return atomic_fetch_dec_acquire(v); | ||
745 | } | ||
746 | |||
747 | static inline long | ||
748 | atomic_long_fetch_dec_release(atomic_long_t *v) | ||
749 | { | ||
750 | return atomic_fetch_dec_release(v); | ||
751 | } | ||
752 | |||
753 | static inline long | ||
754 | atomic_long_fetch_dec_relaxed(atomic_long_t *v) | ||
755 | { | ||
756 | return atomic_fetch_dec_relaxed(v); | ||
757 | } | ||
758 | |||
759 | static inline void | ||
760 | atomic_long_and(long i, atomic_long_t *v) | ||
761 | { | ||
762 | atomic_and(i, v); | ||
763 | } | ||
764 | |||
765 | static inline long | ||
766 | atomic_long_fetch_and(long i, atomic_long_t *v) | ||
767 | { | ||
768 | return atomic_fetch_and(i, v); | ||
769 | } | ||
770 | |||
771 | static inline long | ||
772 | atomic_long_fetch_and_acquire(long i, atomic_long_t *v) | ||
773 | { | ||
774 | return atomic_fetch_and_acquire(i, v); | ||
775 | } | ||
776 | |||
777 | static inline long | ||
778 | atomic_long_fetch_and_release(long i, atomic_long_t *v) | ||
779 | { | ||
780 | return atomic_fetch_and_release(i, v); | ||
781 | } | ||
782 | |||
783 | static inline long | ||
784 | atomic_long_fetch_and_relaxed(long i, atomic_long_t *v) | ||
785 | { | ||
786 | return atomic_fetch_and_relaxed(i, v); | ||
787 | } | ||
788 | |||
789 | static inline void | ||
790 | atomic_long_andnot(long i, atomic_long_t *v) | ||
791 | { | ||
792 | atomic_andnot(i, v); | ||
793 | } | ||
794 | |||
795 | static inline long | ||
796 | atomic_long_fetch_andnot(long i, atomic_long_t *v) | ||
797 | { | ||
798 | return atomic_fetch_andnot(i, v); | ||
799 | } | ||
800 | |||
801 | static inline long | ||
802 | atomic_long_fetch_andnot_acquire(long i, atomic_long_t *v) | ||
803 | { | ||
804 | return atomic_fetch_andnot_acquire(i, v); | ||
805 | } | ||
806 | |||
807 | static inline long | ||
808 | atomic_long_fetch_andnot_release(long i, atomic_long_t *v) | ||
809 | { | ||
810 | return atomic_fetch_andnot_release(i, v); | ||
811 | } | ||
812 | |||
813 | static inline long | ||
814 | atomic_long_fetch_andnot_relaxed(long i, atomic_long_t *v) | ||
815 | { | ||
816 | return atomic_fetch_andnot_relaxed(i, v); | ||
817 | } | ||
39 | 818 | ||
40 | #define ATOMIC_LONG_READ_OP(mo) \ | 819 | static inline void |
41 | static inline long atomic_long_read##mo(const atomic_long_t *l) \ | 820 | atomic_long_or(long i, atomic_long_t *v) |
42 | { \ | ||
43 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ | ||
44 | \ | ||
45 | return (long)ATOMIC_LONG_PFX(_read##mo)(v); \ | ||
46 | } | ||
47 | ATOMIC_LONG_READ_OP() | ||
48 | ATOMIC_LONG_READ_OP(_acquire) | ||
49 | |||
50 | #undef ATOMIC_LONG_READ_OP | ||
51 | |||
52 | #define ATOMIC_LONG_SET_OP(mo) \ | ||
53 | static inline void atomic_long_set##mo(atomic_long_t *l, long i) \ | ||
54 | { \ | ||
55 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ | ||
56 | \ | ||
57 | ATOMIC_LONG_PFX(_set##mo)(v, i); \ | ||
58 | } | ||
59 | ATOMIC_LONG_SET_OP() | ||
60 | ATOMIC_LONG_SET_OP(_release) | ||
61 | |||
62 | #undef ATOMIC_LONG_SET_OP | ||
63 | |||
64 | #define ATOMIC_LONG_ADD_SUB_OP(op, mo) \ | ||
65 | static inline long \ | ||
66 | atomic_long_##op##_return##mo(long i, atomic_long_t *l) \ | ||
67 | { \ | ||
68 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ | ||
69 | \ | ||
70 | return (long)ATOMIC_LONG_PFX(_##op##_return##mo)(i, v); \ | ||
71 | } | ||
72 | ATOMIC_LONG_ADD_SUB_OP(add,) | ||
73 | ATOMIC_LONG_ADD_SUB_OP(add, _relaxed) | ||
74 | ATOMIC_LONG_ADD_SUB_OP(add, _acquire) | ||
75 | ATOMIC_LONG_ADD_SUB_OP(add, _release) | ||
76 | ATOMIC_LONG_ADD_SUB_OP(sub,) | ||
77 | ATOMIC_LONG_ADD_SUB_OP(sub, _relaxed) | ||
78 | ATOMIC_LONG_ADD_SUB_OP(sub, _acquire) | ||
79 | ATOMIC_LONG_ADD_SUB_OP(sub, _release) | ||
80 | |||
81 | #undef ATOMIC_LONG_ADD_SUB_OP | ||
82 | |||
83 | #define atomic_long_cmpxchg_relaxed(l, old, new) \ | ||
84 | (ATOMIC_LONG_PFX(_cmpxchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(l), \ | ||
85 | (old), (new))) | ||
86 | #define atomic_long_cmpxchg_acquire(l, old, new) \ | ||
87 | (ATOMIC_LONG_PFX(_cmpxchg_acquire)((ATOMIC_LONG_PFX(_t) *)(l), \ | ||
88 | (old), (new))) | ||
89 | #define atomic_long_cmpxchg_release(l, old, new) \ | ||
90 | (ATOMIC_LONG_PFX(_cmpxchg_release)((ATOMIC_LONG_PFX(_t) *)(l), \ | ||
91 | (old), (new))) | ||
92 | #define atomic_long_cmpxchg(l, old, new) \ | ||
93 | (ATOMIC_LONG_PFX(_cmpxchg)((ATOMIC_LONG_PFX(_t) *)(l), (old), (new))) | ||
94 | |||
95 | |||
96 | #define atomic_long_try_cmpxchg_relaxed(l, old, new) \ | ||
97 | (ATOMIC_LONG_PFX(_try_cmpxchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(l), \ | ||
98 | (ATOMIC_LONG_TYPE *)(old), (ATOMIC_LONG_TYPE)(new))) | ||
99 | #define atomic_long_try_cmpxchg_acquire(l, old, new) \ | ||
100 | (ATOMIC_LONG_PFX(_try_cmpxchg_acquire)((ATOMIC_LONG_PFX(_t) *)(l), \ | ||
101 | (ATOMIC_LONG_TYPE *)(old), (ATOMIC_LONG_TYPE)(new))) | ||
102 | #define atomic_long_try_cmpxchg_release(l, old, new) \ | ||
103 | (ATOMIC_LONG_PFX(_try_cmpxchg_release)((ATOMIC_LONG_PFX(_t) *)(l), \ | ||
104 | (ATOMIC_LONG_TYPE *)(old), (ATOMIC_LONG_TYPE)(new))) | ||
105 | #define atomic_long_try_cmpxchg(l, old, new) \ | ||
106 | (ATOMIC_LONG_PFX(_try_cmpxchg)((ATOMIC_LONG_PFX(_t) *)(l), \ | ||
107 | (ATOMIC_LONG_TYPE *)(old), (ATOMIC_LONG_TYPE)(new))) | ||
108 | |||
109 | |||
110 | #define atomic_long_xchg_relaxed(v, new) \ | ||
111 | (ATOMIC_LONG_PFX(_xchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(v), (new))) | ||
112 | #define atomic_long_xchg_acquire(v, new) \ | ||
113 | (ATOMIC_LONG_PFX(_xchg_acquire)((ATOMIC_LONG_PFX(_t) *)(v), (new))) | ||
114 | #define atomic_long_xchg_release(v, new) \ | ||
115 | (ATOMIC_LONG_PFX(_xchg_release)((ATOMIC_LONG_PFX(_t) *)(v), (new))) | ||
116 | #define atomic_long_xchg(v, new) \ | ||
117 | (ATOMIC_LONG_PFX(_xchg)((ATOMIC_LONG_PFX(_t) *)(v), (new))) | ||
118 | |||
119 | static __always_inline void atomic_long_inc(atomic_long_t *l) | ||
120 | { | ||
121 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | ||
122 | |||
123 | ATOMIC_LONG_PFX(_inc)(v); | ||
124 | } | ||
125 | |||
126 | static __always_inline void atomic_long_dec(atomic_long_t *l) | ||
127 | { | 821 | { |
128 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 822 | atomic_or(i, v); |
823 | } | ||
129 | 824 | ||
130 | ATOMIC_LONG_PFX(_dec)(v); | 825 | static inline long |
826 | atomic_long_fetch_or(long i, atomic_long_t *v) | ||
827 | { | ||
828 | return atomic_fetch_or(i, v); | ||
131 | } | 829 | } |
132 | 830 | ||
133 | #define ATOMIC_LONG_FETCH_OP(op, mo) \ | 831 | static inline long |
134 | static inline long \ | 832 | atomic_long_fetch_or_acquire(long i, atomic_long_t *v) |
135 | atomic_long_fetch_##op##mo(long i, atomic_long_t *l) \ | 833 | { |
136 | { \ | 834 | return atomic_fetch_or_acquire(i, v); |
137 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ | ||
138 | \ | ||
139 | return (long)ATOMIC_LONG_PFX(_fetch_##op##mo)(i, v); \ | ||
140 | } | 835 | } |
141 | 836 | ||
142 | ATOMIC_LONG_FETCH_OP(add, ) | 837 | static inline long |
143 | ATOMIC_LONG_FETCH_OP(add, _relaxed) | 838 | atomic_long_fetch_or_release(long i, atomic_long_t *v) |
144 | ATOMIC_LONG_FETCH_OP(add, _acquire) | 839 | { |
145 | ATOMIC_LONG_FETCH_OP(add, _release) | 840 | return atomic_fetch_or_release(i, v); |
146 | ATOMIC_LONG_FETCH_OP(sub, ) | 841 | } |
147 | ATOMIC_LONG_FETCH_OP(sub, _relaxed) | ||
148 | ATOMIC_LONG_FETCH_OP(sub, _acquire) | ||
149 | ATOMIC_LONG_FETCH_OP(sub, _release) | ||
150 | ATOMIC_LONG_FETCH_OP(and, ) | ||
151 | ATOMIC_LONG_FETCH_OP(and, _relaxed) | ||
152 | ATOMIC_LONG_FETCH_OP(and, _acquire) | ||
153 | ATOMIC_LONG_FETCH_OP(and, _release) | ||
154 | ATOMIC_LONG_FETCH_OP(andnot, ) | ||
155 | ATOMIC_LONG_FETCH_OP(andnot, _relaxed) | ||
156 | ATOMIC_LONG_FETCH_OP(andnot, _acquire) | ||
157 | ATOMIC_LONG_FETCH_OP(andnot, _release) | ||
158 | ATOMIC_LONG_FETCH_OP(or, ) | ||
159 | ATOMIC_LONG_FETCH_OP(or, _relaxed) | ||
160 | ATOMIC_LONG_FETCH_OP(or, _acquire) | ||
161 | ATOMIC_LONG_FETCH_OP(or, _release) | ||
162 | ATOMIC_LONG_FETCH_OP(xor, ) | ||
163 | ATOMIC_LONG_FETCH_OP(xor, _relaxed) | ||
164 | ATOMIC_LONG_FETCH_OP(xor, _acquire) | ||
165 | ATOMIC_LONG_FETCH_OP(xor, _release) | ||
166 | 842 | ||
167 | #undef ATOMIC_LONG_FETCH_OP | 843 | static inline long |
844 | atomic_long_fetch_or_relaxed(long i, atomic_long_t *v) | ||
845 | { | ||
846 | return atomic_fetch_or_relaxed(i, v); | ||
847 | } | ||
168 | 848 | ||
169 | #define ATOMIC_LONG_FETCH_INC_DEC_OP(op, mo) \ | 849 | static inline void |
170 | static inline long \ | 850 | atomic_long_xor(long i, atomic_long_t *v) |
171 | atomic_long_fetch_##op##mo(atomic_long_t *l) \ | 851 | { |
172 | { \ | 852 | atomic_xor(i, v); |
173 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ | ||
174 | \ | ||
175 | return (long)ATOMIC_LONG_PFX(_fetch_##op##mo)(v); \ | ||
176 | } | 853 | } |
177 | 854 | ||
178 | ATOMIC_LONG_FETCH_INC_DEC_OP(inc,) | 855 | static inline long |
179 | ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _relaxed) | 856 | atomic_long_fetch_xor(long i, atomic_long_t *v) |
180 | ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _acquire) | 857 | { |
181 | ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _release) | 858 | return atomic_fetch_xor(i, v); |
182 | ATOMIC_LONG_FETCH_INC_DEC_OP(dec,) | 859 | } |
183 | ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _relaxed) | ||
184 | ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _acquire) | ||
185 | ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _release) | ||
186 | 860 | ||
187 | #undef ATOMIC_LONG_FETCH_INC_DEC_OP | 861 | static inline long |
862 | atomic_long_fetch_xor_acquire(long i, atomic_long_t *v) | ||
863 | { | ||
864 | return atomic_fetch_xor_acquire(i, v); | ||
865 | } | ||
188 | 866 | ||
189 | #define ATOMIC_LONG_OP(op) \ | 867 | static inline long |
190 | static __always_inline void \ | 868 | atomic_long_fetch_xor_release(long i, atomic_long_t *v) |
191 | atomic_long_##op(long i, atomic_long_t *l) \ | 869 | { |
192 | { \ | 870 | return atomic_fetch_xor_release(i, v); |
193 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ | ||
194 | \ | ||
195 | ATOMIC_LONG_PFX(_##op)(i, v); \ | ||
196 | } | 871 | } |
197 | 872 | ||
198 | ATOMIC_LONG_OP(add) | 873 | static inline long |
199 | ATOMIC_LONG_OP(sub) | 874 | atomic_long_fetch_xor_relaxed(long i, atomic_long_t *v) |
200 | ATOMIC_LONG_OP(and) | 875 | { |
201 | ATOMIC_LONG_OP(andnot) | 876 | return atomic_fetch_xor_relaxed(i, v); |
202 | ATOMIC_LONG_OP(or) | 877 | } |
203 | ATOMIC_LONG_OP(xor) | ||
204 | 878 | ||
205 | #undef ATOMIC_LONG_OP | 879 | static inline long |
880 | atomic_long_xchg(atomic_long_t *v, long i) | ||
881 | { | ||
882 | return atomic_xchg(v, i); | ||
883 | } | ||
206 | 884 | ||
207 | static inline int atomic_long_sub_and_test(long i, atomic_long_t *l) | 885 | static inline long |
886 | atomic_long_xchg_acquire(atomic_long_t *v, long i) | ||
208 | { | 887 | { |
209 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 888 | return atomic_xchg_acquire(v, i); |
889 | } | ||
210 | 890 | ||
211 | return ATOMIC_LONG_PFX(_sub_and_test)(i, v); | 891 | static inline long |
892 | atomic_long_xchg_release(atomic_long_t *v, long i) | ||
893 | { | ||
894 | return atomic_xchg_release(v, i); | ||
212 | } | 895 | } |
213 | 896 | ||
214 | static inline int atomic_long_dec_and_test(atomic_long_t *l) | 897 | static inline long |
898 | atomic_long_xchg_relaxed(atomic_long_t *v, long i) | ||
215 | { | 899 | { |
216 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 900 | return atomic_xchg_relaxed(v, i); |
901 | } | ||
217 | 902 | ||
218 | return ATOMIC_LONG_PFX(_dec_and_test)(v); | 903 | static inline long |
904 | atomic_long_cmpxchg(atomic_long_t *v, long old, long new) | ||
905 | { | ||
906 | return atomic_cmpxchg(v, old, new); | ||
219 | } | 907 | } |
220 | 908 | ||
221 | static inline int atomic_long_inc_and_test(atomic_long_t *l) | 909 | static inline long |
910 | atomic_long_cmpxchg_acquire(atomic_long_t *v, long old, long new) | ||
222 | { | 911 | { |
223 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 912 | return atomic_cmpxchg_acquire(v, old, new); |
913 | } | ||
224 | 914 | ||
225 | return ATOMIC_LONG_PFX(_inc_and_test)(v); | 915 | static inline long |
916 | atomic_long_cmpxchg_release(atomic_long_t *v, long old, long new) | ||
917 | { | ||
918 | return atomic_cmpxchg_release(v, old, new); | ||
226 | } | 919 | } |
227 | 920 | ||
228 | static inline int atomic_long_add_negative(long i, atomic_long_t *l) | 921 | static inline long |
922 | atomic_long_cmpxchg_relaxed(atomic_long_t *v, long old, long new) | ||
229 | { | 923 | { |
230 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 924 | return atomic_cmpxchg_relaxed(v, old, new); |
925 | } | ||
231 | 926 | ||
232 | return ATOMIC_LONG_PFX(_add_negative)(i, v); | 927 | static inline bool |
928 | atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new) | ||
929 | { | ||
930 | return atomic_try_cmpxchg(v, (int *)old, new); | ||
233 | } | 931 | } |
234 | 932 | ||
235 | #define ATOMIC_LONG_INC_DEC_OP(op, mo) \ | 933 | static inline bool |
236 | static inline long \ | 934 | atomic_long_try_cmpxchg_acquire(atomic_long_t *v, long *old, long new) |
237 | atomic_long_##op##_return##mo(atomic_long_t *l) \ | 935 | { |
238 | { \ | 936 | return atomic_try_cmpxchg_acquire(v, (int *)old, new); |
239 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \ | ||
240 | \ | ||
241 | return (long)ATOMIC_LONG_PFX(_##op##_return##mo)(v); \ | ||
242 | } | 937 | } |
243 | ATOMIC_LONG_INC_DEC_OP(inc,) | ||
244 | ATOMIC_LONG_INC_DEC_OP(inc, _relaxed) | ||
245 | ATOMIC_LONG_INC_DEC_OP(inc, _acquire) | ||
246 | ATOMIC_LONG_INC_DEC_OP(inc, _release) | ||
247 | ATOMIC_LONG_INC_DEC_OP(dec,) | ||
248 | ATOMIC_LONG_INC_DEC_OP(dec, _relaxed) | ||
249 | ATOMIC_LONG_INC_DEC_OP(dec, _acquire) | ||
250 | ATOMIC_LONG_INC_DEC_OP(dec, _release) | ||
251 | 938 | ||
252 | #undef ATOMIC_LONG_INC_DEC_OP | 939 | static inline bool |
940 | atomic_long_try_cmpxchg_release(atomic_long_t *v, long *old, long new) | ||
941 | { | ||
942 | return atomic_try_cmpxchg_release(v, (int *)old, new); | ||
943 | } | ||
944 | |||
945 | static inline bool | ||
946 | atomic_long_try_cmpxchg_relaxed(atomic_long_t *v, long *old, long new) | ||
947 | { | ||
948 | return atomic_try_cmpxchg_relaxed(v, (int *)old, new); | ||
949 | } | ||
950 | |||
951 | static inline bool | ||
952 | atomic_long_sub_and_test(long i, atomic_long_t *v) | ||
953 | { | ||
954 | return atomic_sub_and_test(i, v); | ||
955 | } | ||
956 | |||
957 | static inline bool | ||
958 | atomic_long_dec_and_test(atomic_long_t *v) | ||
959 | { | ||
960 | return atomic_dec_and_test(v); | ||
961 | } | ||
962 | |||
963 | static inline bool | ||
964 | atomic_long_inc_and_test(atomic_long_t *v) | ||
965 | { | ||
966 | return atomic_inc_and_test(v); | ||
967 | } | ||
968 | |||
969 | static inline bool | ||
970 | atomic_long_add_negative(long i, atomic_long_t *v) | ||
971 | { | ||
972 | return atomic_add_negative(i, v); | ||
973 | } | ||
974 | |||
975 | static inline long | ||
976 | atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u) | ||
977 | { | ||
978 | return atomic_fetch_add_unless(v, a, u); | ||
979 | } | ||
980 | |||
981 | static inline bool | ||
982 | atomic_long_add_unless(atomic_long_t *v, long a, long u) | ||
983 | { | ||
984 | return atomic_add_unless(v, a, u); | ||
985 | } | ||
253 | 986 | ||
254 | static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u) | 987 | static inline bool |
988 | atomic_long_inc_not_zero(atomic_long_t *v) | ||
255 | { | 989 | { |
256 | ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; | 990 | return atomic_inc_not_zero(v); |
991 | } | ||
257 | 992 | ||
258 | return (long)ATOMIC_LONG_PFX(_add_unless)(v, a, u); | 993 | static inline bool |
994 | atomic_long_inc_unless_negative(atomic_long_t *v) | ||
995 | { | ||
996 | return atomic_inc_unless_negative(v); | ||
259 | } | 997 | } |
260 | 998 | ||
261 | #define atomic_long_inc_not_zero(l) \ | 999 | static inline bool |
262 | ATOMIC_LONG_PFX(_inc_not_zero)((ATOMIC_LONG_PFX(_t) *)(l)) | 1000 | atomic_long_dec_unless_positive(atomic_long_t *v) |
1001 | { | ||
1002 | return atomic_dec_unless_positive(v); | ||
1003 | } | ||
263 | 1004 | ||
264 | #define atomic_long_cond_read_relaxed(v, c) \ | 1005 | static inline long |
265 | ATOMIC_LONG_PFX(_cond_read_relaxed)((ATOMIC_LONG_PFX(_t) *)(v), (c)) | 1006 | atomic_long_dec_if_positive(atomic_long_t *v) |
266 | #define atomic_long_cond_read_acquire(v, c) \ | 1007 | { |
267 | ATOMIC_LONG_PFX(_cond_read_acquire)((ATOMIC_LONG_PFX(_t) *)(v), (c)) | 1008 | return atomic_dec_if_positive(v); |
1009 | } | ||
268 | 1010 | ||
269 | #endif /* _ASM_GENERIC_ATOMIC_LONG_H */ | 1011 | #endif /* CONFIG_64BIT */ |
1012 | #endif /* _ASM_GENERIC_ATOMIC_LONG_H */ | ||