| Index: sky/engine/wtf/BitwiseOperations.h
|
| diff --git a/sky/engine/wtf/BitwiseOperations.h b/sky/engine/wtf/BitwiseOperations.h
|
| index 41c14acde04338fc8d8990d24aa2e161fd25649e..4808efeda69644639885964bba564a44a2477001 100644
|
| --- a/sky/engine/wtf/BitwiseOperations.h
|
| +++ b/sky/engine/wtf/BitwiseOperations.h
|
| @@ -42,9 +42,32 @@
|
|
|
| #include <stdint.h>
|
|
|
| +#if COMPILER(MSVC)
|
| +#include <intrin.h>
|
| +#endif
|
| +
|
| namespace WTF {
|
|
|
| -#if COMPILER(GCC)
|
| +#if COMPILER(MSVC)
|
| +
|
| +ALWAYS_INLINE uint32_t countLeadingZeros32(uint32_t x)
|
| +{
|
| + unsigned long index;
|
| + return LIKELY(_BitScanReverse(&index, x)) ? (31 - index) : 32;
|
| +}
|
| +
|
| +#if CPU(64BIT)
|
| +
|
| +// MSVC only supplies _BitScanForward64 when building for a 64-bit target.
|
| +ALWAYS_INLINE uint64_t countLeadingZeros64(uint64_t x)
|
| +{
|
| + unsigned long index;
|
| + return LIKELY(_BitScanReverse64(&index, x)) ? (63 - index) : 64;
|
| +}
|
| +
|
| +#endif
|
| +
|
| +#elif COMPILER(GCC)
|
|
|
| // This is very annoying. __builtin_clz has undefined behaviour for an input of
|
| // 0, even though these's clearly a return value that makes sense, and even
|
|
|