diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 537701a..52dc113 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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' }, diff --git a/include/bx/inline/cpu.inl b/include/bx/inline/cpu.inl index 2d571db..6594288 100644 --- a/include/bx/inline/cpu.inl +++ b/include/bx/inline/cpu.inl @@ -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 { diff --git a/src/bx.cpp b/src/bx.cpp index 88976b5..0fdcc9f 100644 --- a/src/bx.cpp +++ b/src/bx.cpp @@ -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; diff --git a/tests/simd_test.cpp b/tests/simd_test.cpp index 03ac8b7..fcf3458 100644 --- a/tests/simd_test.cpp +++ b/tests/simd_test.cpp @@ -1100,7 +1100,7 @@ static void intParityAll() intParity1("ftoi_sat", [](Ty a ) { return simd_f32_ftoi_sat(a); }, [](uint32_t a) { return uint32_t(refFtoiSat(bx::bitCast(a) ) ); }, true); intParity1("ftou_sat", [](Ty a ) { return simd_f32_ftou_sat(a); }, [](uint32_t a) { return refFtouSat(bx::bitCast(a) ); }, true); intParity1("f16_fromf32",[](Ty a ) { return simd_f16_fromf32(a); }, [](uint32_t a) { return uint32_t(bx::halfFromFloat(bx::bitCast(a) ) ); }, true); - intParity1("f16_tof32", [](Ty a ) { return simd_f16_tof32(a); }, [](uint32_t a) { return bx::bitCast(bx::halfToFloat(uint16_t(a & 0xffff) ) ); }, false); + intParity1("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]") diff --git a/tests/vsnprintf_test.cpp b/tests/vsnprintf_test.cpp index 0aacde1..b59982a 100644 --- a/tests/vsnprintf_test.cpp +++ b/tests/vsnprintf_test.cpp @@ -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]")