diff options
| author | Ruben Valls <rubenvalls@theembedded.engineer> | 2022-06-20 19:51:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-20 10:51:52 -0700 |
| commit | 27701c0dd5fc30d0eb8041e4f1be3b4bfa164e75 (patch) | |
| tree | 7bcd5900f65231a23fb26377002aaba6bc82eb46 /src | |
| parent | 41ce9fbfd7a396816dab08dcb0284bab4329c622 (diff) | |
| download | nng-27701c0dd5fc30d0eb8041e4f1be3b4bfa164e75.tar.gz nng-27701c0dd5fc30d0eb8041e4f1be3b4bfa164e75.tar.bz2 nng-27701c0dd5fc30d0eb8041e4f1be3b4bfa164e75.zip | |
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).
Diffstat (limited to 'src')
| -rw-r--r-- | src/platform/windows/win_thread.c | 4 |
1 files changed, 3 insertions, 1 deletions
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 <stdlib.h> |
