|
423 | 423 | #endif |
424 | 424 | #endif /* atomic_cmpxchg_relaxed */ |
425 | 425 |
|
| 426 | +#ifndef atomic_try_cmpxchg |
| 427 | + |
| 428 | +#define __atomic_try_cmpxchg(type, _p, _po, _n) \ |
| 429 | +({ \ |
| 430 | + typeof(_po) __po = (_po); \ |
| 431 | + typeof(*(_po)) __o = *__po; \ |
| 432 | + *__po = atomic_cmpxchg##type((_p), __o, (_n)); \ |
| 433 | + (*__po == __o); \ |
| 434 | +}) |
| 435 | + |
| 436 | +#define atomic_try_cmpxchg(_p, _po, _n) __atomic_try_cmpxchg(, _p, _po, _n) |
| 437 | +#define atomic_try_cmpxchg_relaxed(_p, _po, _n) __atomic_try_cmpxchg(_relaxed, _p, _po, _n) |
| 438 | +#define atomic_try_cmpxchg_acquire(_p, _po, _n) __atomic_try_cmpxchg(_acquire, _p, _po, _n) |
| 439 | +#define atomic_try_cmpxchg_release(_p, _po, _n) __atomic_try_cmpxchg(_release, _p, _po, _n) |
| 440 | + |
| 441 | +#else /* atomic_try_cmpxchg */ |
| 442 | +#define atomic_try_cmpxchg_relaxed atomic_try_cmpxchg |
| 443 | +#define atomic_try_cmpxchg_acquire atomic_try_cmpxchg |
| 444 | +#define atomic_try_cmpxchg_release atomic_try_cmpxchg |
| 445 | +#endif /* atomic_try_cmpxchg */ |
| 446 | + |
426 | 447 | /* cmpxchg_relaxed */ |
427 | 448 | #ifndef cmpxchg_relaxed |
428 | 449 | #define cmpxchg_relaxed cmpxchg |
@@ -996,6 +1017,27 @@ static inline int atomic_dec_if_positive(atomic_t *v) |
996 | 1017 | #endif |
997 | 1018 | #endif /* atomic64_cmpxchg_relaxed */ |
998 | 1019 |
|
| 1020 | +#ifndef atomic64_try_cmpxchg |
| 1021 | + |
| 1022 | +#define __atomic64_try_cmpxchg(type, _p, _po, _n) \ |
| 1023 | +({ \ |
| 1024 | + typeof(_po) __po = (_po); \ |
| 1025 | + typeof(*(_po)) __o = *__po; \ |
| 1026 | + *__po = atomic64_cmpxchg##type((_p), __o, (_n)); \ |
| 1027 | + (*__po == __o); \ |
| 1028 | +}) |
| 1029 | + |
| 1030 | +#define atomic64_try_cmpxchg(_p, _po, _n) __atomic64_try_cmpxchg(, _p, _po, _n) |
| 1031 | +#define atomic64_try_cmpxchg_relaxed(_p, _po, _n) __atomic64_try_cmpxchg(_relaxed, _p, _po, _n) |
| 1032 | +#define atomic64_try_cmpxchg_acquire(_p, _po, _n) __atomic64_try_cmpxchg(_acquire, _p, _po, _n) |
| 1033 | +#define atomic64_try_cmpxchg_release(_p, _po, _n) __atomic64_try_cmpxchg(_release, _p, _po, _n) |
| 1034 | + |
| 1035 | +#else /* atomic64_try_cmpxchg */ |
| 1036 | +#define atomic64_try_cmpxchg_relaxed atomic64_try_cmpxchg |
| 1037 | +#define atomic64_try_cmpxchg_acquire atomic64_try_cmpxchg |
| 1038 | +#define atomic64_try_cmpxchg_release atomic64_try_cmpxchg |
| 1039 | +#endif /* atomic64_try_cmpxchg */ |
| 1040 | + |
999 | 1041 | #ifndef atomic64_andnot |
1000 | 1042 | static inline void atomic64_andnot(long long i, atomic64_t *v) |
1001 | 1043 | { |
|
0 commit comments