From 27701c0dd5fc30d0eb8041e4f1be3b4bfa164e75 Mon Sep 17 00:00:00 2001 From: Ruben Valls Date: Mon, 20 Jun 2022 19:51:52 +0200 Subject: Fix mingw atomics (#1601) * Fixes compiling on Windows with Mingw Fixes the build error: "InterlockedDecrementAcquire64 not defined" on Mingw * fixes semantics of InterlockedDecrementRelease64 on Mingw From Microsoft docs, InterlockedDecrementRelease64 returns the resulting decremented value. The equivalent function on Mingw is `__atomic_sub_fetch`, not `__atomic_fetch_sub` (which returns the previous value). --- src/platform/windows/win_thread.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index 652a754d..67ff60b2 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -26,8 +26,10 @@ static pfnSetThreadDescription set_thread_desc; __atomic_add_fetch(a, b, __ATOMIC_RELAXED) #define InterlockedIncrementAcquire64(a) \ __atomic_add_fetch(a, 1, __ATOMIC_ACQUIRE) +#define InterlockedDecrementAcquire64(a) \ + __atomic_sub_fetch(a, 1, __ATOMIC_ACQUIRE) #define InterlockedDecrementRelease64(a) \ - __atomic_fetch_sub(a, 1, __ATOMIC_RELEASE) + __atomic_sub_fetch(a, 1, __ATOMIC_RELEASE) #endif #include -- cgit v1.2.3-70-g09d2