Skip to content

Commit

Permalink
Fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
janweinstock committed Dec 20, 2023
1 parent 42f534c commit 0e4c46b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions include/mwr/core/atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ inline bool atomic_cas8(volatile void* ptr, void* cmp, void* val) {
false, __ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST);
#else
return _InterlockedCompareExchange8((volatile u8*)ptr, read_once<u8>(val),
read_once<u8>(cmp));
return _InterlockedCompareExchange8(
(volatile char*)ptr, read_once<char>(val), read_once<char>(cmp));
#endif
}

Expand All @@ -125,7 +125,7 @@ inline bool atomic_cas16(volatile void* ptr, void* cmp, void* val) {
__ATOMIC_SEQ_CST);
#else
return _InterlockedCompareExchange16(
(volatile u16*)ptr, read_once<u16>(val), read_once<u16>(cmp));
(volatile short*)ptr, read_once<short>(val), read_once<short>(cmp));
#endif
}

Expand All @@ -135,8 +135,8 @@ inline bool atomic_cas32(volatile void* ptr, void* cmp, void* val) {
false, __ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST);
#else
return _InterlockedCompareExchange((volatile u32*)ptr, read_once<u32>(val),
read_once<u32>(cmp));
return _InterlockedCompareExchange(
(volatile long*)ptr, read_once<u32>(long), read_once<long>(cmp));
#endif
}

Expand All @@ -146,15 +146,17 @@ inline bool atomic_cas64(volatile void* ptr, void* cmp, void* val) {
false, __ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST);
#else
return _InterlockedCompareExchange64(
(volatile u64*)ptr, read_once<u64>(val), read_once<u64>(cmp));
return _InterlockedCompareExchange64((volatile long long*)ptr,
read_once<long long>(val),
read_once<long long>(cmp));
#endif
}

inline bool atomic_cas128(volatile void* ptr, void* cmp, void* val) {
#ifdef MWR_MSVC
return InterlockedCompareExchange128((volatile LONG64*)ptr, (u64*)cmp[1],
(u64*)cmp[0], (LONG64*)val);
return _InterlockedCompareExchange128((volatile __int64*)ptr,
((__int64*)cmp)[1],
((__int64*)cmp)[0], (__int64*)val);
#else
u64 cmpl = ((u64*)cmp)[0];
u64 cmph = ((u64*)cmp)[1];
Expand Down

0 comments on commit 0e4c46b

Please sign in to comment.