mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
1 changed files with 2 additions and 2 deletions
|
@ -215,7 +215,7 @@ nlz_int32(uint32_t x)
|
|||
|
||||
#elif defined(_MSC_VER) && defined(_WIN64) /* &&! defined(__AVX2__) */
|
||||
unsigned long r;
|
||||
return _BitScanReverse(&r, x) ? (int)r : 32;
|
||||
return _BitScanReverse(&r, x) ? (31 - (int)r) : 32;
|
||||
|
||||
#elif __has_builtin(__builtin_clz)
|
||||
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__) */
|
||||
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)
|
||||
if (x == 0) {
|
||||
|
|
Loading…
Reference in a new issue