summaryrefslogtreecommitdiffstats
path: root/libcxx/include
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
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')
-rw-r--r--libcxx/include/__config30
-rw-r--r--libcxx/include/__locale2
-rw-r--r--libcxx/include/support/win32/support.h14
-rw-r--r--libcxx/include/type_traits4
4 files changed, 29 insertions, 21 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 7b175a15912..4f0fe1d1480 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -154,11 +154,13 @@
# define _LIBCPP_HAS_QUICK_EXIT
#endif // __NetBSD__
-#ifdef _WIN32
+#if defined(_WIN32)
+# define _LIBCPP_WIN32API 1
# define _LIBCPP_LITTLE_ENDIAN 1
# define _LIBCPP_BIG_ENDIAN 0
+# define _LIBCPP_SHORT_WCHAR 1
// Compiler intrinsics (MSVC)
-#if defined(_MSC_VER) && _MSC_VER >= 1400
+# if defined(_MSC_VER) && _MSC_VER >= 1400
# define _LIBCPP_HAS_IS_BASE_OF
# endif
# if defined(_MSC_VER) && !defined(__clang__)
@@ -167,11 +169,11 @@
# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
# endif
-# // If mingw not explicitly detected, assume using MS C runtime only.
+// If mingw not explicitly detected, assume using MS C runtime only.
# ifndef __MINGW32__
# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
# endif
-#endif // _WIN32
+#endif // defined(_WIN32)
#ifdef __sun__
# include <sys/isa_defs.h>
@@ -195,7 +197,7 @@
// including accesses to the special files under /dev. C++11's
// std::random_device is instead exposed through a NaCl syscall.
# define _LIBCPP_USING_NACL_RANDOM
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_USING_WIN32_RANDOM
#else
# define _LIBCPP_USING_DEV_RANDOM
@@ -520,8 +522,15 @@ namespace std {
#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
+#if defined(__ELF__)
+#define _LIBCPP_OBJECT_FORMAT_ELF 1
+#elif defined(__MACH__)
+#define _LIBCPP_OBJECT_FORMAT_MACHO 1
+#else
+#define _LIBCPP_OBJECT_FORMAT_COFF 1
+#endif
-#ifdef _WIN32
+#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_DLL_VIS
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
@@ -546,6 +555,7 @@ namespace std {
#define _LIBCPP_TYPE_VIS_ONLY
#define _LIBCPP_FUNC_VIS_ONLY
#define _LIBCPP_ENUM_VIS
+
#if defined(_LIBCPP_MSVC)
# define _LIBCPP_INLINE_VISIBILITY __forceinline
# define _LIBCPP_ALWAYS_INLINE __forceinline
@@ -555,7 +565,7 @@ namespace std {
# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
#endif
-#endif // _WIN32
+#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
#ifndef _LIBCPP_HIDDEN
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
@@ -778,14 +788,14 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
#endif
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \
defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
#endif
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
// Most unix variants have catopen. These are the specific ones that don't.
-#if !defined(_WIN32) && !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
+#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
#define _LIBCPP_HAS_CATOPEN 1
#endif
#endif
@@ -959,7 +969,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#endif
#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
#endif
#endif
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index 535ee165f65..3f29bc5e994 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -342,7 +342,7 @@ public:
static const mask punct = _ISpunct;
static const mask xdigit = _ISxdigit;
static const mask blank = _ISblank;
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_MSVCRT)
typedef unsigned short mask;
static const mask space = _SPACE;
static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT;
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.
}
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index e2b537799dc..db9c1d11c98 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -1681,9 +1681,9 @@ _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
// PE/COFF does not support alignment beyond 8192 (=0x2000)
-#if !defined(_WIN32)
+#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
-#endif // !_WIN32
+#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
OpenPOWER on IntegriCloud