fix Windows breakage
Fixing typo revealed that _BitScanReverse is BSR, which behaves differently than LZCNT. What we want here is LZCNT so we have to emulate.
This commit is contained in:
parent
db0398dc04
commit
7fed7eb50b
Notes:
git
2020-01-10 21:17:38 +09:00
@ -215,7 +215,7 @@ nlz_int32(uint32_t x)
|
|||||||
|
|
||||||
#elif defined(_MSC_VER) && defined(_WIN64) /* &&! defined(__AVX2__) */
|
#elif defined(_MSC_VER) && defined(_WIN64) /* &&! defined(__AVX2__) */
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
return _BitScanReverse(&r, x) ? (int)r : 32;
|
return _BitScanReverse(&r, x) ? (31 - (int)r) : 32;
|
||||||
|
|
||||||
#elif __has_builtin(__builtin_clz)
|
#elif __has_builtin(__builtin_clz)
|
||||||
STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT == 32);
|
STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT == 32);
|
||||||
@ -244,7 +244,7 @@ nlz_int64(uint64_t x)
|
|||||||
|
|
||||||
#elif defined(_MSC_VER) && defined(_WIN64) /* &&! defined(__AVX2__) */
|
#elif defined(_MSC_VER) && defined(_WIN64) /* &&! defined(__AVX2__) */
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
return _BitScanReverse64(&r, x) ? (unsigned int)r : 64;
|
return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64;
|
||||||
|
|
||||||
#elif __has_builtin(__builtin_clzl)
|
#elif __has_builtin(__builtin_clzl)
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user