diff --git a/include/__config b/include/__config index 4f0fe1d14..bb6d99896 100644 --- a/include/__config +++ b/include/__config @@ -173,6 +173,9 @@ # ifndef __MINGW32__ # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif +# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) +# define _LIBCPP_HAS_BITSCAN64 +# endif #endif // defined(_WIN32) #ifdef __sun__ diff --git a/include/support/win32/support.h b/include/support/win32/support.h index 105721913..17ee1980a 100644 --- a/include/support/win32/support.h +++ b/include/support/win32/support.h @@ -110,7 +110,7 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask) unsigned long where; // Search from LSB to MSB for first set bit. // Returns zero if no set bit is found. -#if (defined(_M_ARM) || defined(__arm__)) || \ +#if defined(_LIBCPP_HAS_BITSCAN64) (defined(_M_AMD64) || defined(__x86_64__)) if (_BitScanForward64(&where, mask)) return static_cast(where); @@ -151,8 +151,7 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask) unsigned long where; // BitScanReverse scans from MSB to LSB for first set bit. // Returns 0 if no set bit is found. -#if (defined(_M_ARM) || defined(__arm__)) || \ - (defined(_M_AMD64) || defined(__x86_64__)) +#if defined(_LIBCPP_HAS_BITSCAN64) if (_BitScanReverse64(&where, mask)) return static_cast(63 - where); #else