From 8b5d1e07ced66e8ed4c3c1475feed9492467df39 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Fri, 3 Jul 2020 21:25:20 +0200 Subject: [PATCH] Fix build with MSVC in 32 bits mode --- m-core.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/m-core.h b/m-core.h index 6d342c35..f4981be7 100644 --- a/m-core.h +++ b/m-core.h @@ -1920,7 +1920,8 @@ static inline unsigned int m_core_clz64(uint64_t limb) return M_UNLIKELY (limb == 0ULL) ? sizeof (uint64_t)*CHAR_BIT : (unsigned int) __builtin_clzll(limb) - (sizeof (unsigned long long) - sizeof (uint64_t)) * CHAR_BIT; } -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64)) +// NOTE: _BitScanReverse64 is 64-bits only (not compatible 32 bits). #include static inline unsigned int m_core_clz32(uint32_t limb) { @@ -1942,6 +1943,7 @@ static inline unsigned int m_core_clz64(uint64_t limb) } #else +// Emulation layer #define M_CORE_CLZ_TAB "\010\07\06\06\05\05\05\05\04\04\04\04\04\04\04\04\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" static inline unsigned int m_core_clz32(uint32_t limb)