From 5ba4194586f3b0e892596386e87a525a2635c43b Mon Sep 17 00:00:00 2001 From: "Jurjen N. E. Bos" Date: Fri, 18 Dec 2020 17:58:24 +0100 Subject: [PATCH] Use 64 bit bsr I am determined to get this to work! --- Include/internal/pycore_bitutils.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Include/internal/pycore_bitutils.h b/Include/internal/pycore_bitutils.h index 0f87160b4e3..21eb6c62bee 100644 --- a/Include/internal/pycore_bitutils.h +++ b/Include/internal/pycore_bitutils.h @@ -186,9 +186,12 @@ _Py_bit_length_size_t(size_t x) } #elif defined(_MSC_VER) // _BitScanReverse() is documented to search 32 bits. - Py_BUILD_ASSERT(sizeof(size_t) <= 4); - unsigned long msb; + size_t msb; +#if SIZEOF_SIZE_T == 8 + if (_BitScanReverse64(&msb, x)) { +#else if (_BitScanReverse(&msb, x)) { +#endif return (int)msb + 1; } else {