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

@@ -16,6 +16,8 @@ jobs:
include: [
{ config: Debug, platform: x64, runs-on: windows-latest, bindir: 'win64_vs2022', genie-action: 'vs2022', solution-ext: 'sln' },
{ config: Release, platform: x64, runs-on: windows-latest, bindir: 'win64_vs2022', genie-action: 'vs2022', solution-ext: 'sln' },
{ config: Debug, platform: Win32, runs-on: windows-latest, bindir: 'win32_vs2022', genie-action: 'vs2022', solution-ext: 'sln' },
{ config: Release, platform: Win32, runs-on: windows-latest, bindir: 'win32_vs2022', genie-action: 'vs2022', solution-ext: 'sln' },
{ config: Debug, platform: ARM64, runs-on: windows-11-arm, bindir: 'arm64_vs2022', genie-action: 'vs2022', solution-ext: 'sln' },
{ config: Release, platform: ARM64, runs-on: windows-11-arm, bindir: 'arm64_vs2022', genie-action: 'vs2022', solution-ext: 'sln' },
# { config: Debug, platform: x64, bindir: 'win64_vs2026', genie-action: 'vs2026', solution-ext: 'slnx' },

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
{

View File

@@ -114,8 +114,13 @@ namespace bx
constexpr size_t kSimdSize = sizeof(SimdT);
#if BX_COMPILER_MSVC
# if BX_CPU_X86 && BX_ARCH_32BIT
typedef uint32_t UnalignedU32;
typedef uint64_t UnalignedU64;
# else
typedef __unaligned uint32_t UnalignedU32;
typedef __unaligned uint64_t UnalignedU64;
# endif // BX_CPU_X86 && BX_ARCH_32BIT
#else
typedef uint32_t __attribute__( (aligned(1), may_alias) ) UnalignedU32;
typedef uint64_t __attribute__( (aligned(1), may_alias) ) UnalignedU64;

View File

@@ -1100,7 +1100,7 @@ static void intParityAll()
intParity1<Ty>("ftoi_sat", [](Ty a ) { return simd_f32_ftoi_sat(a); }, [](uint32_t a) { return uint32_t(refFtoiSat(bx::bitCast<float>(a) ) ); }, true);
intParity1<Ty>("ftou_sat", [](Ty a ) { return simd_f32_ftou_sat(a); }, [](uint32_t a) { return refFtouSat(bx::bitCast<float>(a) ); }, true);
intParity1<Ty>("f16_fromf32",[](Ty a ) { return simd_f16_fromf32(a); }, [](uint32_t a) { return uint32_t(bx::halfFromFloat(bx::bitCast<float>(a) ) ); }, true);
intParity1<Ty>("f16_tof32", [](Ty a ) { return simd_f16_tof32(a); }, [](uint32_t a) { return bx::bitCast<uint32_t>(bx::halfToFloat(uint16_t(a & 0xffff) ) ); }, false);
intParity1<Ty>("f16_tof32", [](Ty a ) { return simd_f16_tof32(a); }, [](uint32_t a) { return bx::simd_f16_tof32_ni(bx::simd32_splat(a & 0xffff) ).u32; }, false);
}
TEST_CASE("simd_int_scalar_parity", "[simd]")

View File

@@ -344,14 +344,11 @@ TEST_CASE("Format %td", "[string][printf]")
REQUIRE(test("-1", "%td", size) );
if constexpr (4 == sizeof(ptrdiff_t) )
{
REQUIRE(test("-1073741824", "%td", ptrdiff_t(3221225472) ) );
}
else
{
REQUIRE(test("3221225472", "%td", ptrdiff_t(3221225472) ) );
}
#if BX_ARCH_32BIT
REQUIRE(test("-1073741824", "%td", ptrdiff_t(-1073741824) ) );
#else
REQUIRE(test("3221225472", "%td", ptrdiff_t(3221225472) ) );
#endif // BX_ARCH_32BIT
}
TEST_CASE("Format %n", "[string][printf]")