merge libc++ 6.0.0 (bump lib major); ok patrick@, kettenis@
authorrobert <robert@openbsd.org>
Tue, 11 Sep 2018 18:29:53 +0000 (18:29 +0000)
committerrobert <robert@openbsd.org>
Tue, 11 Sep 2018 18:29:53 +0000 (18:29 +0000)
30 files changed:
lib/libcxx/Makefile
lib/libcxx/include/__config
lib/libcxx/include/__locale
lib/libcxx/include/__refstring [deleted file]
lib/libcxx/include/__undef___deallocate [deleted file]
lib/libcxx/include/__undef_min_max [deleted file]
lib/libcxx/include/cstdio
lib/libcxx/include/stdio.h
lib/libcxx/include/support/newlib/xlocale.h
lib/libcxx/include/support/win32/limits_win32.h [deleted file]
lib/libcxx/include/support/win32/locale_mgmt_win32.h [deleted file]
lib/libcxx/include/support/win32/math_win32.h [deleted file]
lib/libcxx/include/support/win32/support.h [deleted file]
lib/libcxx/lib/buildit [deleted file]
lib/libcxx/shlib_version
lib/libcxx/src/debug.cpp
lib/libcxx/src/support/solaris/xlocale.c [deleted file]
lib/libcxx/src/thread.cpp
lib/libcxx/utils/gen_link_script/gen_link_script.py [deleted file]
lib/libcxx/utils/not/not.py [deleted file]
lib/libcxx/utils/sym_check/linux_blacklist.txt [deleted file]
lib/libcxx/utils/sym_check/osx_blacklist.txt [deleted file]
lib/libcxx/utils/sym_check/sym_check/__init__.py [deleted file]
lib/libcxx/utils/sym_check/sym_check/diff.py [deleted file]
lib/libcxx/utils/sym_check/sym_check/extract.py [deleted file]
lib/libcxx/utils/sym_check/sym_check/match.py [deleted file]
lib/libcxx/utils/sym_check/sym_check/util.py [deleted file]
lib/libcxx/utils/sym_check/sym_diff.py [deleted file]
lib/libcxx/utils/sym_check/sym_extract.py [deleted file]
lib/libcxx/utils/sym_check/sym_match.py [deleted file]

index 779f31a..f65f023 100644 (file)
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.6 2017/04/17 15:53:21 kettenis Exp $
+# $OpenBSD: Makefile,v 1.7 2018/09/11 18:29:53 robert Exp $
 
 .include <bsd.own.mk>
 
@@ -19,32 +19,37 @@ CXXINCLUDEDIR=      /usr/include/c++/v1
 
 LIB=           c++
 
-SRCS+=         algorithm.cpp\
-               any.cpp\
-               bind.cpp\
-               chrono.cpp\
-               condition_variable.cpp\
-               debug.cpp\
-               exception.cpp\
-               future.cpp\
-               hash.cpp\
-               ios.cpp\
-               iostream.cpp\
-               locale.cpp\
-               memory.cpp\
-               mutex.cpp\
-               new.cpp\
-               random.cpp\
-               regex.cpp\
-               shared_mutex.cpp\
-               stdexcept.cpp\
-               string.cpp\
-               strstream.cpp\
-               system_error.cpp\
-               thread.cpp\
-               typeinfo.cpp\
-               utility.cpp\
-               valarray.cpp
+
+SRCS+=         algorithm.cpp \
+               any.cpp \
+               bind.cpp \
+               chrono.cpp \
+               condition_variable.cpp \
+               debug.cpp \
+               exception.cpp \
+               functional.cpp \
+               future.cpp \
+               hash.cpp \
+               ios.cpp \
+               iostream.cpp \
+               locale.cpp \
+               memory.cpp \
+               mutex.cpp \
+               new.cpp \
+               optional.cpp \
+               random.cpp \
+               regex.cpp \
+               shared_mutex.cpp \
+               stdexcept.cpp \
+               string.cpp \
+               strstream.cpp \
+               system_error.cpp \
+               thread.cpp \
+               typeinfo.cpp \
+               utility.cpp \
+               valarray.cpp \
+               variant.cpp \
+               vector.cpp
 
 CPPFLAGS+=     -DLIBCXXABI -I${HDRDIR} \
                -DLIBCXX_BUILDING_LIBCXXABI -I${AHDRDIR} -I${UHDRDIR}
@@ -53,119 +58,129 @@ CXXFLAGS+=        -nostdlib -nostdinc++
 CXXFLAGS+=     -std=c++11
 .endif
 
-STD_HEADERS=   __bit_reference\
-               __bsd_locale_defaults.h\
-               __bsd_locale_fallbacks.h\
-               __config\
-               __debug\
-               __functional_03\
-               __functional_base\
-               __functional_base_03\
-               __hash_table\
-               __locale\
-               __mutex_base\
-               __nullptr\
-               __refstring\
-               __split_buffer\
-               __sso_allocator\
-               __std_stream\
-               __threading_support\
-               __tree\
-               __tuple\
-               __undef___deallocate\
-               __undef_min_max\
-               algorithm\
-               array\
-               atomic\
-               bitset\
-               cassert\
-               ccomplex\
-               cctype\
-               cerrno\
-               cfenv\
-               cfloat\
-               chrono\
-               cinttypes\
-               ciso646\
-               climits\
-               clocale\
-               cmath\
-               codecvt\
-               complex\
-               complex.h\
-               condition_variable\
-               csetjmp\
-               csignal\
-               cstdarg\
-               cstdbool\
-               cstddef\
-               cstdint\
-               cstdio\
-               cstdlib\
-               cstring\
-               ctgmath\
-               ctime\
-               ctype.h\
-               cwchar\
-               cwctype\
-               deque\
-               errno.h\
-               exception\
-               float.h\
-               forward_list\
-               fstream\
-               functional\
-               future\
-               initializer_list\
-               inttypes.h\
-               iomanip\
-               ios\
-               iosfwd\
-               iostream\
-               istream\
-               iterator\
-               limits\
-               list\
-               locale\
-               map\
-               math.h\
-               memory\
-               mutex\
-               new\
-               numeric\
-               ostream\
-               queue\
-               random\
-               ratio\
-               regex\
-               scoped_allocator\
-               set\
-               setjmp.h\
-               shared_mutex\
-               sstream\
-               stack\
-               stdbool.h\
-               stddef.h\
-               stdexcept\
-               stdio.h\
-               stdlib.h\
-               streambuf\
-               string\
-               string.h\
-               strstream\
-               system_error\
-               tgmath.h\
-               thread\
-               tuple\
-               type_traits\
-               typeindex\
-               typeinfo\
-               unordered_map\
-               unordered_set\
-               utility\
-               valarray\
-               vector\
-               wchar.h\
+
+STD_HEADERS=   __bit_reference \
+               __bsd_locale_defaults.h \
+               __bsd_locale_fallbacks.h \
+               __config \
+               __config_site.in \
+               __debug \
+               __functional_03 \
+               __functional_base \
+               __functional_base_03 \
+               __hash_table \
+               __libcpp_version \
+               __locale \
+               __mutex_base \
+               __nullptr \
+               __split_buffer \
+               __sso_allocator \
+               __std_stream \
+               __string \
+               __threading_support \
+               __tree \
+               __tuple \
+               __undef_macros \
+               algorithm \
+               any \
+               array \
+               atomic \
+               bitset \
+               cassert \
+               ccomplex \
+               cctype \
+               cerrno \
+               cfenv \
+               cfloat \
+               chrono \
+               cinttypes \
+               ciso646 \
+               climits \
+               clocale \
+               cmath \
+               codecvt \
+               complex \
+               complex.h \
+               condition_variable \
+               csetjmp \
+               csignal \
+               cstdarg \
+               cstdbool \
+               cstddef \
+               cstdint \
+               cstdio \
+               cstdlib \
+               cstring \
+               ctgmath \
+               ctime \
+               ctype.h \
+               cwchar \
+               cwctype \
+               deque \
+               errno.h \
+               exception \
+               float.h \
+               forward_list \
+               fstream \
+               functional \
+               future \
+               initializer_list \
+               inttypes.h \
+               iomanip \
+               ios \
+               iosfwd \
+               iostream \
+               istream \
+               iterator \
+               limits \
+               limits.h \
+               list \
+               locale \
+               locale.h \
+               map \
+               math.h \
+               memory \
+               module.modulemap \
+               mutex \
+               new \
+               numeric \
+               optional \
+               ostream \
+               queue \
+               random \
+               ratio \
+               regex \
+               scoped_allocator \
+               set \
+               setjmp.h \
+               shared_mutex \
+               sstream \
+               stack \
+               stdbool.h \
+               stddef.h \
+               stdexcept \
+               stdint.h \
+               stdio.h \
+               stdlib.h \
+               streambuf \
+               string \
+               string.h \
+               string_view \
+               strstream \
+               system_error \
+               tgmath.h \
+               thread \
+               tuple \
+               type_traits \
+               typeindex \
+               typeinfo \
+               unordered_map \
+               unordered_set \
+               utility \
+               valarray \
+               variant \
+               vector \
+               wchar.h \
                wctype.h
 
 .for hdr in ${STD_HEADERS}
@@ -182,33 +197,36 @@ EXT+=             ${hdr} ${HDRDIR}/ext/${hdr}
 .endfor
 EXTDIR=                ${CXXINCLUDEDIR}/ext
 
-EXP_HEADERS=   __config\
-               __memory\
-               algorithm\
-               any\
-               chrono\
-               deque\
-               dynarray\
-               filesystem\
-               forward_list\
-               functional\
-               iterator\
-               list\
-               map\
-               memory_resource\
-               optional\
-               propagate_const\
-               ratio\
-               regex\
-               set\
-               string\
-               string_view\
-               system_error\
-               tuple\
-               type_traits\
-               unordered_map\
-               unordered_set\
-               utility\
+
+EXP_HEADERS=   __config \
+               __memory \
+               algorithm \
+               any \
+               chrono \
+               coroutine \
+               deque \
+               dynarray \
+               filesystem \
+               forward_list \
+               functional \
+               iterator \
+               list \
+               map \
+               memory_resource \
+               numeric \
+               optional \
+               propagate_const \
+               ratio \
+               regex \
+               set \
+               string \
+               string_view \
+               system_error \
+               tuple \
+               utility \
+               type_traits \
+               unordered_map \
+               unordered_set \
                vector
 
 .for hdr in ${EXP_HEADERS}
index 227fc4a..4be3d2c 100644 (file)
 #define _LIBCPP_CONFIG
 
 #if defined(_MSC_VER) && !defined(__clang__)
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #endif
+#endif
 
 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #pragma GCC system_header
 
 #ifdef __GNUC__
 #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
+// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme
+// introduced in GCC 5.0.
+#define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
 #else
 #define _GNUC_VER 0
+#define _GNUC_VER_NEW 0
 #endif
 
-#define _LIBCPP_VERSION 3900
+#define _LIBCPP_VERSION 6000
 
 #ifndef _LIBCPP_ABI_VERSION
 #define _LIBCPP_ABI_VERSION 1
 #endif
 
+#if defined(__ELF__)
+#define _LIBCPP_OBJECT_FORMAT_ELF   1
+#elif defined(__MACH__)
+#define _LIBCPP_OBJECT_FORMAT_MACHO 1
+#elif defined(_WIN32)
+#define _LIBCPP_OBJECT_FORMAT_COFF  1
+#elif defined(__wasm__)
+#define _LIBCPP_OBJECT_FORMAT_WASM  1
+#else
+#error Unknown object file format
+#endif
+
 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
-// Change short string represention so that string data starts at offset 0,
+// Change short string representation so that string data starts at offset 0,
 // improving its alignment in some cases.
 #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 // Fix deque iterator type in order to support incomplete types.
 #define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
-// Fix undefined behavior in how std::list stores it's linked nodes.
+// Fix undefined behavior in how std::list stores its linked nodes.
 #define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
 // Fix undefined behavior in  how __tree stores its end and parent nodes.
 #define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
+// Fix undefined behavior in how __hash_table stores its pointer types.
+#define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
 #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
 #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
-#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
+// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
+// provided under the alternate keyword __nullptr, which changes the mangling
+// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
+#define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
+// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
+// instead of as a class simulating an enum. If this option is enabled
+// `pointer_safety` and `get_pointer_safety()` will no longer be available
+// in C++03.
+#define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+// Define a key function for `bad_function_call` in the library, to centralize
+// its vtable and typeinfo to libc++ rather than having all other libraries
+// using that class define their own copies.
+#define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
+#define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+// Use the smallest possible integer type to represent the index of the variant.
+// Previously libc++ used "unsigned int" exclusivly.
+#define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
 #elif _LIBCPP_ABI_VERSION == 1
+#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+// Enable compiling copies of now inline methods into the dylib to support
+// applications compiled against older libraries. This is unnecessary with
+// COFF dllexport semantics, since dllexport forces a non-inline definition
+// of inline functions to be emitted anyway. Our own non-inline copy would
+// conflict with the dllexport-emitted copy, so we disable it.
+#define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
+#endif
 // Feature macros for disabling pre ABI v1 features. All of these options
 // are deprecated.
 #if defined(__FreeBSD__)
 
 #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
 
+#if __cplusplus < 201103L
+#define _LIBCPP_CXX03_LANG
+#endif
 
 #ifndef __has_attribute
 #define __has_attribute(__x) 0
 #ifndef __has_feature
 #define __has_feature(__x) 0
 #endif
+#ifndef __has_cpp_attribute
+#define __has_cpp_attribute(__x) 0
+#endif
 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
 // the compiler and '1' otherwise.
 #ifndef __is_identifier
 #define __is_identifier(__x) 1
 #endif
