mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-12 18:30:11 +00:00
Fix internal::clzll on Win64
This commit is contained in:
parent
a81baf2904
commit
d06ff7a7e8
6
format.h
6
format.h
@ -56,18 +56,18 @@ inline uint32_t clz(uint32_t x) {
|
|||||||
return 31 - r;
|
return 31 - r;
|
||||||
}
|
}
|
||||||
# define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n)
|
# define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n)
|
||||||
inline uint32_t clzll(uint64_t n) {
|
inline uint32_t clzll(uint64_t x) {
|
||||||
unsigned long r = 0;
|
unsigned long r = 0;
|
||||||
# ifdef _WIN64
|
# ifdef _WIN64
|
||||||
# pragma intrinsic(_BitScanReverse64)
|
# pragma intrinsic(_BitScanReverse64)
|
||||||
_BitScanReverse64(&r, x);
|
_BitScanReverse64(&r, x);
|
||||||
# else
|
# else
|
||||||
// Scan the high 32 bits.
|
// Scan the high 32 bits.
|
||||||
if (_BitScanReverse(&r, static_cast<uint32_t>(n >> 32)))
|
if (_BitScanReverse(&r, static_cast<uint32_t>(x >> 32)))
|
||||||
return 63 - (r + 32);
|
return 63 - (r + 32);
|
||||||
|
|
||||||
// Scan the low 32 bits.
|
// Scan the low 32 bits.
|
||||||
_BitScanReverse(&r, static_cast<uint32_t>(n));
|
_BitScanReverse(&r, static_cast<uint32_t>(x));
|
||||||
# endif
|
# endif
|
||||||
return 63 - r;
|
return 63 - r;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user