From b2826a1ddc761fb6abcf8d80793a20387e9dc5f6 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 3 Jan 2017 21:53:51 +0000 Subject: 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 --- libcxx/include/support/win32/support.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'libcxx/include/support/win32') 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(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(mask))) @@ -121,8 +122,6 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask) // Scan the High Word. if (_BitScanForward(&where, static_cast(mask >> 32))) return static_cast(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(63 - where); -#elif defined(_WIN32) +#else // Scan the high 32 bits. if (_BitScanReverse(&where, static_cast(mask >> 32))) return static_cast(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(mask))) return static_cast(63 - where); -#else -#error "Implementation of __builtin_clzll required" #endif return 64; // Undefined Behavior. } -- cgit v1.2.3