Use _BitScanReverse on MSVC

This commit is contained in:
Arkady Shapkin 2018-02-15 22:59:38 +03:00 committed by GitHub
parent 3af18990f5
commit d738dcc754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,10 @@
#include "../common/platform.h"
#include <brotli/types.h>
#if defined(_MSC_VER)
#include <intrin.h>
#endif
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
@ -21,6 +25,10 @@ extern "C" {
static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) {
#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_clz)
return 31u ^ (uint32_t)__builtin_clz((uint32_t)n);
#elif defined(_MSC_VER)
unsigned long where;
_BitScanReverse(&where, n);
return where;
#else
uint32_t result = 0;
while (n >>= 1) result++;