summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-01-04 01:53:24 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-01-04 01:53:24 +0000
commit86eebc5b658b5c2ccf2f4fbc16e8aee9880919a5 (patch)
tree0041ced3f6075c30925f3db4109ac50b288e211a
parent539e8e37039865a6e46d2e63d192c87104f1e84a (diff)
downloadbcm5719-llvm-86eebc5b658b5c2ccf2f4fbc16e8aee9880919a5.tar.gz
bcm5719-llvm-86eebc5b658b5c2ccf2f4fbc16e8aee9880919a5.zip
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. llvm-svn: 290924
-rw-r--r--libcxx/include/__config3
-rw-r--r--libcxx/include/support/win32/support.h5
2 files changed, 5 insertions, 3 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 4f0fe1d1480..bb6d998961f 100644
--- a/libcxx/include/__config
+++ b/libcxx/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/libcxx/include/support/win32/support.h b/libcxx/include/support/win32/support.h
index 10572191341..17ee1980a64 100644
--- a/libcxx/include/support/win32/support.h
+++ b/libcxx/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<int>(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<int>(63 - where);
#else
OpenPOWER on IntegriCloud