+#ifndef __has_declspec_attribute
+#define __has_declspec_attribute(__x) 0
+#endif
 
+#define __has_keyword(__x) !(__is_identifier(__x))
+
+#ifdef __has_include
+#define __libcpp_has_include(__x) __has_include(__x)
+#else
+#define __libcpp_has_include(__x) 0
+#endif
+
+#if defined(__clang__)
+#define _LIBCPP_COMPILER_CLANG
+# ifndef __apple_build_version__
+#   define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
+# endif
+#elif defined(__GNUC__)
+#define _LIBCPP_COMPILER_GCC
+#elif defined(_MSC_VER)
+#define _LIBCPP_COMPILER_MSVC
+#elif defined(__IBMCPP__)
+#define _LIBCPP_COMPILER_IBM
+#endif
+
+#ifndef _LIBCPP_CLANG_VER
+#define _LIBCPP_CLANG_VER 0
+#endif
+
+// FIXME: ABI detection should be done via compiler builtin macros. This
+// is just a placeholder until Clang implements such macros. For now assume
+// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
+// and allow the user to explicitly specify the ABI to handle cases where this
+// heuristic falls short.
+#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
+# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
+#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
+# define _LIBCPP_ABI_ITANIUM
+#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
+# define _LIBCPP_ABI_MICROSOFT
+#else
+# if defined(_WIN32) && defined(_MSC_VER)
+#  define _LIBCPP_ABI_MICROSOFT
+# else
+#  define _LIBCPP_ABI_ITANIUM
+# endif
+#endif
+
+// Need to detect which libc we're using if we're on Linux.
+#if defined(__linux__)
+#include <features.h>
+#if !defined(__GLIBC_PREREQ)
+#define __GLIBC_PREREQ(a, b) 0
+#endif // !defined(__GLIBC_PREREQ)
+#endif // defined(__linux__)
 
 #ifdef __LITTLE_ENDIAN__
 #if __LITTLE_ENDIAN__
-#define _LIBCPP_LITTLE_ENDIAN 1
-#define _LIBCPP_BIG_ENDIAN    0
+#define _LIBCPP_LITTLE_ENDIAN
 #endif  // __LITTLE_ENDIAN__
 #endif  // __LITTLE_ENDIAN__
 
 #ifdef __BIG_ENDIAN__
 #if __BIG_ENDIAN__
-#define _LIBCPP_LITTLE_ENDIAN 0
-#define _LIBCPP_BIG_ENDIAN    1
+#define _LIBCPP_BIG_ENDIAN
 #endif  // __BIG_ENDIAN__
 #endif  // __BIG_ENDIAN__
 
 #ifdef __BYTE_ORDER__
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-#define _LIBCPP_LITTLE_ENDIAN 1
-#define _LIBCPP_BIG_ENDIAN 0
+#define _LIBCPP_LITTLE_ENDIAN
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-#define _LIBCPP_LITTLE_ENDIAN 0
-#define _LIBCPP_BIG_ENDIAN 1
+#define _LIBCPP_BIG_ENDIAN
 #endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 #endif // __BYTE_ORDER__
 
 #ifdef __FreeBSD__
 # include <sys/endian.h>
 #  if _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN 1
-#   define _LIBCPP_BIG_ENDIAN    0
+#   define _LIBCPP_LITTLE_ENDIAN
 # else  // _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN 0
-#   define _LIBCPP_BIG_ENDIAN    1
+#   define _LIBCPP_BIG_ENDIAN
 # endif  // _BYTE_ORDER == _LITTLE_ENDIAN
 # ifndef __LONG_LONG_SUPPORTED
 #  define _LIBCPP_HAS_NO_LONG_LONG
 #ifdef __NetBSD__
 # include <sys/endian.h>
 #  if _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN 1
-#   define _LIBCPP_BIG_ENDIAN    0
+#   define _LIBCPP_LITTLE_ENDIAN
 # else  // _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN 0
-#   define _LIBCPP_BIG_ENDIAN    1
+#   define _LIBCPP_BIG_ENDIAN
 # endif  // _BYTE_ORDER == _LITTLE_ENDIAN
 # define _LIBCPP_HAS_QUICK_EXIT
 #endif  // __NetBSD__
 #ifdef __OpenBSD__
 # include <sys/_endian.h>
 #  if _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN 1
-#   define _LIBCPP_BIG_ENDIAN    0
+#   define _LIBCPP_LITTLE_ENDIAN
 # else  // _BYTE_ORDER == _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN 0
-#   define _LIBCPP_BIG_ENDIAN    1
+#   define _LIBCPP_BIG_ENDIAN
 # endif  // _BYTE_ORDER == _LITTLE_ENDIAN
 #endif  // __OpenBSD__
 
-#ifdef _WIN32
-#  define _LIBCPP_LITTLE_ENDIAN 1
-#  define _LIBCPP_BIG_ENDIAN    0
-// Compiler intrinsics (MSVC)
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-#    define _LIBCPP_HAS_IS_BASE_OF
-#  endif
-#  if defined(_MSC_VER) && !defined(__clang__)
-#    define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler
-#    define _LIBCPP_TOSTRING2(x) #x
-#    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.
-#  ifndef __MINGW32__
+#if defined(_WIN32)
+#  define _LIBCPP_WIN32API
+#  define _LIBCPP_LITTLE_ENDIAN
+#  define _LIBCPP_SHORT_WCHAR   1
+// Both MinGW and native MSVC provide a "MSVC"-like enviroment
+#  define _LIBCPP_MSVCRT_LIKE
+// If mingw not explicitly detected, assume using MS C runtime only if
+// a MS compatibility version is specified.
+#  if defined(_MSC_VER) && !defined(__MINGW32__)
 #    define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
-#endif  // _WIN32
+#  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
+#    define _LIBCPP_HAS_BITSCAN64
+#  endif
+# if defined(_LIBCPP_MSVCRT)
+#   define _LIBCPP_HAS_QUICK_EXIT
+# endif
+
+// Some CRT APIs are unavailable to store apps
+#if defined(WINAPI_FAMILY)
+#include <winapifamily.h>
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) &&                      \
+    (!defined(WINAPI_PARTITION_SYSTEM) ||                                      \
+     !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
+#define _LIBCPP_WINDOWS_STORE_APP
+#endif
+#endif
+#endif // defined(_WIN32)
 
 #ifdef __sun__
 # include <sys/isa_defs.h>
 # ifdef _LITTLE_ENDIAN
-#   define _LIBCPP_LITTLE_ENDIAN 1
-#   define _LIBCPP_BIG_ENDIAN    0
+#   define _LIBCPP_LITTLE_ENDIAN
 # else
-#   define _LIBCPP_LITTLE_ENDIAN 0
-#   define _LIBCPP_BIG_ENDIAN    1
+#   define _LIBCPP_BIG_ENDIAN
 # endif
 #endif // __sun__
 
   // random data even when using sandboxing mechanisms such as chroots,
   // Capsicum, etc.
 # define _LIBCPP_USING_ARC4_RANDOM
+#elif defined(__Fuchsia__)
+# define _LIBCPP_USING_GETENTROPY
 #elif defined(__native_client__)
   // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
   // 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
 #endif
 
-#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
+#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
 # include <endian.h>
 # if __BYTE_ORDER == __LITTLE_ENDIAN
-#  define _LIBCPP_LITTLE_ENDIAN 1
-#  define _LIBCPP_BIG_ENDIAN    0
+#  define _LIBCPP_LITTLE_ENDIAN
 # elif __BYTE_ORDER == __BIG_ENDIAN
-#  define _LIBCPP_LITTLE_ENDIAN 0
-#  define _LIBCPP_BIG_ENDIAN    1
+#  define _LIBCPP_BIG_ENDIAN
 # else  // __BYTE_ORDER == __BIG_ENDIAN
 #  error unable to determine endian
 # endif
-#endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
+#endif  // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
 
-#if __has_attribute(__no_sanitize__)
+#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
 #define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
 #else
 #define _LIBCPP_NO_CFI
 #endif
 
-#ifdef _WIN32
-
-// only really useful for a DLL
-#ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
-# ifdef cxx_EXPORTS
-#  define _LIBCPP_HIDDEN
-#  define _LIBCPP_FUNC_VIS __declspec(dllexport)
-#  define _LIBCPP_TYPE_VIS __declspec(dllexport)
-# else
-#  define _LIBCPP_HIDDEN
-#  define _LIBCPP_FUNC_VIS __declspec(dllimport)
-#  define _LIBCPP_TYPE_VIS __declspec(dllimport)
-# endif
-#else
-# define _LIBCPP_HIDDEN
-# define _LIBCPP_FUNC_VIS
-# define _LIBCPP_TYPE_VIS
-#endif
-
-#define _LIBCPP_TYPE_VIS_ONLY
-#define _LIBCPP_FUNC_VIS_ONLY
-
-#ifndef _LIBCPP_INLINE_VISIBILITY
-# ifdef _LIBCPP_MSVC
-#  define _LIBCPP_INLINE_VISIBILITY __forceinline
-# else // MinGW GCC and Clang
-#  define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
-# endif
-#endif
-
-#ifndef _LIBCPP_EXCEPTION_ABI
-#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
-#endif
-
-#ifndef _LIBCPP_ALWAYS_INLINE
-# ifdef _LIBCPP_MSVC
-#  define _LIBCPP_ALWAYS_INLINE __forceinline
-# endif
-#endif
-
-#endif // _WIN32
-
-#ifndef _LIBCPP_HIDDEN
-#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
-#endif
-
-#ifndef _LIBCPP_FUNC_VIS
-#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
-#endif
-
-#ifndef _LIBCPP_TYPE_VIS
-#  if __has_attribute(__type_visibility__)
-#    define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
-#  else
-#    define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
-#  endif
-#endif
-
-#ifndef _LIBCPP_PREFERRED_OVERLOAD
-#  if __has_attribute(__enable_if__)
-#    define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
-#  endif
-#endif
-
-#ifndef _LIBCPP_TYPE_VIS_ONLY
-# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS
-#endif
-
-#ifndef _LIBCPP_FUNC_VIS_ONLY
-# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
-#endif
-
-#ifndef _LIBCPP_INLINE_VISIBILITY
-#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
-#endif
-
-#ifndef _LIBCPP_EXCEPTION_ABI
-#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
-#endif
-
-#ifndef _LIBCPP_ALWAYS_INLINE
-#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
-#endif
-
-#if defined(__clang__)
+#if defined(_LIBCPP_COMPILER_CLANG)
 
 // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
 // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
 #if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&       \
-     !defined(__arm__)) ||                                                     \
+     (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) ||                           \
     defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
 #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 #endif
 #  define _ALIGNAS(x) __attribute__((__aligned__(x)))
 #endif
 
-#if !__has_feature(cxx_alias_templates)
-#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-#endif
-
 #if __cplusplus < 201103L
 typedef __char16_t char16_t;
 typedef __char32_t char32_t;
@@ -326,7 +341,7 @@ typedef __char32_t char32_t;
 #define _LIBCPP_NO_EXCEPTIONS
 #endif
 
-#if !(__has_feature(cxx_rtti))
+#if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI)
 #define _LIBCPP_NO_RTTI
 #endif
 
@@ -344,50 +359,30 @@ typedef __char32_t char32_t;
 #  define _LIBCPP_NORETURN __attribute__ ((noreturn))
 #endif
 
-#if !(__has_feature(cxx_default_function_template_args))
-#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
-#endif
-
-#if !(__has_feature(cxx_defaulted_functions))
-#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
-#endif  // !(__has_feature(cxx_defaulted_functions))
-
-#if !(__has_feature(cxx_deleted_functions))
-#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
-#endif  // !(__has_feature(cxx_deleted_functions))
-
 #if !(__has_feature(cxx_lambdas))
 #define _LIBCPP_HAS_NO_LAMBDAS
 #endif
 
 #if !(__has_feature(cxx_nullptr))
-#define _LIBCPP_HAS_NO_NULLPTR
+# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
+#   define nullptr __nullptr
+# else
+#   define _LIBCPP_HAS_NO_NULLPTR
+# endif
 #endif
 
 #if !(__has_feature(cxx_rvalue_references))
 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #endif
 
-#if !(__has_feature(cxx_static_assert))
-#define _LIBCPP_HAS_NO_STATIC_ASSERT
-#endif
-
 #if !(__has_feature(cxx_auto_type))
 #define _LIBCPP_HAS_NO_AUTO_TYPE
 #endif
 
-#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
-#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
-#endif
-
 #if !(__has_feature(cxx_variadic_templates))
 #define _LIBCPP_HAS_NO_VARIADICS
 #endif
 
-#if !(__has_feature(cxx_trailing_return))
-#define _LIBCPP_HAS_NO_TRAILING_RETURN
-#endif
-
 #if !(__has_feature(cxx_generalized_initializers))
 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 #endif
@@ -407,7 +402,6 @@ typedef __char32_t char32_t;
 
 #if __has_feature(objc_arc_weak)
 #define _LIBCPP_HAS_OBJC_ARC_WEAK
-#define _LIBCPP_HAS_NO_STRONG_ENUMS
 #endif
 
 #if !(__has_feature(cxx_constexpr))
@@ -426,12 +420,12 @@ typedef __char32_t char32_t;
 #if defined(__FreeBSD__)
 #define _LIBCPP_HAS_QUICK_EXIT
 #define _LIBCPP_HAS_C11_FEATURES
-#elif defined(__ANDROID__)
+#elif defined(__Fuchsia__)
 #define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
 #elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
-# include <features.h>
-#if __GLIBC_PREREQ(2, 15)
+#if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
 #define _LIBCPP_HAS_QUICK_EXIT
 #endif
 #if __GLIBC_PREREQ(2, 17)
