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. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290924 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -173,6 +173,9 @@
|
|||||||
# ifndef __MINGW32__
|
# ifndef __MINGW32__
|
||||||
# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
|
# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
|
||||||
# endif
|
# endif
|
||||||
|
# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
|
||||||
|
# define _LIBCPP_HAS_BITSCAN64
|
||||||
|
# endif
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
#ifdef __sun__
|
#ifdef __sun__
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask)
|
|||||||
unsigned long where;
|
unsigned long where;
|
||||||
// Search from LSB to MSB for first set bit.
|
// Search from LSB to MSB for first set bit.
|
||||||
// Returns zero if no set bit is found.
|
// 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__))
|
(defined(_M_AMD64) || defined(__x86_64__))
|
||||||
if (_BitScanForward64(&where, mask))
|
if (_BitScanForward64(&where, mask))
|
||||||
return static_cast<int>(where);
|
return static_cast<int>(where);
|
||||||
@@ -151,8 +151,7 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask)
|
|||||||
unsigned long where;
|
unsigned long where;
|
||||||
// BitScanReverse scans from MSB to LSB for first set bit.
|
// BitScanReverse scans from MSB to LSB for first set bit.
|
||||||
// Returns 0 if no set bit is found.
|
// Returns 0 if no set bit is found.
|
||||||
#if (defined(_M_ARM) || defined(__arm__)) || \
|
#if defined(_LIBCPP_HAS_BITSCAN64)
|
||||||
(defined(_M_AMD64) || defined(__x86_64__))
|
|
||||||
if (_BitScanReverse64(&where, mask))
|
if (_BitScanReverse64(&where, mask))
|
||||||
return static_cast<int>(63 - where);
|
return static_cast<int>(63 - where);
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user