mirror of
https://github.com/google/brotli.git
synced 2024-11-21 19:20:09 +00:00
Use _BitScanReverse on MSVC
This commit is contained in:
parent
3af18990f5
commit
d738dcc754
@ -14,6 +14,10 @@
|
|||||||
#include "../common/platform.h"
|
#include "../common/platform.h"
|
||||||
#include <brotli/types.h>
|
#include <brotli/types.h>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__cplusplus) || defined(c_plusplus)
|
#if defined(__cplusplus) || defined(c_plusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -21,6 +25,10 @@ extern "C" {
|
|||||||
static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) {
|
static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) {
|
||||||
#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_clz)
|
#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_clz)
|
||||||
return 31u ^ (uint32_t)__builtin_clz((uint32_t)n);
|
return 31u ^ (uint32_t)__builtin_clz((uint32_t)n);
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
unsigned long where;
|
||||||
|
_BitScanReverse(&where, n);
|
||||||
|
return where;
|
||||||
#else
|
#else
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
while (n >>= 1) result++;
|
while (n >>= 1) result++;
|
||||||
|
Loading…
Reference in New Issue
Block a user