Fixed MSVC 32-bit x86 build, and added it to CI. (#455)

This commit is contained in:
Branimir Karadžić
2026-10-11 20:08:19 -07:00
committed by GitHub
parent 36b2b6943f
commit 326bddbac8
5 changed files with 29 additions and 10 deletions

View File

@@ -61,8 +61,10 @@ extern "C" void* _InterlockedExchangePointer(void* volatile* _ptr, void* _value)
extern "C" long _InterlockedExchange(long volatile* _ptr, long _value);
# pragma intrinsic(_InterlockedExchange)
# if !(BX_CPU_X86 && BX_ARCH_32BIT)
extern "C" int64_t _InterlockedExchange64(int64_t volatile* _ptr, int64_t _value);
# pragma intrinsic(_InterlockedExchange64)
# pragma intrinsic(_InterlockedExchange64)
# endif // !(BX_CPU_X86 && BX_ARCH_32BIT)
extern "C" void* _InterlockedCompareExchangePointer(void* volatile* _ptr, void* _exchange, void* _comparand);
# pragma intrinsic(_InterlockedCompareExchangePointer)
@@ -410,7 +412,20 @@ namespace bx
#if BX_COMPILER_MSVC
if constexpr (8 == sizeof(Ty) )
{
# if BX_CPU_X86 && BX_ARCH_32BIT
int64_t oldVal;
int64_t newVal = *(int64_t volatile*)_ptr;
do
{
oldVal = newVal;
newVal = _InterlockedCompareExchange64( (volatile int64_t*)_ptr, int64_t(_new), oldVal);
} while (oldVal != newVal);
return Ty(oldVal);
# else
return Ty(_InterlockedExchange64( (volatile int64_t*)_ptr, int64_t(_new) ) );
# endif // BX_CPU_X86 && BX_ARCH_32BIT
}
else
{