diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f62d01c60..860818a03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -356,12 +356,13 @@ jobs: strategy: fail-fast: false matrix: + arch: [x64, Win32] buildType: [Debug, Release] steps: - uses: actions/checkout@v4 - name: build run: | - cmake -B build -G "Visual Studio 17 2022" + cmake -B build -G "Visual Studio 17 2022" -A ${{matrix.arch}} cmake --build build --config ${{matrix.buildType}} --target qjs_exe cmake --build build --config ${{matrix.buildType}} --target function_source - name: stats diff --git a/cutils.h b/cutils.h index a5da60db7..26436d4f2 100644 --- a/cutils.h +++ b/cutils.h @@ -203,9 +203,16 @@ static inline int clz32(unsigned int a) static inline int clz64(uint64_t a) { #if defined(_MSC_VER) && !defined(__clang__) +#if INTPTR_MAX == INT64_MAX unsigned long index; _BitScanReverse64(&index, a); return 63 - index; +#else + if (a >> 32) + return clz32((unsigned)(a >> 32)); + else + return clz32((unsigned)a) + 32; +#endif #else return __builtin_clzll(a); #endif diff --git a/tests/test_conv.c b/tests/test_conv.c index 9761b30d0..b0678ae5c 100644 --- a/tests/test_conv.c +++ b/tests/test_conv.c @@ -94,14 +94,20 @@ static inline int clz32(unsigned int a) static inline int clz64(uint64_t a) { #if defined(_MSC_VER) && !defined(__clang__) +#if INTPTR_MAX == INT64_MAX unsigned long index; _BitScanReverse64(&index, a); return 63 - index; +#else + if (a >> 32) + return clz32((unsigned)(a >> 32)); + else + return clz32((unsigned)a) + 32; +#endif #else return __builtin_clzll(a); #endif } - // prototypes for final functions extern char const digits36[36]; size_t u32toa(char buf[minimum_length(11)], uint32_t n);