diff options
Diffstat (limited to 'lib/libcxx/include')
-rw-r--r-- | lib/libcxx/include/__config | 847 | ||||
-rw-r--r-- | lib/libcxx/include/__locale | 96 | ||||
-rw-r--r-- | lib/libcxx/include/__refstring | 139 | ||||
-rw-r--r-- | lib/libcxx/include/__undef___deallocate | 20 | ||||
-rw-r--r-- | lib/libcxx/include/__undef_min_max | 33 | ||||
-rw-r--r-- | lib/libcxx/include/cstdio | 4 | ||||
-rw-r--r-- | lib/libcxx/include/stdio.h | 6 | ||||
-rw-r--r-- | lib/libcxx/include/support/newlib/xlocale.h | 5 | ||||
-rw-r--r-- | lib/libcxx/include/support/win32/limits_win32.h | 79 | ||||
-rw-r--r-- | lib/libcxx/include/support/win32/locale_mgmt_win32.h | 33 | ||||
-rw-r--r-- | lib/libcxx/include/support/win32/math_win32.h | 117 | ||||
-rw-r--r-- | lib/libcxx/include/support/win32/support.h | 206 |
12 files changed, 696 insertions, 889 deletions
diff --git a/lib/libcxx/include/__config b/lib/libcxx/include/__config index 227fc4a355b..4be3d2c06be 100644 --- a/lib/libcxx/include/__config +++ b/lib/libcxx/include/__config @@ -12,8 +12,10 @@ #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 @@ -23,30 +25,73 @@ #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__) @@ -64,6 +109,9 @@ #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) +#if __cplusplus < 201103L +#define _LIBCPP_CXX03_LANG +#endif #ifndef __has_attribute #define __has_attribute(__x) 0 @@ -77,45 +125,96 @@ #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 @@ -125,11 +224,9 @@ #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__ @@ -137,41 +234,47 @@ #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__ @@ -181,126 +284,42 @@ // 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 @@ -313,10 +332,6 @@ # 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 diff --git a/lib/libcxx/include/__locale b/lib/libcxx/include/__locale index 404b898b9d8..bface07aa68 100644 --- a/lib/libcxx/include/__locale +++ b/lib/libcxx/include/__locale @@ -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> @@ -34,12 +34,14 @@ # 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 @@ -47,6 +49,51 @@ _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 index 61ccc75122a..00000000000 --- a/lib/libcxx/include/__refstring +++ /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 index 52f4d9987e2..00000000000 --- a/lib/libcxx/include/__undef___deallocate +++ /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 index d3c31388cea..00000000000 --- a/lib/libcxx/include/__undef_min_max +++ /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 diff --git a/lib/libcxx/include/cstdio b/lib/libcxx/include/cstdio index 478517622cd..48643c5eb4b 100644 --- a/lib/libcxx/include/cstdio +++ b/lib/libcxx/include/cstdio @@ -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; diff --git a/lib/libcxx/include/stdio.h b/lib/libcxx/include/stdio.h index c135be78f0d..616d0a02d6a 100644 --- a/lib/libcxx/include/stdio.h +++ b/lib/libcxx/include/stdio.h @@ -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 diff --git a/lib/libcxx/include/support/newlib/xlocale.h b/lib/libcxx/include/support/newlib/xlocale.h index 04e41d40971..2afb95e48bf 100644 --- a/lib/libcxx/include/support/newlib/xlocale.h +++ b/lib/libcxx/include/support/newlib/xlocale.h @@ -16,8 +16,11 @@ #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 index 406cd3025bf..00000000000 --- a/lib/libcxx/include/support/win32/limits_win32.h +++ /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 index b3316d62596..00000000000 --- a/lib/libcxx/include/support/win32/locale_mgmt_win32.h +++ /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 index 0d6b422a165..00000000000 --- a/lib/libcxx/include/support/win32/math_win32.h +++ /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 index 5765babcd13..00000000000 --- a/lib/libcxx/include/support/win32/support.h +++ /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 |