ref: 41fb5ec5bb6d70241970dda960202c596054ad45
parent: 6153633dc641fec4f986bf3af10395b5328026c4
author: James Almer <jamrial@gmail.com>
date: Mon Oct 1 19:50:42 EDT 2018
attributes: fix clzll on 32-bit MSVC
--- a/include/common/attributes.h
+++ b/include/common/attributes.h
@@ -87,11 +87,20 @@
return (31 - leading_zero);
}
+#ifndef _M_IX86
static inline int clzll(const unsigned long long mask) {
unsigned long leading_zero = 0;
_BitScanReverse64(&leading_zero, mask);
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 */
static inline int ctz(const unsigned int mask) {
return __builtin_ctz(mask);