Author: compnerd Date: Tue Jan 3 19:53:24 2017 New Revision: 290924 URL: http://llvm.org/viewvc/llvm-project?rev=290924&view=rev Log: Refactor bitscan64 check
Introduce a `_LIBCPP_HAS_BITSCAN64` macro to specify if the 64-bit variant of the bitscan family of APIs is available. This avoids duplicating the check in the support header. Modified: libcxx/trunk/include/__config libcxx/trunk/include/support/win32/support.h Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290924&r1=290923&r2=290924&view=diff ============================================================================== --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Tue Jan 3 19:53:24 2017 @@ -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__ Modified: libcxx/trunk/include/support/win32/support.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/support.h?rev=290924&r1=290923&r2=290924&view=diff ============================================================================== --- libcxx/trunk/include/support/win32/support.h (original) +++ libcxx/trunk/include/support/win32/support.h Tue Jan 3 19:53:24 2017 @@ -110,7 +110,7 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzl 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<int>(where); @@ -151,8 +151,7 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzl 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<int>(63 - where); #else _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits