Commit: 7a3cbb0bd3f3609f5c7ae5c9dcef1924efc23a60
Parent: 99d60056c9a84060bc2209934205622a11dbd40c
Author: Randy Palamar
Date: Mon, 9 Jun 2025 11:21:04 -0600
intrisics: use _InterlockedExchangeAdd on windows
this intrisic does what I actually wanted which is to return the old value
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/intrinsics.c b/intrinsics.c
@@ -30,8 +30,8 @@
#define atomic_load_u64(ptr) *((volatile u64 *)(ptr))
#define atomic_load_u32(ptr) *((volatile u32 *)(ptr))
#define atomic_and_u64(ptr, n) _InterlockedAnd64((volatile u64 *)(ptr), (n))
- #define atomic_add_u64(ptr, n) _InterlockedAdd64((volatile u64 *)(ptr), (n))
- #define atomic_add_u32(ptr, n) _InterlockedAdd((volatile u32 *)(ptr), (n))
+ #define atomic_add_u64(ptr, n) _InterlockedExchangeAdd64((volatile u64 *)(ptr), (n))
+ #define atomic_add_u32(ptr, n) _InterlockedExchangeAdd((volatile u32 *)(ptr), (n))
#define atomic_cas_u64(ptr, cptr, n) (_InterlockedCompareExchange64((volatile u64 *)(ptr), *(cptr), (n)) == *(cptr))
#define atomic_cas_u32(ptr, cptr, n) (_InterlockedCompareExchange((volatile u32 *)(ptr), *(cptr), (n)) == *(cptr))