mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
`InterlockedCompareExchange64 `(winnt.h) is used instead of gcc atomics when compiling with MSVC on Windows, but the function signatures are `InterlockedCompareExchange64(ptr int64, int64, int64)` and `InterlockedCompareExchange32(ptr int32, int32, int32)` as opposed to `(ptr T, ptr T, T)` for `__atomic_compare_exchange_n`. Passing a pointer to the expected value (parameter two) instead of the value itself causes the comparison to unconditionally fail, with stalls in threaded code using atomic comparisons. Fix the function signature for MSVC. Signed-off-by: Ryan Walklin <ryan@testtoast.com>