@@ -475,7 +469,15 @@ namespace std {
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
 #endif 
 
-#elif defined(__GNUC__)
+#if __has_builtin(__builtin_launder)
+#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
+#endif
+
+#if !__is_identifier(__has_unique_object_representations)
+#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
+#endif
+
+#elif defined(_LIBCPP_COMPILER_GCC)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
@@ -515,34 +517,23 @@ namespace std {
 #endif
 
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
-
-#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
 #define _LIBCPP_HAS_NO_DECLTYPE
-#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
-#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
-#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 #define _LIBCPP_HAS_NO_NULLPTR
-#define _LIBCPP_HAS_NO_STATIC_ASSERT
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_NO_VARIADICS
 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #define _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
 #define _LIBCPP_HAS_NO_NOEXCEPT
 
 #else  // __GXX_EXPERIMENTAL_CXX0X__
 
 #if _GNUC_VER < 403
-#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#define _LIBCPP_HAS_NO_STATIC_ASSERT
 #endif
 
 
 #if _GNUC_VER < 404
 #define _LIBCPP_HAS_NO_DECLTYPE
-#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
-#define _LIBCPP_HAS_NO_TRAILING_RETURN
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_NO_VARIADICS
 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -551,47 +542,54 @@ namespace std {
 #if _GNUC_VER < 406
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define _LIBCPP_HAS_NO_NULLPTR
-#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-#endif
-
-#if _GNUC_VER < 407
-#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
-#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 #endif
 
 #endif  // __GXX_EXPERIMENTAL_CXX0X__
 
-#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
+#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_NAMESPACE {
 #define _LIBCPP_END_NAMESPACE_STD  } }
 #define _VSTD std::_LIBCPP_NAMESPACE
 
 namespace std {
-namespace _LIBCPP_NAMESPACE {
-}
-using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
+  inline namespace _LIBCPP_NAMESPACE {
+  }
 }
 
 #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
 #define _LIBCPP_HAS_NO_ASAN
 #endif
 
-#elif defined(_LIBCPP_MSVC)
+#if _GNUC_VER >= 700
+#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
+#endif
+
+#if _GNUC_VER >= 700
+#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
+#endif
+
+#elif defined(_LIBCPP_COMPILER_MSVC)
 
-#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+#define _LIBCPP_TOSTRING2(x) #x
+#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
+#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
+
+#if _MSC_VER < 1900
+#error "MSVC versions prior to Visual Studio 2015 are not supported"
+#endif
+
+#define _LIBCPP_HAS_IS_BASE_OF
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+#if _MSC_VER <= 1800
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
-#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
-#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#endif
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
 #define _ALIGNAS(x) __declspec(align(x))
 #define _LIBCPP_HAS_NO_VARIADICS
 
-
-
 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
 #define _LIBCPP_END_NAMESPACE_STD  }
 #define _VSTD std
@@ -602,16 +600,13 @@ namespace std {
 
 #define _LIBCPP_HAS_NO_ASAN
 
-#elif defined(__IBMCPP__)
+#elif defined(_LIBCPP_COMPILER_IBM)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
 #define _ATTRIBUTE(x) __attribute__((x))
 #define _LIBCPP_NORETURN __attribute__((noreturn))
 
-#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
-#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define _LIBCPP_HAS_NO_NULLPTR
@@ -635,7 +630,156 @@ namespace std {
 
 #define _LIBCPP_HAS_NO_ASAN
 
-#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
+#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
+
+#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
+#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_DLL_VIS
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+#elif defined(_LIBCPP_BUILDING_LIBRARY)
+# define _LIBCPP_DLL_VIS __declspec(dllexport)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
+#else
+# define _LIBCPP_DLL_VIS __declspec(dllimport)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS
+#endif
+
+#define _LIBCPP_TYPE_VIS            _LIBCPP_DLL_VIS
+#define _LIBCPP_FUNC_VIS            _LIBCPP_DLL_VIS
+#define _LIBCPP_EXTERN_VIS          _LIBCPP_DLL_VIS
+#define _LIBCPP_EXCEPTION_ABI       _LIBCPP_DLL_VIS
+#define _LIBCPP_HIDDEN
+#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+#define _LIBCPP_TEMPLATE_VIS
+#define _LIBCPP_ENUM_VIS
+
+#if defined(_LIBCPP_COMPILER_MSVC)
+# define _LIBCPP_INLINE_VISIBILITY __forceinline
+# define _LIBCPP_ALWAYS_INLINE     __forceinline
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#else
+# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+# define _LIBCPP_ALWAYS_INLINE     __attribute__ ((__always_inline__))
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+#endif
+#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
+
+#ifndef _LIBCPP_HIDDEN
+#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
+#else
+#define _LIBCPP_HIDDEN
+#endif
+#endif
+
+#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+// The inline should be removed once PR32114 is resolved
+#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
+#else
+#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+#endif
+#endif
+
+#ifndef _LIBCPP_FUNC_VIS
+#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
+#else
+#define _LIBCPP_FUNC_VIS
+#endif
+#endif
+
+#ifndef _LIBCPP_TYPE_VIS
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#    define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
+#  else
+#    define _LIBCPP_TYPE_VIS
+#  endif
+#endif
+
+#ifndef _LIBCPP_TEMPLATE_VIS
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#    if __has_attribute(__type_visibility__)
+#      define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
+#    else
+#      define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
+#    endif
+#  else
+#    define _LIBCPP_TEMPLATE_VIS
+#  endif
+#endif
+
+#ifndef _LIBCPP_EXTERN_VIS
+# define _LIBCPP_EXTERN_VIS
+#endif
+
+#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
+# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
+#endif
+
+#ifndef _LIBCPP_EXCEPTION_ABI
+#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
+#else
+#define _LIBCPP_EXCEPTION_ABI
+#endif
+#endif
+
+#ifndef _LIBCPP_ENUM_VIS
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
+#    define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
+#  else
+#    define _LIBCPP_ENUM_VIS
+#  endif
+#endif
+
+#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
+#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
+#  else
+#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+#  endif
+#endif
+
+#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+#endif
+
+#ifndef _LIBCPP_INLINE_VISIBILITY
+#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
+#else
+#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+#endif
+#endif
+
+#ifndef _LIBCPP_ALWAYS_INLINE
+#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
+#else
+#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__always_inline__))
+#endif
+#endif
+
+#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+#  define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
+# else
+#  define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__))
+# endif
+#endif
+
+#ifndef _LIBCPP_PREFERRED_OVERLOAD
+#  if __has_attribute(__enable_if__)
+#    define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
+#  endif
+#endif
 
 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
 #  define _NOEXCEPT noexcept
@@ -645,6 +789,17 @@ namespace std {
 #  define _NOEXCEPT_(x)
 #endif
 
+#if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
+# if !defined(_LIBCPP_DEBUG)
+#   error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
+# endif
+# define _NOEXCEPT_DEBUG noexcept(false)
+# define _NOEXCEPT_DEBUG_(x) noexcept(false)
+#else
+# define _NOEXCEPT_DEBUG _NOEXCEPT
+# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
+#endif
+
 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
 typedef unsigned short char16_t;
 typedef unsigned int   char32_t;
@@ -654,8 +809,10 @@ typedef unsigned int   char32_t;
 #define _LIBCPP_HAS_NO_INT128
 #endif
 
-#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
-
+#ifdef _LIBCPP_CXX03_LANG
+# if __has_extension(c_static_assert)
+#   define static_assert(__b, __m) _Static_assert(__b, __m)
+# else
 extern "C++" {
 template <bool> struct __static_assert_test;
 template <> struct __static_assert_test<true> {};
@@ -664,12 +821,12 @@ template <unsigned> struct __static_assert_check {};
 #define static_assert(__b, __m) \
     typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
     _LIBCPP_CONCAT(__t, __LINE__)
-
-#endif  // _LIBCPP_HAS_NO_STATIC_ASSERT
+# endif // __has_extension(c_static_assert)
+#endif  // _LIBCPP_CXX03_LANG
 
 #ifdef _LIBCPP_HAS_NO_DECLTYPE
 // GCC 4.6 provides __decltype in all standard modes.
-#if !__is_identifier(__decltype) || _GNUC_VER >= 406
+#if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406
 #  define decltype(__x) __decltype(__x)
 #else
 #  define decltype(__x) __typeof__(__x)
@@ -682,13 +839,13 @@ template <unsigned> struct __static_assert_check {};
 #define _LIBCPP_CONSTEXPR constexpr
 #endif
 
-#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#ifdef _LIBCPP_CXX03_LANG
 #define _LIBCPP_DEFAULT {}
 #else
 #define _LIBCPP_DEFAULT = default;
 #endif
 
-#ifdef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#ifdef _LIBCPP_CXX03_LANG
 #define _LIBCPP_EQUAL_DELETE
 #else
 #define _LIBCPP_EQUAL_DELETE = delete
@@ -700,7 +857,8 @@ template <unsigned> struct __static_assert_check {};
 #define _NOALIAS
 #endif
 
-#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
+#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
+    (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
 #   define _LIBCPP_EXPLICIT explicit
 #else
 #   define _LIBCPP_EXPLICIT
@@ -719,7 +877,7 @@ template <unsigned> struct __static_assert_check {};
     _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
     };
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
 #endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
 
@@ -731,7 +889,14 @@ template <unsigned> struct __static_assert_check {};
 #   else
 #       error Supported values for _LIBCPP_DEBUG are 0 and 1
 #   endif
+# if !defined(_LIBCPP_BUILDING_LIBRARY)
 #   define _LIBCPP_EXTERN_TEMPLATE(...)
+# endif
+#endif
+
+#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
+#define _LIBCPP_EXTERN_TEMPLATE(...)
+#define _LIBCPP_EXTERN_TEMPLATE2(...)
 #endif
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE
@@ -746,14 +911,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_LIKE) || \
     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(__ANDROID__) && !defined(_NEWLIB_VERSION)
+#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
 #define _LIBCPP_HAS_CATOPEN 1
 #endif
 #endif
@@ -762,6 +927,18 @@ template <unsigned> struct __static_assert_check {};
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
 
+#if defined(__APPLE__)
+# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
+     defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
+#   define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
+# endif
+# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+#   if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+#     define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#   endif
+# endif
+#endif // defined(__APPLE__)
+
 #if defined(__APPLE__) || defined(__FreeBSD__)
 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
 #endif
@@ -775,8 +952,10 @@ template <unsigned> struct __static_assert_check {};
 #    define _LIBCPP_STD_VER 11
 #  elif __cplusplus <= 201402L
 #    define _LIBCPP_STD_VER 14
+#  elif __cplusplus <= 201703L
+#    define _LIBCPP_STD_VER 17
 #  else
-#    define _LIBCPP_STD_VER 16  // current year, or date of c++17 ratification
+#    define _LIBCPP_STD_VER 18  // current year, or date of c++2a ratification
 #  endif
 #endif  // _LIBCPP_STD_VER
 
@@ -806,6 +985,24 @@ template <unsigned> struct __static_assert_check {};
 #define _LIBCPP_CONSTEXPR_AFTER_CXX14
 #endif
 
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
+#else
+#define _LIBCPP_CONSTEXPR_AFTER_CXX17
+#endif
+
+#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17)
+#define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
+#else
+#define _LIBCPP_NODISCARD_AFTER_CXX17
+#endif
+
+#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
+# define _LIBCPP_INLINE_VAR  inline
+#else
+# define _LIBCPP_INLINE_VAR  
+#endif
+
 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #  define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
 #else
@@ -813,7 +1010,7 @@ template <unsigned> struct __static_assert_check {};
 #endif
 
 #ifndef _LIBCPP_HAS_NO_ASAN
-extern "C" void __sanitizer_annotate_contiguous_container(
+_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
   const void *, const void *, const void *, const void *);
 #endif
 
@@ -824,7 +1021,7 @@ extern "C" void __sanitizer_annotate_contiguous_container(
 #  if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
    (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
 #    define _LIBCPP_NO_RTTI
-#  elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
+#  elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
 #    define _LIBCPP_NO_RTTI
 #  endif
 #endif
@@ -834,15 +1031,22 @@ extern "C" void __sanitizer_annotate_contiguous_container(
 #endif
 
 // Thread API
-#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if !defined(_LIBCPP_HAS_NO_THREADS) && \
+    !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
+    !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
+    !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 # if defined(__FreeBSD__) || \
+    defined(__Fuchsia__) || \
     defined(__NetBSD__) || \
     defined(__linux__) || \
     defined(__APPLE__) || \
     defined(__CloudABI__) || \
     defined(__sun__) || \
+    (defined(__MINGW32__) && __libcpp_has_include(<pthread.h>)) || \
     defined(__OpenBSD__)
-#  define _LIBCPP_HAS_THREAD_API_PTHREAD
+#   define _LIBCPP_HAS_THREAD_API_PTHREAD
+# elif defined(_LIBCPP_WIN32API)
+#  define _LIBCPP_HAS_THREAD_API_WIN32
 # else
 #  error "No thread API"
 # endif // _LIBCPP_HAS_THREAD_API
@@ -853,6 +1057,11 @@ extern "C" void __sanitizer_annotate_contiguous_container(
          _LIBCPP_HAS_NO_THREADS is not defined.
 #endif
 
+#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+#  error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
+         _LIBCPP_HAS_NO_THREADS is defined.
+#endif
+
 #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
 #  error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
          _LIBCPP_HAS_NO_THREADS is defined.
@@ -873,18 +1082,19 @@ extern "C" void __sanitizer_annotate_contiguous_container(
 #define _LIBCPP_HAS_NO_STDOUT
 #endif
 
-#if defined(__ANDROID__) || defined(__CloudABI__) || defined(_LIBCPP_HAS_MUSL_LIBC) \
-    || defined(__OpenBSD__)
+#if defined(__BIONIC__) || defined(__CloudABI__) ||                            \
+    defined(__Fuchsia__) || defined(_LIBCPP_HAS_MUSL_LIBC) ||                  \
+    defined(__OpenBSD__)
 #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
 #endif
 
-// Thread-unsafe functions such as strtok(), mbtowc() and localtime()
+// Thread-unsafe functions such as strtok() and localtime()
 // are not available.
 #ifdef __CloudABI__
 #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 #endif
 
-#if __has_feature(cxx_atomic) || __has_extension(c_atomic)
+#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
 #define _LIBCPP_HAS_C_ATOMIC_IMP
 #elif _GNUC_VER > 407
 #define _LIBCPP_HAS_GCC_ATOMIC_IMP
@@ -899,19 +1109,192 @@ extern "C" void __sanitizer_annotate_contiguous_container(
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
 #endif
 
-#if __cplusplus < 201103L
-#define _LIBCPP_CXX03_LANG
+#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
+#if defined(__clang__) && __has_attribute(acquire_capability)
+// Work around the attribute handling in clang.  When both __declspec and
+// __attribute__ are present, the processing goes awry preventing the definition
+// of the types.
+#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
+#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#endif
+#endif
+#endif
+
+#if __has_attribute(require_constant_initialization)
+#define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
 #else
-#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
-#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
+#define _LIBCPP_SAFE_STATIC
 #endif
+
+#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
+# define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
 #endif
 
-#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
-      && __has_attribute(acquire_capability))
-#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
+#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
+#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
+#endif
+#endif
+
+#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
+# define _LIBCPP_DIAGNOSE_WARNING(...) \
+    __attribute__((diagnose_if(__VA_ARGS__, "warning")))
+# define _LIBCPP_DIAGNOSE_ERROR(...) \
+    __attribute__((diagnose_if(__VA_ARGS__, "error")))
+#else
+# define _LIBCPP_DIAGNOSE_WARNING(...)
+# define _LIBCPP_DIAGNOSE_ERROR(...)
+#endif
+
+#if __has_attribute(fallthough) || _GNUC_VER >= 700
+// Use a function like macro to imply that it must be followed by a semicolon
+#define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
+#else
+#define _LIBCPP_FALLTHROUGH() ((void)0)
+#endif
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && \
+   (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
+# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
+#else
+# define _LIBCPP_DECLSPEC_EMPTY_BASES
+#endif
+
+#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
+# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
+# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
+#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+
+#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
+# define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+#endif
+
+#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
+# define _LIBCPP_HAS_NO_IS_AGGREGATE
+#endif
+
+#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
+# define _LIBCPP_HAS_NO_COROUTINES
+#endif
+
+// Decide whether to use availability macros.
+#if !defined(_LIBCPP_BUILDING_LIBRARY) &&                                      \
+    !defined(_LIBCPP_DISABLE_AVAILABILITY) &&                                  \
+    __has_feature(attribute_availability_with_strict) &&                       \
+    __has_feature(attribute_availability_in_templates)
+#ifdef __APPLE__
+#define _LIBCPP_USE_AVAILABILITY_APPLE
+#endif
+#endif
+
+// Define availability macros.
+#if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
+#define _LIBCPP_AVAILABILITY_SHARED_MUTEX                                      \
+  __attribute__((availability(macosx,strict,introduced=10.12)))                \
+  __attribute__((availability(ios,strict,introduced=10.0)))                    \
+  __attribute__((availability(tvos,strict,introduced=10.0)))                   \
+  __attribute__((availability(watchos,strict,introduced=3.0)))
+#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
+#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable))
+#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable))
+#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS                               \
+  __attribute__((availability(macosx,strict,introduced=10.12)))                \
+  __attribute__((availability(ios,strict,introduced=10.0)))                    \
+  __attribute__((availability(tvos,strict,introduced=10.0)))                   \
+  __attribute__((availability(watchos,strict,introduced=3.0)))
+#define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE                                  \
+  __attribute__((availability(macosx,strict,introduced=10.12)))                \
+  __attribute__((availability(ios,strict,introduced=10.0)))                    \
+  __attribute__((availability(tvos,strict,introduced=10.0)))                   \
+  __attribute__((availability(watchos,strict,introduced=3.0)))
+#define _LIBCPP_AVAILABILITY_FUTURE_ERROR                                      \
+  __attribute__((availability(ios,strict,introduced=6.0)))
+#define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE                                   \
+  __attribute__((availability(macosx,strict,introduced=10.9)))                 \
+  __attribute__((availability(ios,strict,introduced=7.0)))
+#define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY                                   \
+  __attribute__((availability(macosx,strict,introduced=10.9)))                 \
+  __attribute__((availability(ios,strict,introduced=7.0)))
+#define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR                                 \
+  __attribute__((availability(macosx,strict,introduced=10.9)))                 \
+  __attribute__((availability(ios,strict,introduced=7.0)))
+#else
+#define _LIBCPP_AVAILABILITY_SHARED_MUTEX
+#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
+#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
+#define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
+#define _LIBCPP_AVAILABILITY_FUTURE_ERROR
+#define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
+#define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
+#define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+#endif
+
+// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
+#ifdef _LIBCPP_NO_EXCEPTIONS
+#define _LIBCPP_AVAILABILITY_DYNARRAY
+#define _LIBCPP_AVAILABILITY_FUTURE
+#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
+#else
+#define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
+#define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
+#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST                                \
+  _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+#endif
+
+// Availability of stream API in the dylib got dropped and re-added.  The
+// extern template should effectively be available at:
+//    availability(macosx,introduced=10.9)
+//    availability(ios,introduced=7.0)
+#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) &&                                 \
+    ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&                \
+      __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) ||                 \
+     (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) &&               \
+      __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
+#define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE
+#endif
+
+#if defined(_LIBCPP_COMPILER_IBM)
+#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
 #endif
 
+#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
+# define _LIBCPP_PUSH_MACROS
+# define _LIBCPP_POP_MACROS
+#else
+  // Don't warn about macro conflicts when we can restore them at the
+  // end of the header.
+# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
+#   define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
+# endif
+# if defined(_LIBCPP_COMPILER_MSVC)
+#   define _LIBCPP_PUSH_MACROS    \
+      __pragma(push_macro("min")) \
+      __pragma(push_macro("max"))
+#   define _LIBCPP_POP_MACROS     \
+      __pragma(pop_macro("min"))  \
+      __pragma(pop_macro("max"))
+# else
+#   define _LIBCPP_PUSH_MACROS        \
+      _Pragma("push_macro(\"min\")")  \
+      _Pragma("push_macro(\"max\")")
+#   define _LIBCPP_POP_MACROS         \
+      _Pragma("pop_macro(\"min\")")   \
+      _Pragma("pop_macro(\"max\")")
+# endif
+#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
+
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+# if defined(_DLL)
+#   pragma(lib, "c++.lib")
+# else
+#   pragma(lib, "libc++.lib")
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG
index 404b898..bface07 100644 (file)
@@ -19,7 +19,7 @@
 #include <cstdint>
 #include <cctype>
 #include <locale.h>
-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#if defined(_LIBCPP_MSVCRT_LIKE)
 # include <support/win32/locale_win32.h>
 #elif defined(_AIX)
 # include <support/ibm/xlocale.h>
 # include <support/solaris/xlocale.h>
 #elif defined(_NEWLIB_VERSION) || defined(__OpenBSD__)
 # include <support/newlib/xlocale.h>
-#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
 # include <xlocale.h>
+#elif defined(__Fuchsia__)
+# include <support/fuchsia/xlocale.h>
 #elif defined(_LIBCPP_HAS_MUSL_LIBC)
 # include <support/musl/xlocale.h>
-#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS)
+struct __libcpp_locale_guard {
+  _LIBCPP_INLINE_VISIBILITY
+  __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
+
+  _LIBCPP_INLINE_VISIBILITY
+  ~__libcpp_locale_guard() {
+    if (__old_loc_)
+      uselocale(__old_loc_);
+  }
+
+  locale_t __old_loc_;
+private:
+  __libcpp_locale_guard(__libcpp_locale_guard const&);
+  __libcpp_locale_guard& operator=(__libcpp_locale_guard const&);
+};
+#elif defined(_LIBCPP_MSVCRT_LIKE)
+struct __libcpp_locale_guard {
+    __libcpp_locale_guard(locale_t __l) :
+        __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)),
+        __locale_collate(setlocale(LC_COLLATE, __l.__get_locale())),
+        __locale_ctype(setlocale(LC_CTYPE, __l.__get_locale())),
+        __locale_monetary(setlocale(LC_MONETARY, __l.__get_locale())),
+        __locale_numeric(setlocale(LC_NUMERIC, __l.__get_locale())),
+        __locale_time(setlocale(LC_TIME, __l.__get_locale()))
+        // LC_MESSAGES is not supported on Windows.
+    {}
+    ~__libcpp_locale_guard() {
+        setlocale(LC_COLLATE, __locale_collate);
+        setlocale(LC_CTYPE, __locale_ctype);
+        setlocale(LC_MONETARY, __locale_monetary);
+        setlocale(LC_NUMERIC, __locale_numeric);
+        setlocale(LC_TIME, __locale_time);
+        _configthreadlocale(__status);
+    }
+    int __status;
+    char* __locale_collate;
+    char* __locale_ctype;
+    char* __locale_monetary;
+    char* __locale_numeric;
+    char* __locale_time;
+};
+#endif
+
+
 class _LIBCPP_TYPE_VIS locale;
 
 template <class _Facet>
@@ -67,6 +114,7 @@ public:
     class _LIBCPP_TYPE_VIS id;
 
     typedef int category;
+    _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
     static const category // values assigned here are for exposition only
         none     = 0,
         collate  = LC_COLLATE_MASK,
@@ -92,13 +140,16 @@ public:
 
     const locale& operator=(const locale&)  _NOEXCEPT;
 
-    template <class _Facet> locale combine(const locale&) const;
+    template <class _Facet>
+      _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+      locale combine(const locale&) const;
 
     // locale operations:
     string name() const;
     bool operator==(const locale&) const;
     bool operator!=(const locale& __y) const {return !(*this == __y);}
     template <class _CharT, class _Traits, class _Allocator>
+      _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
       bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
                       const basic_string<_CharT, _Traits, _Allocator>&) const;
 
@@ -165,10 +216,9 @@ template <class _Facet>
 locale
 locale::combine(const locale& __other) const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (!_VSTD::has_facet<_Facet>(__other))
-        throw runtime_error("locale::combine: locale missing facet");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_runtime_error("locale::combine: locale missing facet");
+
     return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
 }
 
@@ -191,7 +241,7 @@ use_facet(const locale& __l)
 // template <class _CharT> class collate;
 
 template <class _CharT>
-class _LIBCPP_TYPE_VIS_ONLY collate
+class _LIBCPP_TEMPLATE_VIS collate
     : public locale::facet
 {
 public:
@@ -270,12 +320,12 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
     return static_cast<long>(__h);
 }
 
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<char>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)
 
 // template <class CharT> class collate_byname;
 
-template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY collate_byname;
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS collate_byname;
 
 template <>
 class _LIBCPP_TYPE_VIS collate_byname<char>
@@ -343,7 +393,7 @@ public:
     static const mask punct  = _ISpunct;
     static const mask xdigit = _ISxdigit;
     static const mask blank  = _ISblank;
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_MSVCRT_LIKE)
     typedef unsigned short mask;
     static const mask space  = _SPACE;
     static const mask print  = _BLANK|_PUNCT|_ALPHA|_DIGIT;
@@ -426,7 +476,7 @@ public:
     _LIBCPP_ALWAYS_INLINE ctype_base() {}
 };
 
-template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype;
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
 
 template <>
 class _LIBCPP_TYPE_VIS ctype<wchar_t>
@@ -653,7 +703,7 @@ protected:
 
 // template <class CharT> class ctype_byname;
 
-template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype_byname;
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype_byname;
 
 template <>
 class _LIBCPP_TYPE_VIS ctype_byname<char>
@@ -814,7 +864,7 @@ public:
 
 // template <class internT, class externT, class stateT> class codecvt;
 
-template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TYPE_VIS_ONLY codecvt;
+template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TEMPLATE_VIS codecvt;
 
 // template <> class codecvt<char, char, mbstate_t>
 
@@ -1160,7 +1210,7 @@ protected:
 // template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
 
 template <class _InternT, class _ExternT, class _StateT>
-class _LIBCPP_TYPE_VIS_ONLY codecvt_byname
+class _LIBCPP_TEMPLATE_VIS codecvt_byname
     : public codecvt<_InternT, _ExternT, _StateT>
 {
 public:
@@ -1179,12 +1229,12 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
 {
 }
 
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
-_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
 
-_LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
 
 template <size_t _Np>
 struct __narrow_to_utf8
@@ -1368,7 +1418,7 @@ struct __widen_from_utf8<32>
 
 // template <class charT> class numpunct
 
-template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct;
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct;
 
 template <>
 class _LIBCPP_TYPE_VIS numpunct<char>
@@ -1434,7 +1484,7 @@ protected:
 
 // template <class charT> class numpunct_byname
 
-template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname;
+template <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct_byname;
 
 template <>
 class _LIBCPP_TYPE_VIS numpunct_byname<char>
diff --git a/lib/libcxx/include/__refstring b/lib/libcxx/include/__refstring
deleted file mode 100644 (file)
index 61ccc75..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-//===------------------------ __refstring ---------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___REFSTRING
-#define _LIBCPP___REFSTRING
-
-#include <__config>
-#include <cstddef>
-#include <cstring>
-#ifdef __APPLE__
-#include <dlfcn.h>
-#include <mach-o/dyld.h>
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-class _LIBCPP_HIDDEN __libcpp_refstring
-{
-private:
-    const char* str_;
-
-    typedef int count_t;
-
-    struct _Rep_base
-    {
-        std::size_t len;
-        std::size_t cap;
-        count_t     count;
-    };
-
-    static
-    _Rep_base*
-    rep_from_data(const char *data_) _NOEXCEPT
-    {
-        char *data = const_cast<char *>(data_);
-        return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
-    }
-    static
-    char *
-    data_from_rep(_Rep_base *rep) _NOEXCEPT
-    {
-        char *data = reinterpret_cast<char *>(rep);
-        return data + sizeof(*rep);
-    }
-
-#ifdef __APPLE__
-    static
-    const char*
-    compute_gcc_empty_string_storage() _NOEXCEPT
-    {
-        void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
-        if (handle == nullptr)
-            return nullptr;
-        void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
-        if (sym == nullptr)
-            return nullptr;
-        return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
-    }
-
-    static
-    const char*
-    get_gcc_empty_string_storage() _NOEXCEPT
-    {
-        static const char* p = compute_gcc_empty_string_storage();
-        return p;
-    }
-
-    bool
-    uses_refcount() const
-    {
-        return str_ != get_gcc_empty_string_storage();
-    }
-#else
-    bool
-    uses_refcount() const
-    {
-        return true;
-    }
-#endif
-
-public:
-    explicit __libcpp_refstring(const char* msg) {
-        std::size_t len = strlen(msg);
-        _Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1));
-        rep->len = len;
-        rep->cap = len;
-        rep->count = 0;
-        char *data = data_from_rep(rep);
-        std::memcpy(data, msg, len + 1);
-        str_ = data;
-    }
-
-    __libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT : str_(s.str_)
-    {
-        if (uses_refcount())
-            __sync_add_and_fetch(&rep_from_data(str_)->count, 1);
-    }
-
-    __libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT
-    {
-        bool adjust_old_count = uses_refcount();
-        struct _Rep_base *old_rep = rep_from_data(str_);
-        str_ = s.str_;
-        if (uses_refcount())
-            __sync_add_and_fetch(&rep_from_data(str_)->count, 1);
-        if (adjust_old_count)
-        {
-            if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0)
-            {
-                ::operator delete(old_rep);
-            }
-        }
-        return *this;
-    }
-
-    ~__libcpp_refstring()
-    {
-        if (uses_refcount())
-        {
-            _Rep_base* rep = rep_from_data(str_);
-            if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0)
-            {
-                ::operator delete(rep);
-            }
-        }
-    }
-
-    const char* c_str() const _NOEXCEPT {return str_;}
-};
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif //_LIBCPP___REFSTRING
diff --git a/lib/libcxx/include/__undef___deallocate b/lib/libcxx/include/__undef___deallocate
deleted file mode 100644 (file)
index 52f4d99..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifdef __deallocate
-#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_MSC_VER) && !defined(__clang__)
-_LIBCPP_WARNING("macro __deallocate is incompatible with C++.  #undefining __deallocate")
-#else
-#warning: macro __deallocate is incompatible with C++.  #undefining __deallocate
-#endif
-#endif
-#undef __deallocate
-#endif
diff --git a/lib/libcxx/include/__undef_min_max b/lib/libcxx/include/__undef_min_max
deleted file mode 100644 (file)
index d3c3138..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifdef min
-#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_MSC_VER) && ! defined(__clang__)
-_LIBCPP_WARNING("macro min is incompatible with C++.  Try #define NOMINMAX "
-                "before any Windows header. #undefing min")
-#else
-#warning: macro min is incompatible with C++.  #undefing min
-#endif
-#endif
-#undef min
-#endif
-
-#ifdef max
-#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_MSC_VER) && ! defined(__clang__)
-_LIBCPP_WARNING("macro max is incompatible with C++.  Try #define NOMINMAX "
-                "before any Windows header. #undefing max")
-#else
-#warning: macro max is incompatible with C++.  #undefing max
-#endif
-#endif
-#undef max
-#endif
index 4785176..48643c5 100644 (file)
@@ -118,11 +118,9 @@ using ::fscanf;
 using ::snprintf;
 using ::sprintf;
 using ::sscanf;
-#ifndef _LIBCPP_MSVCRT
 using ::vfprintf;
 using ::vfscanf;
 using ::vsscanf;
-#endif // _LIBCPP_MSVCRT
 using ::vsnprintf;
 using ::vsprintf;
 using ::fgetc;
@@ -155,7 +153,7 @@ using ::tmpnam;
 
 #ifndef _LIBCPP_HAS_NO_STDIN
 using ::getchar;
-#if _LIBCPP_STD_VER <= 11 && !defined(__OpenBSD__)
+#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_MSVCRT) && !defined(__OpenBSD__)
 using ::gets;
 #endif
 using ::scanf;
index c135be7..616d0a0 100644 (file)
@@ -110,9 +110,9 @@ void perror(const char* s);
 #ifdef __cplusplus
 
 // snprintf
-#if defined(_LIBCPP_MSVCRT)
-extern "C++" {
-#include "support/win32/support.h"
+#if defined(_LIBCPP_MSVCRT_LIKE)
+extern "C" {
+int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
 }
 #endif
 
index 04e41d4..2afb95e 100644 (file)
 #include <clocale>
 #include <cwctype>
 #include <ctype.h>
-#ifndef __OpenBSD__
+#if !defined(__OpenBSD__)
+#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \
+    __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
 #include <support/xlocale/__nop_locale_mgmt.h>
+#endif
 #include <support/xlocale/__posix_l_fallback.h>
 #endif
 #include <support/xlocale/__strtonum_fallback.h>
diff --git a/lib/libcxx/include/support/win32/limits_win32.h b/lib/libcxx/include/support/win32/limits_win32.h
deleted file mode 100644 (file)
index 406cd30..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-// -*- C++ -*-
-//===--------------------- support/win32/limits_win32.h -------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
-#define _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
-
-#if !defined(_LIBCPP_MSVCRT)
-#error "This header complements the Microsoft C Runtime library, and should not be included otherwise."
-#else
-
-#include <limits.h> // CHAR_BIT
-#include <float.h> // limit constants
-
-#if ! defined(__clang__)
-#define __CHAR_BIT__       CHAR_BIT
-
-#define __FLT_MANT_DIG__   FLT_MANT_DIG
-#define __FLT_DIG__        FLT_DIG
-#define __FLT_RADIX__      FLT_RADIX
-#define __FLT_MIN_EXP__    FLT_MIN_EXP
-#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
-#define __FLT_MAX_EXP__    FLT_MAX_EXP
-#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
-#define __FLT_MIN__        FLT_MIN
-#define __FLT_MAX__        FLT_MAX
-#define __FLT_EPSILON__    FLT_EPSILON
-// predefined by MinGW GCC
-#define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F
-
-#define __DBL_MANT_DIG__   DBL_MANT_DIG
-#define __DBL_DIG__        DBL_DIG
-#define __DBL_RADIX__      DBL_RADIX
-#define __DBL_MIN_EXP__    DBL_MIN_EXP
-#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
-#define __DBL_MAX_EXP__    DBL_MAX_EXP
-#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
-#define __DBL_MIN__        DBL_MIN
-#define __DBL_MAX__        DBL_MAX
-#define __DBL_EPSILON__    DBL_EPSILON
-// predefined by MinGW GCC
-#define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L)
-
-#define __LDBL_MANT_DIG__   LDBL_MANT_DIG
-#define __LDBL_DIG__        LDBL_DIG
-#define __LDBL_RADIX__      LDBL_RADIX
-#define __LDBL_MIN_EXP__    LDBL_MIN_EXP
-#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
-#define __LDBL_MAX_EXP__    LDBL_MAX_EXP
-#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
-#define __LDBL_MIN__        LDBL_MIN
-#define __LDBL_MAX__        LDBL_MAX
-#define __LDBL_EPSILON__    LDBL_EPSILON
-// predefined by MinGW GCC
-#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
-
-// __builtin replacements/workarounds
-#include <math.h> // HUGE_VAL
-#include <ymath.h> // internal MSVC header providing the needed functionality
-#define __builtin_huge_val()     HUGE_VAL
-#define __builtin_huge_valf()    _FInf._Float
-#define __builtin_huge_vall()    _LInf._Long_double
-#define __builtin_nan(__dummy)   _Nan._Double
-#define __builtin_nanf(__dummy)  _FNan._Float
-#define __builtin_nanl(__dummmy) _LNan._Long_double
-#define __builtin_nans(__dummy)  _Snan._Double
-#define __builtin_nansf(__dummy) _FSnan._Float
-#define __builtin_nansl(__dummy) _LSnan._Long_double
-#endif // ! defined(__clang__)
-
-#endif // _LIBCPP_MSVCRT
-
-#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
diff --git a/lib/libcxx/include/support/win32/locale_mgmt_win32.h b/lib/libcxx/include/support/win32/locale_mgmt_win32.h
deleted file mode 100644 (file)
index b3316d6..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// -*- C++ -*-
-//===----------------- support/win32/locale_mgmt_win32.h ------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
-#define _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
-
-#include <xlocinfo.h> // _locale_t
-#define locale_t _locale_t
-#define LC_COLLATE_MASK _M_COLLATE
-#define LC_CTYPE_MASK _M_CTYPE
-#define LC_MONETARY_MASK _M_MONETARY
-#define LC_NUMERIC_MASK _M_NUMERIC
-#define LC_TIME_MASK _M_TIME
-#define LC_MESSAGES_MASK _M_MESSAGES
-#define LC_ALL_MASK (  LC_COLLATE_MASK \
-                     | LC_CTYPE_MASK \
-                     | LC_MESSAGES_MASK \
-                     | LC_MONETARY_MASK \
-                     | LC_NUMERIC_MASK \
-                     | LC_TIME_MASK )
-#define freelocale _free_locale
-// FIXME: base currently unused. Needs manual work to construct the new locale
-locale_t newlocale( int mask, const char * locale, locale_t base );
-locale_t uselocale( locale_t newloc );
-
-#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
diff --git a/lib/libcxx/include/support/win32/math_win32.h b/lib/libcxx/include/support/win32/math_win32.h
deleted file mode 100644 (file)
index 0d6b422..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-// -*- C++ -*-
-//===---------------------- support/win32/math_win32.h --------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
-#define _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
-
-#if !defined(_LIBCPP_MSVCRT)
-#error "This header complements Microsoft's C Runtime library, and should not be included otherwise."
-#else
-
-#include <math.h>
-#include <float.h> // _FPCLASS_PN etc.
-#include <crtversion.h>
-
-#if ((_VC_CRT_MAJOR_VERSION-0) < 12)
-// Necessary?
-typedef float float_t;
-typedef double double_t;
-
-_LIBCPP_ALWAYS_INLINE bool isfinite( double num )
-{
-    return _finite(num) != 0;
-}
-_LIBCPP_ALWAYS_INLINE bool isinf( double num )
-{
-    return !isfinite(num) && !_isnan(num);
-}
-_LIBCPP_ALWAYS_INLINE bool isnan( double num )
-{
-    return _isnan(num) != 0;
-}
-_LIBCPP_ALWAYS_INLINE bool isnormal( double num )
-{
-    int class_ = _fpclass(num);
-    return class_ == _FPCLASS_NN || class_ == _FPCLASS_PN;
-}
-
-_LIBCPP_ALWAYS_INLINE bool isgreater( double x, double y )
-{
-    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
-    else return x > y;
-}
-
-_LIBCPP_ALWAYS_INLINE bool isgreaterequal( double x, double y )
-{
-    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
-    else return x >= y;
-}
-
-_LIBCPP_ALWAYS_INLINE bool isless( double x, double y )
-{
-    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
-    else return x < y;
-}
-
-_LIBCPP_ALWAYS_INLINE bool islessequal( double x, double y )
-{
-    if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
-    else return x <= y;
-}
-
-_LIBCPP_ALWAYS_INLINE bool islessgreater( double x, double y )
-{
-    if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
-    else return x < y || x > y;
-}
-
-_LIBCPP_ALWAYS_INLINE bool isunordered( double x, double y )
-{
-    return isnan(x) || isnan(y);
-}
-_LIBCPP_ALWAYS_INLINE bool signbit( double num )
-{
-    switch(_fpclass(num))
-    {
-        case _FPCLASS_SNAN:
-        case _FPCLASS_QNAN:
-        case _FPCLASS_NINF:
-        case _FPCLASS_NN:
-        case _FPCLASS_ND:
-        case _FPCLASS_NZ:
-            return true;
-        case _FPCLASS_PZ:
-        case _FPCLASS_PD:
-        case _FPCLASS_PN:
-        case _FPCLASS_PINF:
-            return false;
-    }
-    return false;
-}
-_LIBCPP_ALWAYS_INLINE float copysignf( float x, float y )
-{
-    return (signbit (x) != signbit (y) ? - x : x);
-}
-_LIBCPP_ALWAYS_INLINE double copysign( double x, double y )
-{
-    return ::_copysign(x,y);
-}
-_LIBCPP_ALWAYS_INLINE double copysignl( long double x, long double y )
-{
-    return ::_copysignl(x,y);
-}
-_LIBCPP_ALWAYS_INLINE int fpclassify( double num )
-{
-    return _fpclass(num);
-}
-#endif
-#endif // _LIBCPP_MSVCRT
-
-#endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
diff --git a/lib/libcxx/include/support/win32/support.h b/lib/libcxx/include/support/win32/support.h
deleted file mode 100644 (file)
index 5765bab..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-// -*- C++ -*-
-//===----------------------- support/win32/support.h ----------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-#define _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-
-// Functions and constants used in libc++ that
-// are missing from the Windows C library.
-
-#include <wchar.h> // mbstate_t
-#include <cstdarg> // va_ macros
-// "builtins" not implemented here for Clang or GCC as they provide
-// implementations. Assuming required for elsewhere else, certainly MSVC.
-#if defined(_LIBCPP_MSVC)
-#include <intrin.h>
-#endif
-#if defined(_LIBCPP_MSVCRT)
-#include <xlocinfo.h>
-#endif
-#define swprintf _snwprintf
-#define vswprintf _vsnwprintf
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-
-// The mingw headers already define these as static.
-#ifndef __MINGW32__
-extern "C" {
-
-int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
-int asprintf(char **sptr, const char *__restrict fmt, ...);
-size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
-                  size_t nmc, size_t len, mbstate_t *__restrict ps);
-size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
-                  size_t nwc, size_t len, mbstate_t *__restrict ps);
-}
-#endif // __MINGW32__
-
-#if defined(_LIBCPP_MSVCRT)
-#define snprintf _snprintf
-#define atoll _atoi64
-#define strtoll _strtoi64
-#define strtoull _strtoui64
-#define wcstoll _wcstoi64
-#define wcstoull _wcstoui64
-_LIBCPP_ALWAYS_INLINE float strtof(const char *nptr, char **endptr)
-{
-  return _Stof(nptr, endptr, 0);
-}
-_LIBCPP_ALWAYS_INLINE double strtod(const char *nptr, char **endptr)
-{
-  return _Stod(nptr, endptr, 0);
-}
-_LIBCPP_ALWAYS_INLINE long double strtold(const char *nptr, char **endptr)
-{
-  return _Stold(nptr, endptr, 0);
-}
-
-#define _Exit _exit
-#endif
-
-#if defined(_LIBCPP_MSVC)
-
-// Bit builtin's make these assumptions when calling _BitScanForward/Reverse
-// etc. These assumptions are expected to be true for Win32/Win64 which this
-// file supports.
-static_assert(sizeof(unsigned long long) == 8, "");
-static_assert(sizeof(unsigned long) == 4, "");
-static_assert(sizeof(unsigned int) == 4, "");
-
-_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
-{
-  // Binary: 0101...
-  static const unsigned int m1 = 0x55555555;
-  // Binary: 00110011..
-  static const unsigned int m2 = 0x33333333;
-  // Binary:  4 zeros,  4 ones ...
-  static const unsigned int m4 = 0x0f0f0f0f;
-  // The sum of 256 to the power of 0,1,2,3...
-  static const unsigned int h01 = 0x01010101;
-  // Put count of each 2 bits into those 2 bits.
-  x -= (x >> 1) & m1;
-  // Put count of each 4 bits into those 4 bits.
-  x = (x & m2) + ((x >> 2) & m2);
-  // Put count of each 8 bits into those 8 bits.
-  x = (x + (x >> 4)) & m4;
-  // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24).
-  return (x * h01) >> 24;
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_popcountl(unsigned long x)
-{
-  return __builtin_popcount(static_cast<int>(x));
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x)
-{
-  // Binary: 0101...
-  static const unsigned long long m1 = 0x5555555555555555;
-  // Binary: 00110011..
-  static const unsigned long long m2 = 0x3333333333333333;
-  // Binary:  4 zeros,  4 ones ...
-  static const unsigned long long m4 = 0x0f0f0f0f0f0f0f0f;
-  // The sum of 256 to the power of 0,1,2,3...
-  static const unsigned long long h01 = 0x0101010101010101;
-  // Put count of each 2 bits into those 2 bits.
-  x -= (x >> 1) & m1;
-  // Put count of each 4 bits into those 4 bits.
-  x = (x & m2) + ((x >> 2) & m2);
-  // Put count of each 8 bits into those 8 bits.
-  x = (x + (x >> 4)) & m4;
-  // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ...
-  return static_cast<int>((x * h01) >> 56);
-}
-
-// Returns the number of trailing 0-bits in x, starting at the least significant
-// bit position. If x is 0, the result is undefined.
-_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 (_BitScanForward64(&where, mask))
-    return static_cast<int>(where);
-#elif defined(_WIN32)
-  // 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)))
-    return static_cast<int>(where);
-  // 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;
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_ctzl(unsigned long mask)
-{
-  unsigned long where;
-  // Search from LSB to MSB for first set bit.
-  // Returns zero if no set bit is found.
-  if (_BitScanForward(&where, mask))
-    return static_cast<int>(where);
-  return 32;
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_ctz(unsigned int mask)
-{
-  // Win32 and Win64 expectations.
-  static_assert(sizeof(mask) == 4, "");
-  static_assert(sizeof(unsigned long) == 4, "");
-  return __builtin_ctzl(static_cast<unsigned long>(mask));
-}
-
-// Returns the number of leading 0-bits in x, starting at the most significant
-// bit position. If x is 0, the result is undefined.
-_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 (_BitScanReverse64(&where, mask))
-    return static_cast<int>(63 - where);
-#elif defined(_WIN32)
-  // Scan the high 32 bits.
-  if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
-    return static_cast<int>(63 -
-                            (where + 32)); // Create a bit offset from the MSB.
-  // 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.
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_clzl(unsigned long mask)
-{
-  unsigned long where;
-  // Search from LSB to MSB for first set bit.
-  // Returns zero if no set bit is found.
-  if (_BitScanReverse(&where, mask))
-    return static_cast<int>(31 - where);
-  return 32; // Undefined Behavior.
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_clz(unsigned int x)
-{
-  return __builtin_clzl(x);
-}
-#endif // _LIBCPP_MSVC
-
-#endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H
diff --git a/lib/libcxx/lib/buildit b/lib/libcxx/lib/buildit
deleted file mode 100755 (executable)
index 6451a9b..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-#! /bin/sh
-#
-# Set the $TRIPLE environment variable to your system's triple before
-# running this script.  If you set $CXX, that will be used to compile
-# the library.  Otherwise we'll use clang++.
-
-set -e
-
-if [ `basename $(pwd)` != "lib" ]
-then
-    echo "current directory must be lib"
-    exit 1
-fi
-
-if [ -z "$CXX" ]
-then
-    CXX=clang++
-fi
-
-if [ -z "$CXX_LANG" ]
-then
-    CXX_LANG=c++11
-fi
-
-if [ -z "$CC" ]
-then
-    CC=clang
-fi
-
-if [ -z "$MACOSX_DEPLOYMENT_TARGET" ]
-then
-    if [ -z "$IPHONEOS_DEPLOYMENT_TARGET" ]
-    then
-        MACOSX_DEPLOYMENT_TARGET=10.7
-    fi
-fi
-
-if [ -z "$RC_ProjectSourceVersion" ]
-then
-  RC_ProjectSourceVersion=1
-fi
-
-EXTRA_FLAGS="-nostdinc++ -std=${CXX_LANG} -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \
-             -Wstrict-aliasing=2 -Wstrict-overflow=4 "
-
-case $TRIPLE in
-  *-apple-*)
-    if [ -z $RC_XBS ]
-    then
-      RC_CFLAGS="-arch i386 -arch x86_64"
-    fi
-    SOEXT=dylib
-    if [ "$MACOSX_DEPLOYMENT_TARGET" = "10.6" ]
-    then
-        EXTRA_FLAGS="-nostdinc++ -std=c++11 -U__STRICT_ANSI__"
-        LDSHARED_FLAGS="-o libc++.1.dylib \
-            -dynamiclib -nodefaultlibs -current_version 1 \
-            -compatibility_version 1 \
-            -install_name /usr/lib/libc++.1.dylib \
-            -Wl,-reexport_library,/usr/lib/libc++abi.dylib \
-            -Wl,-unexported_symbols_list,libc++unexp.exp  \
-            /usr/lib/libSystem.B.dylib"
-    else
-        if [ -n "$SDKROOT" ]
-        then
-            EXTRA_FLAGS+="-isysroot ${SDKROOT} "
-            if echo "${RC_ARCHS}" | grep -q "armv7"  
-            then
-                RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp"
-            else
-                RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib"
-            fi
-            CXX=`xcrun -sdk "${SDKROOT}"  -find clang++`
-            CC=`xcrun -sdk "${SDKROOT}"  -find clang`
-        else
-            # Check if we have _LIBCPPABI_VERSION, to determine the reexport list to use.
-            if (echo "#include <cxxabi.h>" | $CXX -E -dM -x c++ - | \
-                grep _LIBCPPABI_VERSION > /dev/null)
-            then
-                RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi2.exp"
-            else
-                RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp"
-            fi
-        fi
-        LDSHARED_FLAGS="-o libc++.1.dylib \
-            -dynamiclib -nodefaultlibs  \
-            -current_version ${RC_ProjectSourceVersion} \
-            -compatibility_version 1 \
-            -install_name /usr/lib/libc++.1.dylib \
-            -lSystem  \
-            -Wl,-unexported_symbols_list,libc++unexp.exp  \
-            ${RE_EXPORT_LINE}  \
-            -Wl,-force_symbols_not_weak_list,notweak.exp \
-            -Wl,-force_symbols_weak_list,weak.exp"
-    fi
-    ;;
-  *-*-mingw*)
-    # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt
-    SOEXT=dll
-    LDSHARED_FLAGS="-o libc++.dll \
-        -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \
-        -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt"
-    ;;
-  *-ibm-*)
-    hostOS=`uname`
-    hostOS=`echo $hostOS | sed -e "s/\s+$//"`
-    hostOS=`echo $hostOS | tr '[A-Z]' '[a-z]'`
-
-    if [ $hostOS = "linux" ]
-    then
-      LDSHARED_FLAGS="-o libc++.so.1 \
-        -qmkshrobj -Wl,-soname,libc++.so.1 \
-        -lpthread -lrt -lc -lstdc++"
-      EXTRA_FLAGS="-qlanglvl=extended0x -D__GLIBCXX__=1"
-    else
-      LDSHARED_FLAGS="-o shr.o -qmkshrobj -lpthread -bnoquiet"
-      EXTRA_FLAGS="-qlanglvl=extended0x"
-    fi
-    RC_CFLAGS="-qpic=large"
-    ;;
-  *)
-    RC_CFLAGS="-fPIC"
-    SOEXT=so
-    LDSHARED_FLAGS="-o libc++.so.1.0 \
-        -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \
-        -lpthread -lrt -lc -lstdc++"
-    ;;
-esac
-
-if [ -z "$RC_XBS" ]
-then
-    rm -f libc++.1.$SOEXT*
-fi
-
-set -x
-
-for FILE in ../src/*.cpp; do
-    $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE
-done
-case $TRIPLE in
-  *-*-mingw*)
-  for FILE in ../src/support/win32/*.cpp; do
-    $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE
-  done
-  ;;
-esac
-$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
-
-#libtool -static -o libc++.a *.o
-
-# Create the link for the final library name, so that we can use this directory
-# as a link target for the tests.
-case $TRIPLE in
-    *-apple-*)
-        rm -f libc++.dylib
-        ln -s libc++.1.dylib libc++.dylib
-        ;;
-    *-*-mingw*)
-        ;;
-    *-ibm-*)
-        if [ $hostOS = "linux" ]
-        then
-           rm -f libc++.so
-           ln -s libc++.so.1 libc++.so
-        else #AIX
-           rm -f libc++.a
-           ar r libc++.a shr.o
-        fi
-        ;;
-    *)
-        rm -f libc++.so
-        ln -s libc++.so.1 libc++.so
-        ;;
-esac
-
-if [ -z "$RC_XBS" ]
-then
-    rm *.o
-fi
index 1edea46..b52599a 100644 (file)
@@ -1,2 +1,2 @@
-major=1
+major=2
 minor=0
index f2fc1ce..c073927 100644 (file)
@@ -7,6 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define _LIBCPP_DEBUG 1
 #include "__config"
 #include "__debug"
 #include "functional"
diff --git a/lib/libcxx/src/support/solaris/xlocale.c b/lib/libcxx/src/support/solaris/xlocale.c
deleted file mode 100644 (file)
index 9125eea..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifdef __sun__
-
-#include "support/solaris/xlocale.h"
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/localedef.h>
-
-
-int isxdigit_l(int __c, locale_t __l) {
-    return isxdigit(__c);
-}
-
-int iswxdigit_l(wchar_t __c, locale_t __l) {
-    return isxdigit(__c);
-}
-
-// FIXME: This disregards the locale, which is Very Wrong
-#define vsnprintf_l(__s, __n, __l, __format, __va)  \
-    vsnprintf(__s, __n, __format, __va) 
-
-int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...)
-{
-  va_list __va;
-  va_start(__va, __format);
-  int __res = vsnprintf_l(__s, __n , __l, __format, __va);
-  va_end(__va);
-  return __res;
-}
-
-int asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
-  va_list __va;
-  va_start(__va, __format);
-  // FIXME:
-  int __res = vasprintf(__s, __format, __va);
-  va_end(__va);
-  return __res;
-}
-
-int sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
-  va_list __va;
-  va_start(__va, __format);
-  // FIXME:
-  int __res = vsscanf(__s, __format, __va);
-  va_end(__va);
-  return __res;
-}
-
-size_t mbrtowc_l(wchar_t *__pwc, const char *__pmb,
-                 size_t __max, mbstate_t *__ps, locale_t __loc) {
-  return mbrtowc(__pwc, __pmb, __max, __ps);
-}
-
-struct lconv *localeconv_l(locale_t __l) {
-  return localeconv();
-}
-
-#endif // __sun__
index d4977cd..62b8e9c 100644 (file)
 # endif // defined(BSD)
 #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
-#if !defined(_WIN32)
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__)
 # include <unistd.h>
-#endif // !_WIN32
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__)
 
 #if defined(__NetBSD__)
 #pragma weak pthread_create // Do not create libpthread dependency
 #endif
-#if defined(_WIN32)
+
+#if defined(_LIBCPP_WIN32API)
 #include <windows.h>
 #endif
 
@@ -39,7 +40,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 thread::~thread()
 {
-    if (__t_ != 0)
+    if (!__libcpp_thread_isnull(&__t_))
         terminate();
 }
 
@@ -47,32 +48,30 @@ void
 thread::join()
 {
     int ec = EINVAL;
-    if (__t_ != 0)
+    if (!__libcpp_thread_isnull(&__t_))
     {
         ec = __libcpp_thread_join(&__t_);
         if (ec == 0)
-            __t_ = 0;
+            __t_ = _LIBCPP_NULL_THREAD;
     }
-#ifndef _LIBCPP_NO_EXCEPTIONS
+
     if (ec)
-        throw system_error(error_code(ec, system_category()), "thread::join failed");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_system_error(ec, "thread::join failed");
 }
 
 void
 thread::detach()
 {
     int ec = EINVAL;
-    if (__t_ != 0)
+    if (!__libcpp_thread_isnull(&__t_))
     {
         ec = __libcpp_thread_detach(&__t_);
         if (ec == 0)
-            __t_ = 0;
+            __t_ = _LIBCPP_NULL_THREAD;
     }
-#ifndef _LIBCPP_NO_EXCEPTIONS
+
     if (ec)
-        throw system_error(error_code(ec, system_category()), "thread::detach failed");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_system_error(ec, "thread::detach failed");
 }
 
 unsigned
@@ -93,14 +92,14 @@ thread::hardware_concurrency() _NOEXCEPT
     if (result < 0)
         return 0;
     return static_cast<unsigned>(result);
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_WIN32API)
     SYSTEM_INFO info;
     GetSystemInfo(&info);
     return info.dwNumberOfProcessors;
 #else  // defined(CTL_HW) && defined(HW_NCPU)
     // TODO: grovel through /proc or check cpuid on x86 and similar
     // instructions on other architectures.
-#   if defined(_MSC_VER) && ! defined(__clang__)
+#   if defined(_LIBCPP_WARNING)
         _LIBCPP_WARNING("hardware_concurrency not yet implemented")
 #   else
 #       warning hardware_concurrency not yet implemented
@@ -115,26 +114,9 @@ namespace this_thread
 void
 sleep_for(const chrono::nanoseconds& ns)
 {
-    using namespace chrono;
-    if (ns > nanoseconds::zero())
+    if (ns > chrono::nanoseconds::zero())
     {
-        seconds s = duration_cast<seconds>(ns);
-        timespec ts;
-        typedef decltype(ts.tv_sec) ts_sec;
-        _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
-        if (s.count() < ts_sec_max)
-        {
-            ts.tv_sec = static_cast<ts_sec>(s.count());
-            ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((ns-s).count());
-        }
-        else
-        {
-            ts.tv_sec = ts_sec_max;
-            ts.tv_nsec = giga::num - 1;
-        }
-
-        while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
-            ;
+        __libcpp_thread_sleep_for(ns);
     }
 }
 
diff --git a/lib/libcxx/utils/gen_link_script/gen_link_script.py b/lib/libcxx/utils/gen_link_script/gen_link_script.py
deleted file mode 100755 (executable)
index 9f1f0b7..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-
-import os
-import sys
-
-def print_and_exit(msg):
-    sys.stderr.write(msg + '\n')
-    sys.exit(1)
-
-def usage_and_exit():
-    print_and_exit("Usage: ./gen_link_script.py [--help] [--dryrun] <path/to/libcxx.so> <abi_libname>")
-
-def help_and_exit():
-    help_msg = \
-"""Usage
-
-  gen_link_script.py [--help] [--dryrun] <path/to/libcxx.so> <abi_libname>
-
-  Generate a linker script that links libc++ to the proper ABI library.
-  The script replaces the specified libc++ symlink.
-  An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)".
-
-Arguments
-  <path/to/libcxx.so> - The top level symlink to the versioned libc++ shared
-                        library. This file is replaced with a linker script.
-  <abi_libname>       - The name of the ABI library to use in the linker script.
-                        The name must be one of [c++abi, stdc++, supc++, cxxrt].
-
-Exit Status:
-  0 if OK,
-  1 if the action failed.
-"""
-    print_and_exit(help_msg)
-
-def parse_args():
-    args = list(sys.argv)
-    del args[0]
-    if len(args) == 0:
-        usage_and_exit()
-    if args[0] == '--help':
-        help_and_exit()
-    dryrun = '--dryrun' == args[0]
-    if dryrun:
-        del args[0]
-    if len(args) != 2:
-        usage_and_exit()
-    symlink_file = args[0]
-    abi_libname = args[1]
-    return dryrun, symlink_file, abi_libname
-
-def main():
-    dryrun, symlink_file, abi_libname = parse_args()
-
-    # Check that the given libc++.so file is a valid symlink.
-    if not os.path.islink(symlink_file):
-        print_and_exit("symlink file %s is not a symlink" % symlink_file)
-
-    # Read the symlink so we know what libc++ to link to in the linker script.
-    linked_libcxx = os.readlink(symlink_file)
-
-    # Check that the abi_libname is one of the supported values.
-    supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt']
-    if abi_libname not in supported_abi_list:
-        print_and_exit("abi name '%s' is not supported: Use one of %r" %
-                        (abi_libname, supported_abi_list))
-
-    # Generate the linker script contents and print the script and destination
-    # information.
-    contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname)
-    print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file))
-
-    # Remove the existing libc++ symlink and replace it with the script.
-    if not dryrun:
-        os.unlink(symlink_file)
-        with open(symlink_file, 'w') as f:
-            f.write(contents + "\n")
-
-
-if __name__ == '__main__':
-    main()
diff --git a/lib/libcxx/utils/not/not.py b/lib/libcxx/utils/not/not.py
deleted file mode 100644 (file)
index d9ceb85..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-
-"""not.py is a utility for inverting the return code of commands.
-It acts similar to llvm/utils/not.
-ex: python /path/to/not.py ' echo hello
-    echo $? // (prints 1)
-"""
-
-import distutils.spawn
-import subprocess
-import sys
-
-
-def main():
-    argv = list(sys.argv)
-    del argv[0]
-    if len(argv) > 0 and argv[0] == '--crash':
-        del argv[0]
-        expectCrash = True
-    else:
-        expectCrash = False
-    if len(argv) == 0:
-        return 1
-    prog = distutils.spawn.find_executable(argv[0])
-    if prog is None:
-        sys.stderr.write('Failed to find program %s' % argv[0])
-        return 1
-    rc = subprocess.call(argv)
-    if rc < 0:
-        return 0 if expectCrash else 1
-    if expectCrash:
-        return 1
-    return rc == 0
-
-
-if __name__ == '__main__':
-    exit(main())
diff --git a/lib/libcxx/utils/sym_check/linux_blacklist.txt b/lib/libcxx/utils/sym_check/linux_blacklist.txt
deleted file mode 100644 (file)
index 4d9d1d4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# all guard variables
-_ZGVNSt3__
-# all vtables
-_ZTV
-# all VTT
-_ZTT
-# all non-virtual thunks
-_ZTh
-# all virtual thunks
-_ZTv
-# typeinfo for std::__1::__types
-#    There are no std::__types
-_ZTINSt3__1[0-9][0-9]*__
-# typeinfo name for std::__1::__types
-_ZTSNSt3__1[0-9][0-9]*__
-# anything using __hidden_allocator
-.*__hidden_allocator
-# anything using __sso_allocator
-.*__sso_allocator
diff --git a/lib/libcxx/utils/sym_check/osx_blacklist.txt b/lib/libcxx/utils/sym_check/osx_blacklist.txt
deleted file mode 100644 (file)
index cfa911e..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# all guard variables
-__ZGVNSt3__
-# all vtables
-__ZTV
-# all VTT
-__ZTT
-# all non-virtual thunks
-__ZTh
-# all virtual thunks
-__ZTv
-# typeinfo for std::__1::__types
-#    There are no std::__types
-__ZTINSt3__1[0-9][0-9]*__
-# typeinfo name for std::__1::__types
-__ZTSNSt3__1[0-9][0-9]*__
-# anything using __hidden_allocator
-.*__hidden_allocator
-# anything using __sso_allocator
-.*__sso_allocator
diff --git a/lib/libcxx/utils/sym_check/sym_check/__init__.py b/lib/libcxx/utils/sym_check/sym_check/__init__.py
deleted file mode 100644 (file)
index 1aa2b45..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-
-"""libcxx abi symbol checker"""
-
-__author__ = 'Eric Fiselier'
-__email__ = 'eric@efcs.ca'
-__versioninfo__ = (0, 1, 0)
-__version__ = ' '.join(str(v) for v in __versioninfo__) + 'dev'
-
-__all__ = ['diff', 'extract', 'util']
diff --git a/lib/libcxx/utils/sym_check/sym_check/diff.py b/lib/libcxx/utils/sym_check/sym_check/diff.py
deleted file mode 100644 (file)
index 6502a48..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80:
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-"""
-diff - A set of functions for diff-ing two symbol lists.
-"""
-
-from sym_check import util
-
-
-def _symbol_difference(lhs, rhs):
-    lhs_names = set((n['name'] for n in lhs))
-    rhs_names = set((n['name'] for n in rhs))
-    diff_names = lhs_names - rhs_names
-    return [n for n in lhs if n['name'] in diff_names]
-
-
-def _find_by_key(sym_list, k):
-    for sym in sym_list:
-        if sym['name'] == k:
-            return sym
-    return None
-
-
-def added_symbols(old, new):
-    return _symbol_difference(new, old)
-
-
-def removed_symbols(old, new):
-    return _symbol_difference(old, new)
-
-
-def changed_symbols(old, new):
-    changed = []
-    for old_sym in old:
-        if old_sym in new:
-            continue
-        new_sym = _find_by_key(new, old_sym['name'])
-        if (new_sym is not None and not new_sym in old
-                and cmp(old_sym, new_sym) != 0):
-            changed += [(old_sym, new_sym)]
-    return changed
-
-
-def diff(old, new):
-    added = added_symbols(old, new)
-    removed = removed_symbols(old, new)
-    changed = changed_symbols(old, new)
-    return added, removed, changed
-
-
-def report_diff(added_syms, removed_syms, changed_syms, names_only=False,
-                demangle=True):
-    def maybe_demangle(name):
-        return util.demangle_symbol(name) if demangle else name
-
-    report = ''
-    for sym in added_syms:
-        report += 'Symbol added: %s\n' % maybe_demangle(sym['name'])
-        if not names_only:
-            report += '    %s\n\n' % sym
-    if added_syms and names_only:
-        report += '\n'
-    for sym in removed_syms:
-        report += 'SYMBOL REMOVED: %s\n' % maybe_demangle(sym['name'])
-        if not names_only:
-            report += '    %s\n\n' % sym
-    if removed_syms and names_only:
-        report += '\n'
-    if not names_only:
-        for sym_pair in changed_syms:
-            old_sym, new_sym = sym_pair
-            old_str = '\n    OLD SYMBOL: %s' % old_sym
-            new_str = '\n    NEW SYMBOL: %s' % new_sym
-            report += ('SYMBOL CHANGED: %s%s%s\n\n' %
-                       (maybe_demangle(old_sym['name']),
-                        old_str, new_str))
-
-    added = bool(len(added_syms) != 0)
-    abi_break = bool(len(removed_syms))
-    if not names_only:
-        abi_break = abi_break or len(changed_syms)
-    if added or abi_break:
-        report += 'Summary\n'
-        report += '    Added:   %d\n' % len(added_syms)
-        report += '    Removed: %d\n' % len(removed_syms)
-        if not names_only:
-            report += '    Changed: %d\n' % len(changed_syms)
-        if not abi_break:
-            report += 'Symbols added.'
-        else:
-            report += 'ABI BREAKAGE: SYMBOLS ADDED OR REMOVED!'
-    else:
-        report += 'Symbols match.'
-    return report, int(abi_break)
diff --git a/lib/libcxx/utils/sym_check/sym_check/extract.py b/lib/libcxx/utils/sym_check/sym_check/extract.py
deleted file mode 100644 (file)
index 7bafd8e..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80:
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-"""
-extract - A set of function that extract symbol lists from shared libraries.
-"""
-import distutils.spawn
-import sys
-
-from sym_check import util
-
-
-class NMExtractor(object):
-    """
-    NMExtractor - Extract symbol lists from libraries using nm.
-    """
-
-    @staticmethod
-    def find_tool():
-        """
-        Search for the nm executable and return the path.
-        """
-        return distutils.spawn.find_executable('nm')
-
-    def __init__(self):
-        """
-        Initialize the nm executable and flags that will be used to extract
-        symbols from shared libraries.
-        """
-        self.nm_exe = self.find_tool()
-        if self.nm_exe is None:
-            # ERROR no NM found
-            print("ERROR: Could not find nm")
-            sys.exit(1)
-        self.flags = ['-P', '-g']
-
-    def extract(self, lib):
-        """
-        Extract symbols from a library and return the results as a dict of
-        parsed symbols.
-        """
-        cmd = [self.nm_exe] + self.flags + [lib]
-        out, _, exit_code = util.execute_command_verbose(cmd)
-        if exit_code != 0:
-            raise RuntimeError('Failed to run %s on %s' % (self.nm_exe, lib))
-        fmt_syms = (self._extract_sym(l)
-                    for l in out.splitlines() if l.strip())
-            # Cast symbol to string.
-        final_syms = (repr(s) for s in fmt_syms if self._want_sym(s))
-        # Make unique and sort strings.
-        tmp_list = list(sorted(set(final_syms)))
-        # Cast string back to symbol.
-        return util.read_syms_from_list(tmp_list)
-
-    def _extract_sym(self, sym_str):
-        bits = sym_str.split()
-        # Everything we want has at least two columns.
-        if len(bits) < 2:
-            return None
-        new_sym = {
-            'name': bits[0],
-            'type': bits[1]
-        }
-        new_sym['name'] = new_sym['name'].replace('@@', '@')
-        new_sym = self._transform_sym_type(new_sym)
-        # NM types which we want to save the size for.
-        if new_sym['type'] == 'OBJECT' and len(bits) > 3:
-            new_sym['size'] = int(bits[3], 16)
-        return new_sym
-
-    @staticmethod
-    def _want_sym(sym):
-        """
-        Check that s is a valid symbol that we want to keep.
-        """
-        if sym is None or len(sym) < 2:
-            return False
-        bad_types = ['t', 'b', 'r', 'd', 'w']
-        return (sym['type'] not in bad_types
-                and sym['name'] not in ['__bss_start', '_end', '_edata'])
-
-    @staticmethod
-    def _transform_sym_type(sym):
-        """
-        Map the nm single letter output for type to either FUNC or OBJECT.
-        If the type is not recognized it is left unchanged.
-        """
-        func_types = ['T', 'W']
-        obj_types = ['B', 'D', 'R', 'V', 'S']
-        if sym['type'] in func_types:
-            sym['type'] = 'FUNC'
-        elif sym['type'] in obj_types:
-            sym['type'] = 'OBJECT'
-        return sym
-
-class ReadElfExtractor(object):
-    """
-    ReadElfExtractor - Extract symbol lists from libraries using readelf.
-    """
-
-    @staticmethod
-    def find_tool():
-        """
-        Search for the readelf executable and return the path.
-        """
-        return distutils.spawn.find_executable('readelf')
-
-    def __init__(self):
-        """
-        Initialize the readelf executable and flags that will be used to
-        extract symbols from shared libraries.
-        """
-        self.tool = self.find_tool()
-        if self.tool is None:
-            # ERROR no NM found
-            print("ERROR: Could not find readelf")
-            sys.exit(1)
-        self.flags = ['--wide', '--symbols']
-
-    def extract(self, lib):
-        """
-        Extract symbols from a library and return the results as a dict of
-        parsed symbols.
-        """
-        cmd = [self.tool] + self.flags + [lib]
-        out, _, exit_code = util.execute_command_verbose(cmd)
-        if exit_code != 0:
-            raise RuntimeError('Failed to run %s on %s' % (self.nm_exe, lib))
-        dyn_syms = self.get_dynsym_table(out)
-        return self.process_syms(dyn_syms)
-
-    def process_syms(self, sym_list):
-        new_syms = []
-        for s in sym_list:
-            parts = s.split()
-            if not parts:
-                continue
-            assert len(parts) == 7 or len(parts) == 8 or len(parts) == 9
-            if len(parts) == 7:
-                continue
-            new_sym = {
-                'name': parts[7],
-                'size': int(parts[2]),
-                'type': parts[3],
-            }
-            assert new_sym['type'] in ['OBJECT', 'FUNC', 'NOTYPE']
-            if new_sym['type'] == 'NOTYPE':
-                continue
-            if new_sym['type'] == 'FUNC':
-                del new_sym['size']
-            new_syms += [new_sym]
-        return new_syms
-
-    def get_dynsym_table(self, out):
-        lines = out.splitlines()
-        start = -1
-        end = -1
-        for i in range(len(lines)):
-            if lines[i].startswith("Symbol table '.dynsym'"):
-                start = i + 2
-            if start != -1 and end == -1 and not lines[i].strip():
-                end = i + 1
-        assert start != -1
-        if end == -1:
-            end = len(lines)
-        return lines[start:end]
-
-
-def extract_symbols(lib_file):
-    """
-    Extract and return a list of symbols extracted from a dynamic library.
-    The symbols are extracted using NM. They are then filtered and formated.
-    Finally they symbols are made unique.
-    """
-    if ReadElfExtractor.find_tool():
-        extractor = ReadElfExtractor()
-    else:
-        extractor = NMExtractor()
-    return extractor.extract(lib_file)
diff --git a/lib/libcxx/utils/sym_check/sym_check/match.py b/lib/libcxx/utils/sym_check/sym_check/match.py
deleted file mode 100644 (file)
index fae400e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80:
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-"""
-match - A set of functions for matching symbols in a list to a list of regexs
-"""
-
-import re
-
-
-def find_and_report_matching(symbol_list, regex_list):
-    report = ''
-    found_count = 0
-    for regex_str in regex_list:
-        report += 'Matching regex "%s":\n' % regex_str
-        matching_list = find_matching_symbols(symbol_list, regex_str)
-        if not matching_list:
-            report += '    No matches found\n\n'
-            continue
-        # else
-        found_count += len(matching_list)
-        for m in matching_list:
-            report += '    MATCHES: %s\n' % m['name']
-        report += '\n'
-    return found_count, report
-
-
-def find_matching_symbols(symbol_list, regex_str):
-    regex = re.compile(regex_str)
-    matching_list = []
-    for s in symbol_list:
-        if regex.match(s['name']):
-            matching_list += [s]
-    return matching_list
diff --git a/lib/libcxx/utils/sym_check/sym_check/util.py b/lib/libcxx/utils/sym_check/sym_check/util.py
deleted file mode 100644 (file)
index 6ae71b0..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-
-import ast
-import distutils.spawn
-import signal
-import subprocess
-import sys
-
-
-def execute_command(cmd, input_str=None):
-    """
-    Execute a command, capture and return its output.
-    """
-    kwargs = {
-        'stdin': subprocess.PIPE,
-        'stdout': subprocess.PIPE,
-        'stderr': subprocess.PIPE,
-    }
-    p = subprocess.Popen(cmd, **kwargs)
-    out, err = p.communicate(input=input_str)
-    exitCode = p.wait()
-    if exitCode == -signal.SIGINT:
-        raise KeyboardInterrupt
-    return out, err, exitCode
-
-
-def execute_command_verbose(cmd, input_str=None):
-    """
-    Execute a command and print its output on failure.
-    """
-    out, err, exitCode = execute_command(cmd, input_str=input_str)
-    if exitCode != 0:
-        report = "Command: %s\n" % ' '.join(["'%s'" % a for a in cmd])
-        report += "Exit Code: %d\n" % exitCode
-        if out:
-            report += "Standard Output:\n--\n%s--" % out
-        if err:
-            report += "Standard Error:\n--\n%s--" % err
-        report += "\n\nFailed!"
-        sys.stderr.write('%s\n' % report)
-    return out, err, exitCode
-
-
-def read_syms_from_list(slist):
-    """
-    Read a list of symbols from a list of strings.
-    Each string is one symbol.
-    """
-    return [ast.literal_eval(l) for l in slist]
-
-
-def read_syms_from_file(filename):
-    """
-    Read a list of symbols in from a file.
-    """
-    with open(filename, 'r') as f:
-        data = f.read()
-    return read_syms_from_list(data.splitlines())
-
-
-def read_blacklist(filename):
-    with open(filename, 'r') as f:
-        data = f.read()
-    lines = [l.strip() for l in data.splitlines() if l.strip()]
-    lines = [l for l in lines if not l.startswith('#')]
-    return lines
-
-
-def write_syms(sym_list, out=None, names_only=False):
-    """
-    Write a list of symbols to the file named by out.
-    """
-    out_str = ''
-    out_list = sym_list
-    if names_only:
-        out_list = [sym['name'] for sym in sym_list]
-        out_list.sort()
-    for sym in out_list:
-        out_str += '%s\n' % sym
-    if out is None:
-        sys.stdout.write(out_str)
-    else:
-        with open(out, 'w') as f:
-            f.write(out_str)
-
-
-_cppfilt_exe = distutils.spawn.find_executable('c++filt')
-
-
-def demangle_symbol(symbol):
-    if _cppfilt_exe is None:
-        return symbol
-    out, _, exit_code = execute_command_verbose(
-        [_cppfilt_exe], input_str=symbol)
-    if exit_code != 0:
-        return symbol
-    return out
-
-
-def is_elf(filename):
-    with open(filename, 'r') as f:
-        magic_bytes = f.read(4)
-    return magic_bytes == '\x7fELF'
-
-
-def is_mach_o(filename):
-    with open(filename, 'r') as f:
-        magic_bytes = f.read(4)
-    return magic_bytes in [
-        '\xfe\xed\xfa\xce',  # MH_MAGIC
-        '\xce\xfa\xed\xfe',  # MH_CIGAM
-        '\xfe\xed\xfa\xcf',  # MH_MAGIC_64
-        '\xcf\xfa\xed\xfe',  # MH_CIGAM_64
-        '\xca\xfe\xba\xbe',  # FAT_MAGIC
-        '\xbe\xba\xfe\xca'   # FAT_CIGAM
-    ]
-
-
-def is_library_file(filename):
-    if sys.platform == 'darwin':
-        return is_mach_o(filename)
-    else:
-        return is_elf(filename)
-
-
-def extract_or_load(filename):
-    import sym_check.extract
-    if is_library_file(filename):
-        return sym_check.extract.extract_symbols(filename)
-    return read_syms_from_file(filename)
diff --git a/lib/libcxx/utils/sym_check/sym_diff.py b/lib/libcxx/utils/sym_check/sym_diff.py
deleted file mode 100755 (executable)
index 69c3400..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env python
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-"""
-sym_diff - Compare two symbol lists and output the differences.
-"""
-
-from argparse import ArgumentParser
-import sys
-from sym_check import diff, util
-
-
-def main():
-    parser = ArgumentParser(
-        description='Extract a list of symbols from a shared library.')
-    parser.add_argument(
-        '--names-only', dest='names_only',
-        help='Only print symbol names',
-        action='store_true', default=False)
-    parser.add_argument(
-        '-o', '--output', dest='output',
-        help='The output file. stdout is used if not given',
-        type=str, action='store', default=None)
-    parser.add_argument(
-        '--demangle', dest='demangle', action='store_true', default=False)
-    parser.add_argument(
-        'old_syms', metavar='old-syms', type=str,
-        help='The file containing the old symbol list or a library')
-    parser.add_argument(
-        'new_syms', metavar='new-syms', type=str,
-        help='The file containing the new symbol list or a library')
-    args = parser.parse_args()
-
-    old_syms_list = util.extract_or_load(args.old_syms)
-    new_syms_list = util.extract_or_load(args.new_syms)
-
-    added, removed, changed = diff.diff(old_syms_list, new_syms_list)
-    report, is_break = diff.report_diff(added, removed, changed,
-                                        names_only=args.names_only,
-                                        demangle=args.demangle)
-    if args.output is None:
-        print(report)
-    else:
-        with open(args.output, 'w') as f:
-            f.write(report + '\n')
-    sys.exit(is_break)
-
-
-if __name__ == '__main__':
-    main()
diff --git a/lib/libcxx/utils/sym_check/sym_extract.py b/lib/libcxx/utils/sym_check/sym_extract.py
deleted file mode 100755 (executable)
index a0fbb3e..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env python
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-"""
-sym_extract - Extract and output a list of symbols from a shared library.
-"""
-from argparse import ArgumentParser
-from sym_check import extract, util
-
-
-def main():
-    parser = ArgumentParser(
-        description='Extract a list of symbols from a shared library.')
-    parser.add_argument('library', metavar='shared-lib', type=str,
-                        help='The library to extract symbols from')
-    parser.add_argument('-o', '--output', dest='output',
-                        help='The output file. stdout is used if not given',
-                        type=str, action='store', default=None)
-    parser.add_argument('--names-only', dest='names_only',
-                        help='Output only the name of the symbol',
-                        action='store_true', default=False)
-    args = parser.parse_args()
-    if args.output is not None:
-        print('Extracting symbols from %s to %s.'
-              % (args.library, args.output))
-    syms = extract.extract_symbols(args.library)
-    util.write_syms(syms, out=args.output, names_only=args.names_only)
-
-
-if __name__ == '__main__':
-    main()
diff --git a/lib/libcxx/utils/sym_check/sym_match.py b/lib/libcxx/utils/sym_check/sym_match.py
deleted file mode 100755 (executable)
index 231bdc8..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-#===----------------------------------------------------------------------===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===----------------------------------------------------------------------===##
-
-"""
-sym_match - Match all symbols in a list against a list of regexes.
-"""
-from argparse import ArgumentParser
-import sys
-from sym_check import util, match, extract
-
-
-def main():
-    parser = ArgumentParser(
-        description='Extract a list of symbols from a shared library.')
-    parser.add_argument(
-        '--blacklist', dest='blacklist',
-        type=str, action='store', default=None)
-    parser.add_argument(
-        'symbol_list', metavar='symbol_list', type=str,
-        help='The file containing the old symbol list')
-    parser.add_argument(
-        'regexes', metavar='regexes', default=[], nargs='*',
-        help='The file containing the new symbol list or a library')
-    args = parser.parse_args()
-
-    if not args.regexes and args.blacklist is None:
-        sys.stderr.write('Either a regex or a blacklist must be specified.\n')
-        sys.exit(1)
-    if args.blacklist:
-        search_list = util.read_blacklist(args.blacklist)
-    else:
-        search_list = args.regexes
-
-    symbol_list = util.extract_or_load(args.symbol_list)
-
-    matching_count, report = match.find_and_report_matching(
-        symbol_list, search_list)
-    sys.stdout.write(report)
-    if matching_count != 0:
-        print('%d matching symbols found...' % matching_count)
-
-
-if __name__ == '__main__':
-    main()