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. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290910 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user