Commit 41fb5ec5 authored by James Almer's avatar James Almer

attributes: fix clzll on 32-bit MSVC

parent 6153633d
...@@ -87,11 +87,20 @@ static inline int clz(const unsigned int mask) { ...@@ -87,11 +87,20 @@ static inline int clz(const unsigned int mask) {
return (31 - leading_zero); return (31 - leading_zero);
} }
#ifndef _M_IX86
static inline int clzll(const unsigned long long mask) { static inline int clzll(const unsigned long long mask) {
unsigned long leading_zero = 0; unsigned long leading_zero = 0;
_BitScanReverse64(&leading_zero, mask); _BitScanReverse64(&leading_zero, mask);
return (63 - leading_zero); return (63 - leading_zero);
} }
#else /* _M_IX86 */
static inline int clzll(const unsigned long long mask) {
if (mask >> 32)
return clz((unsigned)(mask >> 32));
else
return clz((unsigned)mask) + 32;
}
#endif /* _M_IX86 */
#else /* !_MSC_VER */ #else /* !_MSC_VER */
static inline int ctz(const unsigned int mask) { static inline int ctz(const unsigned int mask) {
return __builtin_ctz(mask); return __builtin_ctz(mask);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment