fix: only use InterlockedCompareExchangeRelease64 on LP64 systems

This commit is contained in:
Tropical 2026-03-25 19:20:18 -05:00
parent caf7128d58
commit b598aa9232

View file

@ -336,6 +336,7 @@ static inline VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer) {
static inline DWORD GetLastError(VOID) { return errno; }
#ifdef __LP64__
static inline LONG64 InterlockedCompareExchangeRelease64(
LONG64 volatile* Destination, LONG64 Exchange, LONG64 Comperand) {
LONG64 expected = Comperand;
@ -343,6 +344,15 @@ static inline LONG64 InterlockedCompareExchangeRelease64(
__ATOMIC_RELEASE, __ATOMIC_RELAXED);
return expected;
}
#else
static inline LONG64 InterlockedCompareExchangeRelease(
LONG volatile* Destination, LONG Exchange, LONG Comperand) {
LONG expected = Comperand;
__atomic_compare_exchange_n(Destination, &expected, Exchange, false,
__ATOMIC_RELEASE, __ATOMIC_RELAXED);
return expected;
}
#endif
// internal helper: convert time_t to FILETIME (100ns intervals since
// 1601-01-01)