summaryrefslogtreecommitdiffstats
path: root/libcxx/include/support/win32
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-01-03 21:53:51 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-01-03 21:53:51 +0000
commitb2826a1ddc761fb6abcf8d80793a20387e9dc5f6 (patch)
treeda7f2a05031e7ee3b062a6f4aac11f2b544fca8f /libcxx/include/support/win32
parent8a41319d8d805dd1a8ba85f28eb111a822c4c45b (diff)
downloadbcm5719-llvm-b2826a1ddc761fb6abcf8d80793a20387e9dc5f6.tar.gz
bcm5719-llvm-b2826a1ddc761fb6abcf8d80793a20387e9dc5f6.zip
clean up use of _WIN32
Replace the use of _WIN32 in libc++. Replace most use with a C runtime check _LIBCPP_MSVCRT or the new _LIBCPP_WIN32 to indicate that we are using the Win32 API. Use a new _LIBCPP_WCHAR_IS_UCS2 to indicate that we are on an environment that has a short wchar_t. llvm-svn: 290910
Diffstat (limited to 'libcxx/include/support/win32')
-rw-r--r--libcxx/include/support/win32/support.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/libcxx/include/support/win32/support.h b/libcxx/include/support/win32/support.h
index 6a5763b5e49..10572191341 100644
--- a/libcxx/include/support/win32/support.h
+++ b/libcxx/include/support/win32/support.h
@@ -110,10 +110,11 @@ _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(_WIN64)
+#if (defined(_M_ARM) || defined(__arm__)) || \
+ (defined(_M_AMD64) || defined(__x86_64__))
if (_BitScanForward64(&where, mask))
return static_cast<int>(where);
-#elif defined(_WIN32)
+#else
// Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
// Scan the Low Word.
if (_BitScanForward(&where, static_cast<unsigned long>(mask)))
@@ -121,8 +122,6 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask)
// Scan the High Word.
if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32)))
return static_cast<int>(where + 32); // Create a bit offset from the LSB.
-#else
-#error "Implementation of __builtin_ctzll required"
#endif
return 64;
}
@@ -152,10 +151,11 @@ _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(_WIN64)
+#if (defined(_M_ARM) || defined(__arm__)) || \
+ (defined(_M_AMD64) || defined(__x86_64__))
if (_BitScanReverse64(&where, mask))
return static_cast<int>(63 - where);
-#elif defined(_WIN32)
+#else
// Scan the high 32 bits.
if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
return static_cast<int>(63 -
@@ -163,8 +163,6 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask)
// Scan the low 32 bits.
if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
return static_cast<int>(63 - where);
-#else
-#error "Implementation of __builtin_clzll required"
#endif
return 64; // Undefined Behavior.
}
OpenPOWER on IntegriCloud