diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/stubs/hash.h | 2 | ||||
-rw-r--r-- | src/google/protobuf/stubs/port.h | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index d04a25e1..fd8ba156 100644 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -93,7 +93,7 @@ # endif // GCC <= 4.1 does not define std::tr1::hash for `long long int` or `long long unsigned int` -# if __GNUC__ == 4 && defined(__GNUC__MINOR__) && __GNUC__MINOR__ <= 1 +# if __GNUC__ == 4 && defined(__GNUC_MINOR__) && __GNUC_MINOR__ <= 1 # undef GOOGLE_PROTOBUF_HAS_TR1 # undef GOOGLE_PROTOBUF_HAVE_HASH_MAP # undef GOOGLE_PROTOBUF_HAVE_HASH_SET diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index de83def0..6b52305f 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -91,6 +91,7 @@ // These #includes are for the byte swap functions declared later on. #ifdef _MSC_VER #include <stdlib.h> // NOLINT(build/include) +#include <intrin.h> #elif defined(__APPLE__) #include <libkern/OSByteOrder.h> #elif defined(__GLIBC__) || defined(__BIONIC__) || defined(__CYGWIN__) @@ -414,12 +415,10 @@ class Bits { static uint32 Log2FloorNonZero(uint32 n) { #if defined(__GNUC__) return 31 ^ static_cast<uint32>(__builtin_clz(n)); -#elif defined(COMPILER_MSVC) && defined(_M_IX86) - _asm { - bsr ebx, n - mov n, ebx - } - return n; +#elif defined(_MSC_VER) + unsigned long where; + _BitScanReverse(&where, n); + return where; #else return Log2FloorNonZero_Portable(n); #endif @@ -434,6 +433,10 @@ class Bits { // implementation instead. #if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_USE_PORTABLE_LOG2) return 63 ^ static_cast<uint32>(__builtin_clzll(n)); +#elif defined(_MSC_VER) && defined(_M_X64) + unsigned long where; + _BitScanReverse64(&where, n); + return where; #else return Log2FloorNonZero64_Portable(n); #endif |