mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +02:00
Add atomic compare and swap.
This commit is contained in:
@@ -7499,6 +7499,9 @@ Atomics
|
|||||||
#define ma_atomic_exchange_64(a, b) InterlockedExchange64((LONGLONG*)a, (LONGLONG)b)
|
#define ma_atomic_exchange_64(a, b) InterlockedExchange64((LONGLONG*)a, (LONGLONG)b)
|
||||||
#define ma_atomic_increment_32(a) InterlockedIncrement((LONG*)a)
|
#define ma_atomic_increment_32(a) InterlockedIncrement((LONG*)a)
|
||||||
#define ma_atomic_decrement_32(a) InterlockedDecrement((LONG*)a)
|
#define ma_atomic_decrement_32(a) InterlockedDecrement((LONG*)a)
|
||||||
|
#define ma_compare_and_swap_32(d, e, c) _InterlockedCompareExchange((LONG*)d, (LONG)e, (LONG)c)
|
||||||
|
#define ma_compare_and_swap_64(d, e, c) _InterlockedCompareExchange64((LONGLONG*)d, (LONGLONG)e, (LONGLONG)c)
|
||||||
|
#define ma_compare_and_swap_ptr(d, e, c) _InterlockedCompareExchangePointer((void*volatile*)d, (void*)e, (void*)c)
|
||||||
#else
|
#else
|
||||||
#define ma_memory_barrier() __sync_synchronize()
|
#define ma_memory_barrier() __sync_synchronize()
|
||||||
#if defined(MA_HAS_SYNC_SWAP)
|
#if defined(MA_HAS_SYNC_SWAP)
|
||||||
@@ -7513,6 +7516,9 @@ Atomics
|
|||||||
#endif
|
#endif
|
||||||
#define ma_atomic_increment_32(a) __sync_add_and_fetch(a, 1)
|
#define ma_atomic_increment_32(a) __sync_add_and_fetch(a, 1)
|
||||||
#define ma_atomic_decrement_32(a) __sync_sub_and_fetch(a, 1)
|
#define ma_atomic_decrement_32(a) __sync_sub_and_fetch(a, 1)
|
||||||
|
#define ma_compare_and_swap_32(d, e, c) __sync_val_compare_and_swap(d, e, c)
|
||||||
|
#define ma_compare_and_swap_64(d, e, c) __sync_val_compare_and_swap(d, e, c)
|
||||||
|
#define ma_compare_and_swap_ptr(d, e, c) __sync_val_compare_and_swap(d, e, c)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MA_64BIT
|
#ifdef MA_64BIT
|
||||||
|
|||||||
Reference in New Issue
Block a user