diff options
| author | 2024-10-19 11:23:02 -0400 | |
|---|---|---|
| committer | 2024-10-19 11:23:02 -0400 | |
| commit | 425c57802f6859976a4940b1d134c2a8d1be8c03 (patch) | |
| tree | 71c07a993119a6589fa7ab810100a16d2135b885 | |
| parent | 96f1ca95d5fbe8ff5bcf8802bb40d366409ea2fb (diff) | |
| download | libalabaster-425c57802f6859976a4940b1d134c2a8d1be8c03.tar.gz libalabaster-425c57802f6859976a4940b1d134c2a8d1be8c03.tar.bz2 libalabaster-425c57802f6859976a4940b1d134c2a8d1be8c03.zip | |
atomic: Add compare_and_swap()
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rw-r--r-- | include/al/atomic.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/al/atomic.h b/include/al/atomic.h index 7d070ab..594413c 100644 --- a/include/al/atomic.h +++ b/include/al/atomic.h @@ -18,6 +18,7 @@ #define al_atomic_store(T) _al_atomic_store_##T #define al_atomic_add(T) _al_atomic_add_##T #define al_atomic_sub(T) _al_atomic_sub_##T +#define al_atomic_compare_and_swap(T) _al_atomic_compare_and_swap_##T // Special case for pointers. #define _al_atomic_load_void(p, order) c89atomic_load_explicit_ptr((volatile void **)p, order) @@ -44,6 +45,10 @@ typedef f32 c89atomic_f32; static inline T al_atomic_sub(T)(atomic(T) *a, T value, int order) \ { \ return c89atomic_fetch_sub_explicit_##S(a, value, order); \ + } \ + static inline T al_atomic_compare_and_swap(T)(atomic(T) *a, T expected, T desired) \ + { \ + return c89atomic_compare_and_swap_##S(a, expected, desired); \ } #if defined C89ATOMIC_64BIT |