10b57cec5SDimitry Andric// -*- C++ -*- 20b57cec5SDimitry Andric//===--------------------------- __config ---------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_CONFIG 110b57cec5SDimitry Andric#define _LIBCPP_CONFIG 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric#if defined(_MSC_VER) && !defined(__clang__) 140b57cec5SDimitry Andric# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 150b57cec5SDimitry Andric# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 160b57cec5SDimitry Andric# endif 170b57cec5SDimitry Andric#endif 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 200b57cec5SDimitry Andric#pragma GCC system_header 210b57cec5SDimitry Andric#endif 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric#ifdef __cplusplus 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric#ifdef __GNUC__ 260b57cec5SDimitry Andric# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) 270b57cec5SDimitry Andric// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme 280b57cec5SDimitry Andric// introduced in GCC 5.0. 290b57cec5SDimitry Andric# define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) 300b57cec5SDimitry Andric#else 310b57cec5SDimitry Andric# define _GNUC_VER 0 320b57cec5SDimitry Andric# define _GNUC_VER_NEW 0 330b57cec5SDimitry Andric#endif 340b57cec5SDimitry Andric 35*5ffd83dbSDimitry Andric#define _LIBCPP_VERSION 11000 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric#ifndef _LIBCPP_ABI_VERSION 380b57cec5SDimitry Andric# define _LIBCPP_ABI_VERSION 1 390b57cec5SDimitry Andric#endif 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric#ifndef __STDC_HOSTED__ 420b57cec5SDimitry Andric# define _LIBCPP_FREESTANDING 430b57cec5SDimitry Andric#endif 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric#ifndef _LIBCPP_STD_VER 460b57cec5SDimitry Andric# if __cplusplus <= 201103L 470b57cec5SDimitry Andric# define _LIBCPP_STD_VER 11 480b57cec5SDimitry Andric# elif __cplusplus <= 201402L 490b57cec5SDimitry Andric# define _LIBCPP_STD_VER 14 500b57cec5SDimitry Andric# elif __cplusplus <= 201703L 510b57cec5SDimitry Andric# define _LIBCPP_STD_VER 17 520b57cec5SDimitry Andric# else 530b57cec5SDimitry Andric# define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification 540b57cec5SDimitry Andric# endif 550b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric#if defined(__ELF__) 580b57cec5SDimitry Andric# define _LIBCPP_OBJECT_FORMAT_ELF 1 590b57cec5SDimitry Andric#elif defined(__MACH__) 600b57cec5SDimitry Andric# define _LIBCPP_OBJECT_FORMAT_MACHO 1 610b57cec5SDimitry Andric#elif defined(_WIN32) 620b57cec5SDimitry Andric# define _LIBCPP_OBJECT_FORMAT_COFF 1 630b57cec5SDimitry Andric#elif defined(__wasm__) 640b57cec5SDimitry Andric# define _LIBCPP_OBJECT_FORMAT_WASM 1 650b57cec5SDimitry Andric#else 660b57cec5SDimitry Andric# error Unknown object file format 670b57cec5SDimitry Andric#endif 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 700b57cec5SDimitry Andric// Change short string representation so that string data starts at offset 0, 710b57cec5SDimitry Andric// improving its alignment in some cases. 720b57cec5SDimitry Andric# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 730b57cec5SDimitry Andric// Fix deque iterator type in order to support incomplete types. 740b57cec5SDimitry Andric# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 750b57cec5SDimitry Andric// Fix undefined behavior in how std::list stores its linked nodes. 760b57cec5SDimitry Andric# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 770b57cec5SDimitry Andric// Fix undefined behavior in how __tree stores its end and parent nodes. 780b57cec5SDimitry Andric# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 790b57cec5SDimitry Andric// Fix undefined behavior in how __hash_table stores its pointer types. 800b57cec5SDimitry Andric# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 810b57cec5SDimitry Andric# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 820b57cec5SDimitry Andric# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 830b57cec5SDimitry Andric// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr 840b57cec5SDimitry Andric// provided under the alternate keyword __nullptr, which changes the mangling 850b57cec5SDimitry Andric// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. 860b57cec5SDimitry Andric# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR 870b57cec5SDimitry Andric// Define the `pointer_safety` enum as a C++11 strongly typed enumeration 880b57cec5SDimitry Andric// instead of as a class simulating an enum. If this option is enabled 890b57cec5SDimitry Andric// `pointer_safety` and `get_pointer_safety()` will no longer be available 900b57cec5SDimitry Andric// in C++03. 910b57cec5SDimitry Andric# define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE 920b57cec5SDimitry Andric// Define a key function for `bad_function_call` in the library, to centralize 930b57cec5SDimitry Andric// its vtable and typeinfo to libc++ rather than having all other libraries 940b57cec5SDimitry Andric// using that class define their own copies. 950b57cec5SDimitry Andric# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 960b57cec5SDimitry Andric// Enable optimized version of __do_get_(un)signed which avoids redundant copies. 970b57cec5SDimitry Andric# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET 980b57cec5SDimitry Andric// Use the smallest possible integer type to represent the index of the variant. 990b57cec5SDimitry Andric// Previously libc++ used "unsigned int" exclusively. 1000b57cec5SDimitry Andric# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION 1010b57cec5SDimitry Andric// Unstable attempt to provide a more optimized std::function 1020b57cec5SDimitry Andric# define _LIBCPP_ABI_OPTIMIZED_FUNCTION 1030b57cec5SDimitry Andric// All the regex constants must be distinct and nonzero. 1040b57cec5SDimitry Andric# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO 105*5ffd83dbSDimitry Andric// Re-worked external template instantiations for std::string with a focus on 106*5ffd83dbSDimitry Andric// performance and fast-path inlining. 107*5ffd83dbSDimitry Andric# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION 1080b57cec5SDimitry Andric#elif _LIBCPP_ABI_VERSION == 1 1090b57cec5SDimitry Andric# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) 1100b57cec5SDimitry Andric// Enable compiling copies of now inline methods into the dylib to support 1110b57cec5SDimitry Andric// applications compiled against older libraries. This is unnecessary with 1120b57cec5SDimitry Andric// COFF dllexport semantics, since dllexport forces a non-inline definition 1130b57cec5SDimitry Andric// of inline functions to be emitted anyway. Our own non-inline copy would 1140b57cec5SDimitry Andric// conflict with the dllexport-emitted copy, so we disable it. 1150b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS 1160b57cec5SDimitry Andric# endif 1170b57cec5SDimitry Andric// Feature macros for disabling pre ABI v1 features. All of these options 1180b57cec5SDimitry Andric// are deprecated. 1190b57cec5SDimitry Andric# if defined(__FreeBSD__) 1200b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 1210b57cec5SDimitry Andric# endif 1220b57cec5SDimitry Andric#endif 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andric#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1250b57cec5SDimitry Andric#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \ 1260b57cec5SDimitry Andric use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead 1270b57cec5SDimitry Andric#endif 1280b57cec5SDimitry Andric 1290b57cec5SDimitry Andric#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y 1300b57cec5SDimitry Andric#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) 1310b57cec5SDimitry Andric 1320b57cec5SDimitry Andric#ifndef _LIBCPP_ABI_NAMESPACE 1330b57cec5SDimitry Andric# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) 1340b57cec5SDimitry Andric#endif 1350b57cec5SDimitry Andric 1360b57cec5SDimitry Andric#if __cplusplus < 201103L 1370b57cec5SDimitry Andric#define _LIBCPP_CXX03_LANG 1380b57cec5SDimitry Andric#endif 1390b57cec5SDimitry Andric 1400b57cec5SDimitry Andric#ifndef __has_attribute 1410b57cec5SDimitry Andric#define __has_attribute(__x) 0 1420b57cec5SDimitry Andric#endif 1430b57cec5SDimitry Andric 1440b57cec5SDimitry Andric#ifndef __has_builtin 1450b57cec5SDimitry Andric#define __has_builtin(__x) 0 1460b57cec5SDimitry Andric#endif 1470b57cec5SDimitry Andric 1480b57cec5SDimitry Andric#ifndef __has_extension 1490b57cec5SDimitry Andric#define __has_extension(__x) 0 1500b57cec5SDimitry Andric#endif 1510b57cec5SDimitry Andric 1520b57cec5SDimitry Andric#ifndef __has_feature 1530b57cec5SDimitry Andric#define __has_feature(__x) 0 1540b57cec5SDimitry Andric#endif 1550b57cec5SDimitry Andric 1560b57cec5SDimitry Andric#ifndef __has_cpp_attribute 1570b57cec5SDimitry Andric#define __has_cpp_attribute(__x) 0 1580b57cec5SDimitry Andric#endif 1590b57cec5SDimitry Andric 1600b57cec5SDimitry Andric// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by 1610b57cec5SDimitry Andric// the compiler and '1' otherwise. 1620b57cec5SDimitry Andric#ifndef __is_identifier 1630b57cec5SDimitry Andric#define __is_identifier(__x) 1 1640b57cec5SDimitry Andric#endif 1650b57cec5SDimitry Andric 1660b57cec5SDimitry Andric#ifndef __has_declspec_attribute 1670b57cec5SDimitry Andric#define __has_declspec_attribute(__x) 0 1680b57cec5SDimitry Andric#endif 1690b57cec5SDimitry Andric 1700b57cec5SDimitry Andric#define __has_keyword(__x) !(__is_identifier(__x)) 1710b57cec5SDimitry Andric 1720b57cec5SDimitry Andric#ifndef __has_include 1730b57cec5SDimitry Andric#define __has_include(...) 0 1740b57cec5SDimitry Andric#endif 1750b57cec5SDimitry Andric 1760b57cec5SDimitry Andric#if defined(__clang__) 1770b57cec5SDimitry Andric# define _LIBCPP_COMPILER_CLANG 1780b57cec5SDimitry Andric# ifndef __apple_build_version__ 1790b57cec5SDimitry Andric# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) 1800b57cec5SDimitry Andric# endif 1810b57cec5SDimitry Andric#elif defined(__GNUC__) 1820b57cec5SDimitry Andric# define _LIBCPP_COMPILER_GCC 1830b57cec5SDimitry Andric#elif defined(_MSC_VER) 1840b57cec5SDimitry Andric# define _LIBCPP_COMPILER_MSVC 1850b57cec5SDimitry Andric#elif defined(__IBMCPP__) 1860b57cec5SDimitry Andric# define _LIBCPP_COMPILER_IBM 1870b57cec5SDimitry Andric#endif 1880b57cec5SDimitry Andric 1890b57cec5SDimitry Andric#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L 1900b57cec5SDimitry Andric#error "libc++ does not support using GCC with C++03. Please enable C++11" 1910b57cec5SDimitry Andric#endif 1920b57cec5SDimitry Andric 1930b57cec5SDimitry Andric// FIXME: ABI detection should be done via compiler builtin macros. This 1940b57cec5SDimitry Andric// is just a placeholder until Clang implements such macros. For now assume 1950b57cec5SDimitry Andric// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, 1960b57cec5SDimitry Andric// and allow the user to explicitly specify the ABI to handle cases where this 1970b57cec5SDimitry Andric// heuristic falls short. 1980b57cec5SDimitry Andric#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) 1990b57cec5SDimitry Andric# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" 2000b57cec5SDimitry Andric#elif defined(_LIBCPP_ABI_FORCE_ITANIUM) 2010b57cec5SDimitry Andric# define _LIBCPP_ABI_ITANIUM 2020b57cec5SDimitry Andric#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) 2030b57cec5SDimitry Andric# define _LIBCPP_ABI_MICROSOFT 2040b57cec5SDimitry Andric#else 2050b57cec5SDimitry Andric# if defined(_WIN32) && defined(_MSC_VER) 2060b57cec5SDimitry Andric# define _LIBCPP_ABI_MICROSOFT 2070b57cec5SDimitry Andric# else 2080b57cec5SDimitry Andric# define _LIBCPP_ABI_ITANIUM 2090b57cec5SDimitry Andric# endif 2100b57cec5SDimitry Andric#endif 2110b57cec5SDimitry Andric 2120b57cec5SDimitry Andric#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) 2130b57cec5SDimitry Andric# define _LIBCPP_ABI_VCRUNTIME 2140b57cec5SDimitry Andric#endif 2150b57cec5SDimitry Andric 2160b57cec5SDimitry Andric// Need to detect which libc we're using if we're on Linux. 2170b57cec5SDimitry Andric#if defined(__linux__) 2180b57cec5SDimitry Andric# include <features.h> 2190b57cec5SDimitry Andric# if defined(__GLIBC_PREREQ) 2200b57cec5SDimitry Andric# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) 2210b57cec5SDimitry Andric# else 2220b57cec5SDimitry Andric# define _LIBCPP_GLIBC_PREREQ(a, b) 0 2230b57cec5SDimitry Andric# endif // defined(__GLIBC_PREREQ) 2240b57cec5SDimitry Andric#endif // defined(__linux__) 2250b57cec5SDimitry Andric 2260b57cec5SDimitry Andric#ifdef __LITTLE_ENDIAN__ 2270b57cec5SDimitry Andric# if __LITTLE_ENDIAN__ 2280b57cec5SDimitry Andric# define _LIBCPP_LITTLE_ENDIAN 2290b57cec5SDimitry Andric# endif // __LITTLE_ENDIAN__ 2300b57cec5SDimitry Andric#endif // __LITTLE_ENDIAN__ 2310b57cec5SDimitry Andric 2320b57cec5SDimitry Andric#ifdef __BIG_ENDIAN__ 2330b57cec5SDimitry Andric# if __BIG_ENDIAN__ 2340b57cec5SDimitry Andric# define _LIBCPP_BIG_ENDIAN 2350b57cec5SDimitry Andric# endif // __BIG_ENDIAN__ 2360b57cec5SDimitry Andric#endif // __BIG_ENDIAN__ 2370b57cec5SDimitry Andric 2380b57cec5SDimitry Andric#ifdef __BYTE_ORDER__ 2390b57cec5SDimitry Andric# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 2400b57cec5SDimitry Andric# define _LIBCPP_LITTLE_ENDIAN 2410b57cec5SDimitry Andric# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 2420b57cec5SDimitry Andric# define _LIBCPP_BIG_ENDIAN 2430b57cec5SDimitry Andric# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 2440b57cec5SDimitry Andric#endif // __BYTE_ORDER__ 2450b57cec5SDimitry Andric 2460b57cec5SDimitry Andric#ifdef __FreeBSD__ 2470b57cec5SDimitry Andric# include <sys/endian.h> 2480b57cec5SDimitry Andric# include <osreldate.h> 2490b57cec5SDimitry Andric# if _BYTE_ORDER == _LITTLE_ENDIAN 2500b57cec5SDimitry Andric# define _LIBCPP_LITTLE_ENDIAN 2510b57cec5SDimitry Andric# else // _BYTE_ORDER == _LITTLE_ENDIAN 2520b57cec5SDimitry Andric# define _LIBCPP_BIG_ENDIAN 2530b57cec5SDimitry Andric# endif // _BYTE_ORDER == _LITTLE_ENDIAN 2540b57cec5SDimitry Andric# ifndef __LONG_LONG_SUPPORTED 2550b57cec5SDimitry Andric# define _LIBCPP_HAS_NO_LONG_LONG 2560b57cec5SDimitry Andric# endif // __LONG_LONG_SUPPORTED 2570b57cec5SDimitry Andric#endif // __FreeBSD__ 2580b57cec5SDimitry Andric 2590b57cec5SDimitry Andric#ifdef __NetBSD__ 2600b57cec5SDimitry Andric# include <sys/endian.h> 2610b57cec5SDimitry Andric# if _BYTE_ORDER == _LITTLE_ENDIAN 2620b57cec5SDimitry Andric# define _LIBCPP_LITTLE_ENDIAN 2630b57cec5SDimitry Andric# else // _BYTE_ORDER == _LITTLE_ENDIAN 2640b57cec5SDimitry Andric# define _LIBCPP_BIG_ENDIAN 2650b57cec5SDimitry Andric# endif // _BYTE_ORDER == _LITTLE_ENDIAN 2660b57cec5SDimitry Andric#endif // __NetBSD__ 2670b57cec5SDimitry Andric 2680b57cec5SDimitry Andric#if defined(_WIN32) 2690b57cec5SDimitry Andric# define _LIBCPP_WIN32API 2700b57cec5SDimitry Andric# define _LIBCPP_LITTLE_ENDIAN 2710b57cec5SDimitry Andric# define _LIBCPP_SHORT_WCHAR 1 2720b57cec5SDimitry Andric// Both MinGW and native MSVC provide a "MSVC"-like environment 2730b57cec5SDimitry Andric# define _LIBCPP_MSVCRT_LIKE 2740b57cec5SDimitry Andric// If mingw not explicitly detected, assume using MS C runtime only if 2750b57cec5SDimitry Andric// a MS compatibility version is specified. 2760b57cec5SDimitry Andric# if defined(_MSC_VER) && !defined(__MINGW32__) 2770b57cec5SDimitry Andric# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library 2780b57cec5SDimitry Andric# endif 2790b57cec5SDimitry Andric# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) 2800b57cec5SDimitry Andric# define _LIBCPP_HAS_BITSCAN64 2810b57cec5SDimitry Andric# endif 2820b57cec5SDimitry Andric# define _LIBCPP_HAS_OPEN_WITH_WCHAR 2830b57cec5SDimitry Andric# if defined(_LIBCPP_MSVCRT) 2840b57cec5SDimitry Andric# define _LIBCPP_HAS_QUICK_EXIT 2850b57cec5SDimitry Andric# endif 2860b57cec5SDimitry Andric 2870b57cec5SDimitry Andric// Some CRT APIs are unavailable to store apps 2880b57cec5SDimitry Andric# if defined(WINAPI_FAMILY) 2890b57cec5SDimitry Andric# include <winapifamily.h> 2900b57cec5SDimitry Andric# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \ 2910b57cec5SDimitry Andric (!defined(WINAPI_PARTITION_SYSTEM) || \ 2920b57cec5SDimitry Andric !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)) 2930b57cec5SDimitry Andric# define _LIBCPP_WINDOWS_STORE_APP 2940b57cec5SDimitry Andric# endif 2950b57cec5SDimitry Andric# endif 2960b57cec5SDimitry Andric#endif // defined(_WIN32) 2970b57cec5SDimitry Andric 2980b57cec5SDimitry Andric#ifdef __sun__ 2990b57cec5SDimitry Andric# include <sys/isa_defs.h> 3000b57cec5SDimitry Andric# ifdef _LITTLE_ENDIAN 3010b57cec5SDimitry Andric# define _LIBCPP_LITTLE_ENDIAN 3020b57cec5SDimitry Andric# else 3030b57cec5SDimitry Andric# define _LIBCPP_BIG_ENDIAN 3040b57cec5SDimitry Andric# endif 3050b57cec5SDimitry Andric#endif // __sun__ 3060b57cec5SDimitry Andric 3070b57cec5SDimitry Andric#if defined(__CloudABI__) 3080b57cec5SDimitry Andric // Certain architectures provide arc4random(). Prefer using 3090b57cec5SDimitry Andric // arc4random() over /dev/{u,}random to make it possible to obtain 3100b57cec5SDimitry Andric // random data even when using sandboxing mechanisms such as chroots, 3110b57cec5SDimitry Andric // Capsicum, etc. 3120b57cec5SDimitry Andric# define _LIBCPP_USING_ARC4_RANDOM 3130b57cec5SDimitry Andric#elif defined(__Fuchsia__) || defined(__wasi__) 3140b57cec5SDimitry Andric# define _LIBCPP_USING_GETENTROPY 3150b57cec5SDimitry Andric#elif defined(__native_client__) 3160b57cec5SDimitry Andric // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, 3170b57cec5SDimitry Andric // including accesses to the special files under /dev. C++11's 3180b57cec5SDimitry Andric // std::random_device is instead exposed through a NaCl syscall. 3190b57cec5SDimitry Andric# define _LIBCPP_USING_NACL_RANDOM 3200b57cec5SDimitry Andric#elif defined(_LIBCPP_WIN32API) 3210b57cec5SDimitry Andric# define _LIBCPP_USING_WIN32_RANDOM 3220b57cec5SDimitry Andric#else 3230b57cec5SDimitry Andric# define _LIBCPP_USING_DEV_RANDOM 3240b57cec5SDimitry Andric#endif 3250b57cec5SDimitry Andric 3260b57cec5SDimitry Andric#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 3270b57cec5SDimitry Andric# include <endian.h> 3280b57cec5SDimitry Andric# if __BYTE_ORDER == __LITTLE_ENDIAN 3290b57cec5SDimitry Andric# define _LIBCPP_LITTLE_ENDIAN 3300b57cec5SDimitry Andric# elif __BYTE_ORDER == __BIG_ENDIAN 3310b57cec5SDimitry Andric# define _LIBCPP_BIG_ENDIAN 3320b57cec5SDimitry Andric# else // __BYTE_ORDER == __BIG_ENDIAN 3330b57cec5SDimitry Andric# error unable to determine endian 3340b57cec5SDimitry Andric# endif 3350b57cec5SDimitry Andric#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 3360b57cec5SDimitry Andric 3370b57cec5SDimitry Andric#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) 3380b57cec5SDimitry Andric# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) 3390b57cec5SDimitry Andric#else 3400b57cec5SDimitry Andric# define _LIBCPP_NO_CFI 3410b57cec5SDimitry Andric#endif 3420b57cec5SDimitry Andric 3430b57cec5SDimitry Andric#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L 3440b57cec5SDimitry Andric# if defined(__FreeBSD__) 345480093f4SDimitry Andric# define _LIBCPP_HAS_ALIGNED_ALLOC 3460b57cec5SDimitry Andric# define _LIBCPP_HAS_QUICK_EXIT 3470b57cec5SDimitry Andric# define _LIBCPP_HAS_C11_FEATURES 34813138422SDimitry Andric# if __FreeBSD_version >= 1300064 || \ 34913138422SDimitry Andric (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000) 35013138422SDimitry Andric# define _LIBCPP_HAS_TIMESPEC_GET 35113138422SDimitry Andric# endif 352480093f4SDimitry Andric# elif defined(__BIONIC__) 353480093f4SDimitry Andric# define _LIBCPP_HAS_C11_FEATURES 354480093f4SDimitry Andric# if __ANDROID_API__ >= 21 355480093f4SDimitry Andric# define _LIBCPP_HAS_QUICK_EXIT 356480093f4SDimitry Andric# endif 357480093f4SDimitry Andric# if __ANDROID_API__ >= 28 358480093f4SDimitry Andric# define _LIBCPP_HAS_ALIGNED_ALLOC 359480093f4SDimitry Andric# endif 360480093f4SDimitry Andric# if __ANDROID_API__ >= 29 361480093f4SDimitry Andric# define _LIBCPP_HAS_TIMESPEC_GET 362480093f4SDimitry Andric# endif 363480093f4SDimitry Andric# elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__) 364480093f4SDimitry Andric# define _LIBCPP_HAS_ALIGNED_ALLOC 3650b57cec5SDimitry Andric# define _LIBCPP_HAS_QUICK_EXIT 3660b57cec5SDimitry Andric# define _LIBCPP_HAS_TIMESPEC_GET 3670b57cec5SDimitry Andric# define _LIBCPP_HAS_C11_FEATURES 3680b57cec5SDimitry Andric# elif defined(__linux__) 3690b57cec5SDimitry Andric# if !defined(_LIBCPP_HAS_MUSL_LIBC) 3700b57cec5SDimitry Andric# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__) 3710b57cec5SDimitry Andric# define _LIBCPP_HAS_QUICK_EXIT 3720b57cec5SDimitry Andric# endif 3730b57cec5SDimitry Andric# if _LIBCPP_GLIBC_PREREQ(2, 17) 374480093f4SDimitry Andric# define _LIBCPP_HAS_ALIGNED_ALLOC 3750b57cec5SDimitry Andric# define _LIBCPP_HAS_C11_FEATURES 3760b57cec5SDimitry Andric# define _LIBCPP_HAS_TIMESPEC_GET 3770b57cec5SDimitry Andric# endif 3780b57cec5SDimitry Andric# else // defined(_LIBCPP_HAS_MUSL_LIBC) 379480093f4SDimitry Andric# define _LIBCPP_HAS_ALIGNED_ALLOC 3800b57cec5SDimitry Andric# define _LIBCPP_HAS_QUICK_EXIT 3810b57cec5SDimitry Andric# define _LIBCPP_HAS_TIMESPEC_GET 3820b57cec5SDimitry Andric# define _LIBCPP_HAS_C11_FEATURES 3830b57cec5SDimitry Andric# endif 3840b57cec5SDimitry Andric# endif // __linux__ 3850b57cec5SDimitry Andric#endif 3860b57cec5SDimitry Andric 3870b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3880b57cec5SDimitry Andric# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) 3890b57cec5SDimitry Andric#elif defined(_LIBCPP_COMPILER_CLANG) 3900b57cec5SDimitry Andric# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) 3910b57cec5SDimitry Andric#else 3920b57cec5SDimitry Andric// This definition is potentially buggy, but it's only taken with GCC in C++03, 3930b57cec5SDimitry Andric// which we barely support anyway. See llvm.org/PR39713 3940b57cec5SDimitry Andric# define _LIBCPP_ALIGNOF(_Tp) __alignof(_Tp) 3950b57cec5SDimitry Andric#endif 3960b57cec5SDimitry Andric 3970b57cec5SDimitry Andric#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) 3980b57cec5SDimitry Andric 3990b57cec5SDimitry Andric#if defined(_LIBCPP_COMPILER_CLANG) 4000b57cec5SDimitry Andric 401*5ffd83dbSDimitry Andric#if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) 402*5ffd83dbSDimitry Andric# error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead 403*5ffd83dbSDimitry Andric#endif 404*5ffd83dbSDimitry Andric#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ 405*5ffd83dbSDimitry Andric (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) 4060b57cec5SDimitry Andric# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 4070b57cec5SDimitry Andric#endif 4080b57cec5SDimitry Andric 4090b57cec5SDimitry Andric#if __has_feature(cxx_alignas) 4100b57cec5SDimitry Andric# define _ALIGNAS_TYPE(x) alignas(x) 4110b57cec5SDimitry Andric# define _ALIGNAS(x) alignas(x) 4120b57cec5SDimitry Andric#else 4130b57cec5SDimitry Andric# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 4140b57cec5SDimitry Andric# define _ALIGNAS(x) __attribute__((__aligned__(x))) 4150b57cec5SDimitry Andric#endif 4160b57cec5SDimitry Andric 4170b57cec5SDimitry Andric#if __cplusplus < 201103L 4180b57cec5SDimitry Andrictypedef __char16_t char16_t; 4190b57cec5SDimitry Andrictypedef __char32_t char32_t; 4200b57cec5SDimitry Andric#endif 4210b57cec5SDimitry Andric 422*5ffd83dbSDimitry Andric#if !__has_feature(cxx_exceptions) 4230b57cec5SDimitry Andric# define _LIBCPP_NO_EXCEPTIONS 4240b57cec5SDimitry Andric#endif 4250b57cec5SDimitry Andric 4260b57cec5SDimitry Andric#if !(__has_feature(cxx_strong_enums)) 4270b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_STRONG_ENUMS 4280b57cec5SDimitry Andric#endif 4290b57cec5SDimitry Andric 4300b57cec5SDimitry Andric#if __has_feature(cxx_attributes) 4310b57cec5SDimitry Andric# define _LIBCPP_NORETURN [[noreturn]] 4320b57cec5SDimitry Andric#else 4330b57cec5SDimitry Andric# define _LIBCPP_NORETURN __attribute__ ((noreturn)) 4340b57cec5SDimitry Andric#endif 4350b57cec5SDimitry Andric 4360b57cec5SDimitry Andric#if !(__has_feature(cxx_lambdas)) 4370b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_LAMBDAS 4380b57cec5SDimitry Andric#endif 4390b57cec5SDimitry Andric 4400b57cec5SDimitry Andric#if !(__has_feature(cxx_nullptr)) 4410b57cec5SDimitry Andric# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) 4420b57cec5SDimitry Andric# define nullptr __nullptr 4430b57cec5SDimitry Andric# else 4440b57cec5SDimitry Andric# define _LIBCPP_HAS_NO_NULLPTR 4450b57cec5SDimitry Andric# endif 4460b57cec5SDimitry Andric#endif 4470b57cec5SDimitry Andric 4480b57cec5SDimitry Andric#if !(__has_feature(cxx_rvalue_references)) 4490b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 4500b57cec5SDimitry Andric#endif 4510b57cec5SDimitry Andric 4520b57cec5SDimitry Andric#if !(__has_feature(cxx_auto_type)) 4530b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_AUTO_TYPE 4540b57cec5SDimitry Andric#endif 4550b57cec5SDimitry Andric 4560b57cec5SDimitry Andric#if !(__has_feature(cxx_variadic_templates)) 4570b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_VARIADICS 4580b57cec5SDimitry Andric#endif 4590b57cec5SDimitry Andric 4600b57cec5SDimitry Andric// Objective-C++ features (opt-in) 4610b57cec5SDimitry Andric#if __has_feature(objc_arc) 4620b57cec5SDimitry Andric#define _LIBCPP_HAS_OBJC_ARC 4630b57cec5SDimitry Andric#endif 4640b57cec5SDimitry Andric 4650b57cec5SDimitry Andric#if __has_feature(objc_arc_weak) 4660b57cec5SDimitry Andric#define _LIBCPP_HAS_OBJC_ARC_WEAK 4670b57cec5SDimitry Andric#endif 4680b57cec5SDimitry Andric 469*5ffd83dbSDimitry Andric#if __has_extension(blocks) 470*5ffd83dbSDimitry Andric# define _LIBCPP_HAS_EXTENSION_BLOCKS 471*5ffd83dbSDimitry Andric#endif 472*5ffd83dbSDimitry Andric 473*5ffd83dbSDimitry Andric#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) 474*5ffd83dbSDimitry Andric# define _LIBCPP_HAS_BLOCKS_RUNTIME 475*5ffd83dbSDimitry Andric#endif 476*5ffd83dbSDimitry Andric 4770b57cec5SDimitry Andric#if !(__has_feature(cxx_relaxed_constexpr)) 4780b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 4790b57cec5SDimitry Andric#endif 4800b57cec5SDimitry Andric 4810b57cec5SDimitry Andric#if !(__has_feature(cxx_variable_templates)) 4820b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 4830b57cec5SDimitry Andric#endif 4840b57cec5SDimitry Andric 4850b57cec5SDimitry Andric#if !(__has_feature(cxx_noexcept)) 4860b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_NOEXCEPT 4870b57cec5SDimitry Andric#endif 4880b57cec5SDimitry Andric 4890b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) 4900b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_ASAN 4910b57cec5SDimitry Andric#endif 4920b57cec5SDimitry Andric 4930b57cec5SDimitry Andric// Allow for build-time disabling of unsigned integer sanitization 4940b57cec5SDimitry Andric#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize) 4950b57cec5SDimitry Andric#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) 4960b57cec5SDimitry Andric#endif 4970b57cec5SDimitry Andric 4980b57cec5SDimitry Andric#if __has_builtin(__builtin_launder) 4990b57cec5SDimitry Andric#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER 5000b57cec5SDimitry Andric#endif 5010b57cec5SDimitry Andric 502*5ffd83dbSDimitry Andric#if __has_builtin(__builtin_constant_p) 503*5ffd83dbSDimitry Andric#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P 504*5ffd83dbSDimitry Andric#endif 505*5ffd83dbSDimitry Andric 5060b57cec5SDimitry Andric#if !__is_identifier(__has_unique_object_representations) 5070b57cec5SDimitry Andric#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS 5080b57cec5SDimitry Andric#endif 5090b57cec5SDimitry Andric 5100b57cec5SDimitry Andric#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) 5110b57cec5SDimitry Andric 512e40139ffSDimitry Andric// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1 513e40139ffSDimitry Andric#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \ 514e40139ffSDimitry Andric (defined(__apple_build_version__) && __apple_build_version__ < 10010000) 5150b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS 5160b57cec5SDimitry Andric#endif 5170b57cec5SDimitry Andric 518e40139ffSDimitry Andric#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 519e40139ffSDimitry Andric 5200b57cec5SDimitry Andric#elif defined(_LIBCPP_COMPILER_GCC) 5210b57cec5SDimitry Andric 5220b57cec5SDimitry Andric#define _ALIGNAS(x) __attribute__((__aligned__(x))) 5230b57cec5SDimitry Andric#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 5240b57cec5SDimitry Andric 5250b57cec5SDimitry Andric#define _LIBCPP_NORETURN __attribute__((noreturn)) 5260b57cec5SDimitry Andric 527*5ffd83dbSDimitry Andric#if !__EXCEPTIONS 5280b57cec5SDimitry Andric# define _LIBCPP_NO_EXCEPTIONS 5290b57cec5SDimitry Andric#endif 5300b57cec5SDimitry Andric 5310b57cec5SDimitry Andric// Determine if GCC supports relaxed constexpr 5320b57cec5SDimitry Andric#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L 5330b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 5340b57cec5SDimitry Andric#endif 5350b57cec5SDimitry Andric 5360b57cec5SDimitry Andric// GCC 5 supports variable templates 5370b57cec5SDimitry Andric#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L 5380b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 5390b57cec5SDimitry Andric#endif 5400b57cec5SDimitry Andric 5410b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) 5420b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_ASAN 5430b57cec5SDimitry Andric#endif 5440b57cec5SDimitry Andric 5450b57cec5SDimitry Andric#if _GNUC_VER >= 700 5460b57cec5SDimitry Andric#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER 547*5ffd83dbSDimitry Andric#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P 5480b57cec5SDimitry Andric#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS 5490b57cec5SDimitry Andric#endif 5500b57cec5SDimitry Andric 5510b57cec5SDimitry Andric#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) 5520b57cec5SDimitry Andric 553e40139ffSDimitry Andric#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 554e40139ffSDimitry Andric 5550b57cec5SDimitry Andric#elif defined(_LIBCPP_COMPILER_MSVC) 5560b57cec5SDimitry Andric 5570b57cec5SDimitry Andric#define _LIBCPP_TOSTRING2(x) #x 5580b57cec5SDimitry Andric#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) 5590b57cec5SDimitry Andric#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) 5600b57cec5SDimitry Andric 5610b57cec5SDimitry Andric#if _MSC_VER < 1900 5620b57cec5SDimitry Andric#error "MSVC versions prior to Visual Studio 2015 are not supported" 5630b57cec5SDimitry Andric#endif 5640b57cec5SDimitry Andric 5650b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 5660b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 5670b57cec5SDimitry Andric#define __alignof__ __alignof 5680b57cec5SDimitry Andric#define _LIBCPP_NORETURN __declspec(noreturn) 5690b57cec5SDimitry Andric#define _ALIGNAS(x) __declspec(align(x)) 5700b57cec5SDimitry Andric#define _ALIGNAS_TYPE(x) alignas(x) 5710b57cec5SDimitry Andric 5720b57cec5SDimitry Andric#define _LIBCPP_WEAK 5730b57cec5SDimitry Andric 5740b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_ASAN 5750b57cec5SDimitry Andric 5760b57cec5SDimitry Andric#define _LIBCPP_ALWAYS_INLINE __forceinline 5770b57cec5SDimitry Andric 5780b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_VECTOR_EXTENSION 5790b57cec5SDimitry Andric 580e40139ffSDimitry Andric#define _LIBCPP_DISABLE_EXTENSION_WARNING 581e40139ffSDimitry Andric 5820b57cec5SDimitry Andric#elif defined(_LIBCPP_COMPILER_IBM) 5830b57cec5SDimitry Andric 5840b57cec5SDimitry Andric#define _ALIGNAS(x) __attribute__((__aligned__(x))) 5850b57cec5SDimitry Andric#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 5860b57cec5SDimitry Andric#define _ATTRIBUTE(x) __attribute__((x)) 5870b57cec5SDimitry Andric#define _LIBCPP_NORETURN __attribute__((noreturn)) 5880b57cec5SDimitry Andric 5890b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_UNICODE_CHARS 5900b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 5910b57cec5SDimitry Andric 5920b57cec5SDimitry Andric#if defined(_AIX) 5930b57cec5SDimitry Andric#define __MULTILOCALE_API 5940b57cec5SDimitry Andric#endif 5950b57cec5SDimitry Andric 5960b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_ASAN 5970b57cec5SDimitry Andric 5980b57cec5SDimitry Andric#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) 5990b57cec5SDimitry Andric 6000b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_VECTOR_EXTENSION 6010b57cec5SDimitry Andric 602e40139ffSDimitry Andric#define _LIBCPP_DISABLE_EXTENSION_WARNING 603e40139ffSDimitry Andric 6040b57cec5SDimitry Andric#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] 6050b57cec5SDimitry Andric 6060b57cec5SDimitry Andric#if defined(_LIBCPP_OBJECT_FORMAT_COFF) 6070b57cec5SDimitry Andric 6080b57cec5SDimitry Andric#ifdef _DLL 6090b57cec5SDimitry Andric# define _LIBCPP_CRT_FUNC __declspec(dllimport) 6100b57cec5SDimitry Andric#else 6110b57cec5SDimitry Andric# define _LIBCPP_CRT_FUNC 6120b57cec5SDimitry Andric#endif 6130b57cec5SDimitry Andric 6140b57cec5SDimitry Andric#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 6150b57cec5SDimitry Andric# define _LIBCPP_DLL_VIS 6160b57cec5SDimitry Andric# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 6170b57cec5SDimitry Andric# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 6180b57cec5SDimitry Andric# define _LIBCPP_OVERRIDABLE_FUNC_VIS 6190b57cec5SDimitry Andric# define _LIBCPP_EXPORTED_FROM_ABI 6200b57cec5SDimitry Andric#elif defined(_LIBCPP_BUILDING_LIBRARY) 6210b57cec5SDimitry Andric# define _LIBCPP_DLL_VIS __declspec(dllexport) 6220b57cec5SDimitry Andric# if defined(__MINGW32__) 6230b57cec5SDimitry Andric# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 6240b57cec5SDimitry Andric# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 6250b57cec5SDimitry Andric# else 6260b57cec5SDimitry Andric# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 6270b57cec5SDimitry Andric# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS 6280b57cec5SDimitry Andric# endif 6290b57cec5SDimitry Andric# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS 6300b57cec5SDimitry Andric# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) 6310b57cec5SDimitry Andric#else 6320b57cec5SDimitry Andric# define _LIBCPP_DLL_VIS __declspec(dllimport) 6330b57cec5SDimitry Andric# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 6340b57cec5SDimitry Andric# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 6350b57cec5SDimitry Andric# define _LIBCPP_OVERRIDABLE_FUNC_VIS 6360b57cec5SDimitry Andric# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) 6370b57cec5SDimitry Andric#endif 6380b57cec5SDimitry Andric 6390b57cec5SDimitry Andric#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS 6400b57cec5SDimitry Andric#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS 6410b57cec5SDimitry Andric#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS 6420b57cec5SDimitry Andric#define _LIBCPP_HIDDEN 6430b57cec5SDimitry Andric#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 6440b57cec5SDimitry Andric#define _LIBCPP_TEMPLATE_VIS 6450b57cec5SDimitry Andric#define _LIBCPP_ENUM_VIS 6460b57cec5SDimitry Andric 6470b57cec5SDimitry Andric#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) 6480b57cec5SDimitry Andric 6490b57cec5SDimitry Andric#ifndef _LIBCPP_HIDDEN 6500b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 6510b57cec5SDimitry Andric# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) 6520b57cec5SDimitry Andric# else 6530b57cec5SDimitry Andric# define _LIBCPP_HIDDEN 6540b57cec5SDimitry Andric# endif 6550b57cec5SDimitry Andric#endif 6560b57cec5SDimitry Andric 6570b57cec5SDimitry Andric#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 6580b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 6590b57cec5SDimitry Andric// The inline should be removed once PR32114 is resolved 6600b57cec5SDimitry Andric# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN 6610b57cec5SDimitry Andric# else 6620b57cec5SDimitry Andric# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 6630b57cec5SDimitry Andric# endif 6640b57cec5SDimitry Andric#endif 6650b57cec5SDimitry Andric 6660b57cec5SDimitry Andric#ifndef _LIBCPP_FUNC_VIS 6670b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 6680b57cec5SDimitry Andric# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) 6690b57cec5SDimitry Andric# else 6700b57cec5SDimitry Andric# define _LIBCPP_FUNC_VIS 6710b57cec5SDimitry Andric# endif 6720b57cec5SDimitry Andric#endif 6730b57cec5SDimitry Andric 6740b57cec5SDimitry Andric#ifndef _LIBCPP_TYPE_VIS 6750b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 6760b57cec5SDimitry Andric# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) 6770b57cec5SDimitry Andric# else 6780b57cec5SDimitry Andric# define _LIBCPP_TYPE_VIS 6790b57cec5SDimitry Andric# endif 6800b57cec5SDimitry Andric#endif 6810b57cec5SDimitry Andric 6820b57cec5SDimitry Andric#ifndef _LIBCPP_TEMPLATE_VIS 6830b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 6840b57cec5SDimitry Andric# if __has_attribute(__type_visibility__) 6850b57cec5SDimitry Andric# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default"))) 6860b57cec5SDimitry Andric# else 6870b57cec5SDimitry Andric# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default"))) 6880b57cec5SDimitry Andric# endif 6890b57cec5SDimitry Andric# else 6900b57cec5SDimitry Andric# define _LIBCPP_TEMPLATE_VIS 6910b57cec5SDimitry Andric# endif 6920b57cec5SDimitry Andric#endif 6930b57cec5SDimitry Andric 6940b57cec5SDimitry Andric#ifndef _LIBCPP_EXPORTED_FROM_ABI 6950b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 6960b57cec5SDimitry Andric# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) 6970b57cec5SDimitry Andric# else 6980b57cec5SDimitry Andric# define _LIBCPP_EXPORTED_FROM_ABI 6990b57cec5SDimitry Andric# endif 7000b57cec5SDimitry Andric#endif 7010b57cec5SDimitry Andric 7020b57cec5SDimitry Andric#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS 7030b57cec5SDimitry Andric#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS 7040b57cec5SDimitry Andric#endif 7050b57cec5SDimitry Andric 7060b57cec5SDimitry Andric#ifndef _LIBCPP_EXCEPTION_ABI 7070b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 7080b57cec5SDimitry Andric# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) 7090b57cec5SDimitry Andric# else 7100b57cec5SDimitry Andric# define _LIBCPP_EXCEPTION_ABI 7110b57cec5SDimitry Andric# endif 7120b57cec5SDimitry Andric#endif 7130b57cec5SDimitry Andric 7140b57cec5SDimitry Andric#ifndef _LIBCPP_ENUM_VIS 7150b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 7160b57cec5SDimitry Andric# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) 7170b57cec5SDimitry Andric# else 7180b57cec5SDimitry Andric# define _LIBCPP_ENUM_VIS 7190b57cec5SDimitry Andric# endif 7200b57cec5SDimitry Andric#endif 7210b57cec5SDimitry Andric 7220b57cec5SDimitry Andric#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 7230b57cec5SDimitry Andric# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 7240b57cec5SDimitry Andric# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) 7250b57cec5SDimitry Andric# else 7260b57cec5SDimitry Andric# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 7270b57cec5SDimitry Andric# endif 7280b57cec5SDimitry Andric#endif 7290b57cec5SDimitry Andric 7300b57cec5SDimitry Andric#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 7310b57cec5SDimitry Andric#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 7320b57cec5SDimitry Andric#endif 7330b57cec5SDimitry Andric 7340b57cec5SDimitry Andric#if __has_attribute(internal_linkage) 7350b57cec5SDimitry Andric# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage)) 7360b57cec5SDimitry Andric#else 7370b57cec5SDimitry Andric# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE 7380b57cec5SDimitry Andric#endif 7390b57cec5SDimitry Andric 7400b57cec5SDimitry Andric#if __has_attribute(exclude_from_explicit_instantiation) 7410b57cec5SDimitry Andric# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__)) 7420b57cec5SDimitry Andric#else 7430b57cec5SDimitry Andric // Try to approximate the effect of exclude_from_explicit_instantiation 7440b57cec5SDimitry Andric // (which is that entities are not assumed to be provided by explicit 7450b57cec5SDimitry Andric // template instantiations in the dylib) by always inlining those entities. 7460b57cec5SDimitry Andric# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE 7470b57cec5SDimitry Andric#endif 7480b57cec5SDimitry Andric 7490b57cec5SDimitry Andric#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU 7500b57cec5SDimitry Andric# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT 7510b57cec5SDimitry Andric# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 7520b57cec5SDimitry Andric# else 7530b57cec5SDimitry Andric# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 7540b57cec5SDimitry Andric# endif 7550b57cec5SDimitry Andric#endif 7560b57cec5SDimitry Andric 757*5ffd83dbSDimitry Andric#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 7580b57cec5SDimitry Andric# ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos. 759*5ffd83dbSDimitry Andric# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2 7600b57cec5SDimitry Andric# else 7610b57cec5SDimitry Andric // TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398 7620b57cec5SDimitry Andric // And we should consider defaulting to OFF. 763*5ffd83dbSDimitry Andric# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1 7640b57cec5SDimitry Andric# endif 7650b57cec5SDimitry Andric#endif 7660b57cec5SDimitry Andric 7670b57cec5SDimitry Andric#ifndef _LIBCPP_HIDE_FROM_ABI 7680b57cec5SDimitry Andric# if _LIBCPP_HIDE_FROM_ABI_PER_TU 7690b57cec5SDimitry Andric# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE 7700b57cec5SDimitry Andric# else 7710b57cec5SDimitry Andric# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 7720b57cec5SDimitry Andric# endif 7730b57cec5SDimitry Andric#endif 7740b57cec5SDimitry Andric 7750b57cec5SDimitry Andric#ifdef _LIBCPP_BUILDING_LIBRARY 7760b57cec5SDimitry Andric# if _LIBCPP_ABI_VERSION > 1 7770b57cec5SDimitry Andric# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 7780b57cec5SDimitry Andric# else 7790b57cec5SDimitry Andric# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 7800b57cec5SDimitry Andric# endif 7810b57cec5SDimitry Andric#else 7820b57cec5SDimitry Andric# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 7830b57cec5SDimitry Andric#endif 7840b57cec5SDimitry Andric 7850b57cec5SDimitry Andric// Just so we can migrate to the new macros gradually. 7860b57cec5SDimitry Andric#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI 7870b57cec5SDimitry Andric 7880b57cec5SDimitry Andric// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. 7890b57cec5SDimitry Andric#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { 7900b57cec5SDimitry Andric#define _LIBCPP_END_NAMESPACE_STD } } 7910b57cec5SDimitry Andric#define _VSTD std::_LIBCPP_ABI_NAMESPACE 7920b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD 7930b57cec5SDimitry Andric 7940b57cec5SDimitry Andric#if _LIBCPP_STD_VER >= 17 7950b57cec5SDimitry Andric#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 7960b57cec5SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { 7970b57cec5SDimitry Andric#else 7980b57cec5SDimitry Andric#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 7990b57cec5SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { 8000b57cec5SDimitry Andric#endif 8010b57cec5SDimitry Andric 8020b57cec5SDimitry Andric#define _LIBCPP_END_NAMESPACE_FILESYSTEM \ 8030b57cec5SDimitry Andric _LIBCPP_END_NAMESPACE_STD } } 8040b57cec5SDimitry Andric 8050b57cec5SDimitry Andric#define _VSTD_FS _VSTD::__fs::filesystem 8060b57cec5SDimitry Andric 8070b57cec5SDimitry Andric#ifndef _LIBCPP_PREFERRED_OVERLOAD 8080b57cec5SDimitry Andric# if __has_attribute(__enable_if__) 8090b57cec5SDimitry Andric# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) 8100b57cec5SDimitry Andric# endif 8110b57cec5SDimitry Andric#endif 8120b57cec5SDimitry Andric 8130b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_NOEXCEPT 8140b57cec5SDimitry Andric# define _NOEXCEPT noexcept 8150b57cec5SDimitry Andric# define _NOEXCEPT_(x) noexcept(x) 8160b57cec5SDimitry Andric#else 8170b57cec5SDimitry Andric# define _NOEXCEPT throw() 8180b57cec5SDimitry Andric# define _NOEXCEPT_(x) 8190b57cec5SDimitry Andric#endif 8200b57cec5SDimitry Andric 8210b57cec5SDimitry Andric#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS 8220b57cec5SDimitry Andrictypedef unsigned short char16_t; 8230b57cec5SDimitry Andrictypedef unsigned int char32_t; 8240b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 8250b57cec5SDimitry Andric 8260b57cec5SDimitry Andric#ifndef __SIZEOF_INT128__ 8270b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_INT128 8280b57cec5SDimitry Andric#endif 8290b57cec5SDimitry Andric 8300b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG 8310b57cec5SDimitry Andric# define static_assert(...) _Static_assert(__VA_ARGS__) 8320b57cec5SDimitry Andric# define decltype(...) __decltype(__VA_ARGS__) 8330b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 8340b57cec5SDimitry Andric 8350b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG 8360b57cec5SDimitry Andric# define _LIBCPP_CONSTEXPR 8370b57cec5SDimitry Andric#else 8380b57cec5SDimitry Andric# define _LIBCPP_CONSTEXPR constexpr 8390b57cec5SDimitry Andric#endif 8400b57cec5SDimitry Andric 8410b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG 8420b57cec5SDimitry Andric# define _LIBCPP_DEFAULT {} 8430b57cec5SDimitry Andric#else 8440b57cec5SDimitry Andric# define _LIBCPP_DEFAULT = default; 8450b57cec5SDimitry Andric#endif 8460b57cec5SDimitry Andric 8470b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG 8480b57cec5SDimitry Andric# define _LIBCPP_EQUAL_DELETE 8490b57cec5SDimitry Andric#else 8500b57cec5SDimitry Andric# define _LIBCPP_EQUAL_DELETE = delete 8510b57cec5SDimitry Andric#endif 8520b57cec5SDimitry Andric 8530b57cec5SDimitry Andric#ifdef __GNUC__ 8540b57cec5SDimitry Andric# define _LIBCPP_NOALIAS __attribute__((__malloc__)) 8550b57cec5SDimitry Andric#else 8560b57cec5SDimitry Andric# define _LIBCPP_NOALIAS 8570b57cec5SDimitry Andric#endif 8580b57cec5SDimitry Andric 8590b57cec5SDimitry Andric#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ 8600b57cec5SDimitry Andric (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions 8610b57cec5SDimitry Andric# define _LIBCPP_EXPLICIT explicit 8620b57cec5SDimitry Andric#else 8630b57cec5SDimitry Andric# define _LIBCPP_EXPLICIT 8640b57cec5SDimitry Andric#endif 8650b57cec5SDimitry Andric 8660b57cec5SDimitry Andric#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete) 8670b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE 8680b57cec5SDimitry Andric#endif 8690b57cec5SDimitry Andric 8700b57cec5SDimitry Andric#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 8710b57cec5SDimitry Andric# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx 8720b57cec5SDimitry Andric# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 8730b57cec5SDimitry Andric __lx __v_; \ 8740b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ 8750b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 8760b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \ 8770b57cec5SDimitry Andric }; 8780b57cec5SDimitry Andric#else // _LIBCPP_HAS_NO_STRONG_ENUMS 8790b57cec5SDimitry Andric# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x 8800b57cec5SDimitry Andric# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 8810b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_STRONG_ENUMS 8820b57cec5SDimitry Andric 8830b57cec5SDimitry Andric#ifdef _LIBCPP_DEBUG 8840b57cec5SDimitry Andric# if _LIBCPP_DEBUG == 0 8850b57cec5SDimitry Andric# define _LIBCPP_DEBUG_LEVEL 1 8860b57cec5SDimitry Andric# elif _LIBCPP_DEBUG == 1 8870b57cec5SDimitry Andric# define _LIBCPP_DEBUG_LEVEL 2 8880b57cec5SDimitry Andric# else 8890b57cec5SDimitry Andric# error Supported values for _LIBCPP_DEBUG are 0 and 1 8900b57cec5SDimitry Andric# endif 8910b57cec5SDimitry Andric# if !defined(_LIBCPP_BUILDING_LIBRARY) 8920b57cec5SDimitry Andric# define _LIBCPP_EXTERN_TEMPLATE(...) 8930b57cec5SDimitry Andric# endif 8940b57cec5SDimitry Andric#endif 8950b57cec5SDimitry Andric 896480093f4SDimitry Andric#ifndef _LIBCPP_DEBUG_LEVEL 897480093f4SDimitry Andric# define _LIBCPP_DEBUG_LEVEL 0 898480093f4SDimitry Andric#endif 899480093f4SDimitry Andric 9000b57cec5SDimitry Andric#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE 9010b57cec5SDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE(...) 9020b57cec5SDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE2(...) 9030b57cec5SDimitry Andric#endif 9040b57cec5SDimitry Andric 9050b57cec5SDimitry Andric#ifndef _LIBCPP_EXTERN_TEMPLATE 9060b57cec5SDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; 9070b57cec5SDimitry Andric#endif 9080b57cec5SDimitry Andric 9090b57cec5SDimitry Andric#ifndef _LIBCPP_EXTERN_TEMPLATE2 9100b57cec5SDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; 9110b57cec5SDimitry Andric#endif 9120b57cec5SDimitry Andric 913*5ffd83dbSDimitry Andric#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE 914*5ffd83dbSDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__; 915*5ffd83dbSDimitry Andric#endif 916*5ffd83dbSDimitry Andric 9170b57cec5SDimitry Andric#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ 9180b57cec5SDimitry Andric defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) 9190b57cec5SDimitry Andric#define _LIBCPP_LOCALE__L_EXTENSIONS 1 9200b57cec5SDimitry Andric#endif 9210b57cec5SDimitry Andric 9220b57cec5SDimitry Andric#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) 9230b57cec5SDimitry Andric// Most unix variants have catopen. These are the specific ones that don't. 9240b57cec5SDimitry Andric# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) 9250b57cec5SDimitry Andric# define _LIBCPP_HAS_CATOPEN 1 9260b57cec5SDimitry Andric# endif 9270b57cec5SDimitry Andric#endif 9280b57cec5SDimitry Andric 9290b57cec5SDimitry Andric#ifdef __FreeBSD__ 9300b57cec5SDimitry Andric#define _DECLARE_C99_LDBL_MATH 1 9310b57cec5SDimitry Andric#endif 9320b57cec5SDimitry Andric 9330b57cec5SDimitry Andric// If we are getting operator new from the MSVC CRT, then allocation overloads 9340b57cec5SDimitry Andric// for align_val_t were added in 19.12, aka VS 2017 version 15.3. 9350b57cec5SDimitry Andric#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 9360b57cec5SDimitry Andric# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 9370b57cec5SDimitry Andric#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) 9380b57cec5SDimitry Andric // We're deferring to Microsoft's STL to provide aligned new et al. We don't 9390b57cec5SDimitry Andric // have it unless the language feature test macro is defined. 9400b57cec5SDimitry Andric# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 9410b57cec5SDimitry Andric#endif 9420b57cec5SDimitry Andric 9430b57cec5SDimitry Andric#if defined(__APPLE__) 9440b57cec5SDimitry Andric# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ 9450b57cec5SDimitry Andric defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) 9460b57cec5SDimitry Andric# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 9470b57cec5SDimitry Andric# endif 9480b57cec5SDimitry Andric#endif // defined(__APPLE__) 9490b57cec5SDimitry Andric 9500b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ 9510b57cec5SDimitry Andric (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ 9520b57cec5SDimitry Andric (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)) 9530b57cec5SDimitry Andric# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION 9540b57cec5SDimitry Andric#endif 9550b57cec5SDimitry Andric 9560b57cec5SDimitry Andric#if defined(__APPLE__) || defined(__FreeBSD__) 9570b57cec5SDimitry Andric#define _LIBCPP_HAS_DEFAULTRUNELOCALE 9580b57cec5SDimitry Andric#endif 9590b57cec5SDimitry Andric 9600b57cec5SDimitry Andric#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) 9610b57cec5SDimitry Andric#define _LIBCPP_WCTYPE_IS_MASK 9620b57cec5SDimitry Andric#endif 9630b57cec5SDimitry Andric 9640b57cec5SDimitry Andric#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) 9650b57cec5SDimitry Andric#define _LIBCPP_NO_HAS_CHAR8_T 9660b57cec5SDimitry Andric#endif 9670b57cec5SDimitry Andric 9680b57cec5SDimitry Andric// Deprecation macros. 9690b57cec5SDimitry Andric// 9700b57cec5SDimitry Andric// Deprecations warnings are always enabled, except when users explicitly opt-out 9710b57cec5SDimitry Andric// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. 9720b57cec5SDimitry Andric#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) 9730b57cec5SDimitry Andric# if __has_attribute(deprecated) 9740b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) 9750b57cec5SDimitry Andric# elif _LIBCPP_STD_VER > 11 9760b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED [[deprecated]] 9770b57cec5SDimitry Andric# else 9780b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED 9790b57cec5SDimitry Andric# endif 9800b57cec5SDimitry Andric#else 9810b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED 9820b57cec5SDimitry Andric#endif 9830b57cec5SDimitry Andric 9840b57cec5SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG) 9850b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED 9860b57cec5SDimitry Andric#else 9870b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED_IN_CXX11 9880b57cec5SDimitry Andric#endif 9890b57cec5SDimitry Andric 9900b57cec5SDimitry Andric#if _LIBCPP_STD_VER >= 14 9910b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED 9920b57cec5SDimitry Andric#else 9930b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED_IN_CXX14 9940b57cec5SDimitry Andric#endif 9950b57cec5SDimitry Andric 9960b57cec5SDimitry Andric#if _LIBCPP_STD_VER >= 17 9970b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED 9980b57cec5SDimitry Andric#else 9990b57cec5SDimitry Andric# define _LIBCPP_DEPRECATED_IN_CXX17 10000b57cec5SDimitry Andric#endif 10010b57cec5SDimitry Andric 1002e40139ffSDimitry Andric// Macros to enter and leave a state where deprecation warnings are suppressed. 1003e40139ffSDimitry Andric#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \ 1004e40139ffSDimitry Andric (defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC)) 1005e40139ffSDimitry Andric# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ 1006e40139ffSDimitry Andric _Pragma("GCC diagnostic push") \ 1007e40139ffSDimitry Andric _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") 1008e40139ffSDimitry Andric# define _LIBCPP_SUPPRESS_DEPRECATED_POP \ 1009e40139ffSDimitry Andric _Pragma("GCC diagnostic pop") 1010e40139ffSDimitry Andric#endif 1011e40139ffSDimitry Andric#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) 1012e40139ffSDimitry Andric# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH 1013e40139ffSDimitry Andric# define _LIBCPP_SUPPRESS_DEPRECATED_POP 1014e40139ffSDimitry Andric#endif 1015e40139ffSDimitry Andric 10160b57cec5SDimitry Andric#if _LIBCPP_STD_VER <= 11 10170b57cec5SDimitry Andric# define _LIBCPP_EXPLICIT_AFTER_CXX11 10180b57cec5SDimitry Andric#else 10190b57cec5SDimitry Andric# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit 10200b57cec5SDimitry Andric#endif 10210b57cec5SDimitry Andric 10220b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 10230b57cec5SDimitry Andric# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr 10240b57cec5SDimitry Andric#else 10250b57cec5SDimitry Andric# define _LIBCPP_CONSTEXPR_AFTER_CXX11 10260b57cec5SDimitry Andric#endif 10270b57cec5SDimitry Andric 10280b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 10290b57cec5SDimitry Andric# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr 10300b57cec5SDimitry Andric#else 10310b57cec5SDimitry Andric# define _LIBCPP_CONSTEXPR_AFTER_CXX14 10320b57cec5SDimitry Andric#endif 10330b57cec5SDimitry Andric 10340b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 10350b57cec5SDimitry Andric# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr 10360b57cec5SDimitry Andric#else 10370b57cec5SDimitry Andric# define _LIBCPP_CONSTEXPR_AFTER_CXX17 10380b57cec5SDimitry Andric#endif 10390b57cec5SDimitry Andric 1040480093f4SDimitry Andric#if _LIBCPP_STD_VER > 17 && \ 1041480093f4SDimitry Andric !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) && \ 1042480093f4SDimitry Andric !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) 1043480093f4SDimitry Andric# define _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED constexpr 1044480093f4SDimitry Andric#else 1045480093f4SDimitry Andric# define _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED 1046480093f4SDimitry Andric#endif 1047480093f4SDimitry Andric 10480b57cec5SDimitry Andric// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other 10490b57cec5SDimitry Andric// NODISCARD macros to the correct attribute. 10500b57cec5SDimitry Andric#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) 10510b57cec5SDimitry Andric# define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]] 10520b57cec5SDimitry Andric#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG) 10530b57cec5SDimitry Andric# define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]] 10540b57cec5SDimitry Andric#else 10550b57cec5SDimitry Andric// We can't use GCC's [[gnu::warn_unused_result]] and 10560b57cec5SDimitry Andric// __attribute__((warn_unused_result)), because GCC does not silence them via 10570b57cec5SDimitry Andric// (void) cast. 10580b57cec5SDimitry Andric# define _LIBCPP_NODISCARD_ATTRIBUTE 10590b57cec5SDimitry Andric#endif 10600b57cec5SDimitry Andric 10610b57cec5SDimitry Andric// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not 10620b57cec5SDimitry Andric// specified as such as an extension. 10630b57cec5SDimitry Andric#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 10640b57cec5SDimitry Andric# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE 10650b57cec5SDimitry Andric#else 10660b57cec5SDimitry Andric# define _LIBCPP_NODISCARD_EXT 10670b57cec5SDimitry Andric#endif 10680b57cec5SDimitry Andric 10690b57cec5SDimitry Andric#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \ 10700b57cec5SDimitry Andric (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) 10710b57cec5SDimitry Andric# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE 10720b57cec5SDimitry Andric#else 10730b57cec5SDimitry Andric# define _LIBCPP_NODISCARD_AFTER_CXX17 10740b57cec5SDimitry Andric#endif 10750b57cec5SDimitry Andric 10760b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L) 10770b57cec5SDimitry Andric# define _LIBCPP_INLINE_VAR inline 10780b57cec5SDimitry Andric#else 10790b57cec5SDimitry Andric# define _LIBCPP_INLINE_VAR 10800b57cec5SDimitry Andric#endif 10810b57cec5SDimitry Andric 10820b57cec5SDimitry Andric#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 10830b57cec5SDimitry Andric# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) 10840b57cec5SDimitry Andric#else 10850b57cec5SDimitry Andric# define _LIBCPP_EXPLICIT_MOVE(x) (x) 10860b57cec5SDimitry Andric#endif 10870b57cec5SDimitry Andric 10880b57cec5SDimitry Andric#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG 10890b57cec5SDimitry Andric#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 10900b57cec5SDimitry Andric#define _LIBCPP_CONSTEXPR_IF_NODEBUG 10910b57cec5SDimitry Andric#else 10920b57cec5SDimitry Andric#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr 10930b57cec5SDimitry Andric#endif 10940b57cec5SDimitry Andric#endif 10950b57cec5SDimitry Andric 10960b57cec5SDimitry Andric#if __has_attribute(no_destroy) 10970b57cec5SDimitry Andric# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) 10980b57cec5SDimitry Andric#else 10990b57cec5SDimitry Andric# define _LIBCPP_NO_DESTROY 11000b57cec5SDimitry Andric#endif 11010b57cec5SDimitry Andric 11020b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_ASAN 11030b57cec5SDimitry Andric_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( 11040b57cec5SDimitry Andric const void *, const void *, const void *, const void *); 11050b57cec5SDimitry Andric#endif 11060b57cec5SDimitry Andric 11070b57cec5SDimitry Andric// Try to find out if RTTI is disabled. 1108*5ffd83dbSDimitry Andric#if defined(_LIBCPP_COMPILER_CLANG) && !__has_feature(cxx_rtti) 1109*5ffd83dbSDimitry Andric# define _LIBCPP_NO_RTTI 1110*5ffd83dbSDimitry Andric#elif defined(__GNUC__) && !defined(__GXX_RTTI) 11110b57cec5SDimitry Andric# define _LIBCPP_NO_RTTI 11120b57cec5SDimitry Andric#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) 11130b57cec5SDimitry Andric# define _LIBCPP_NO_RTTI 11140b57cec5SDimitry Andric#endif 11150b57cec5SDimitry Andric 11160b57cec5SDimitry Andric#ifndef _LIBCPP_WEAK 11170b57cec5SDimitry Andric#define _LIBCPP_WEAK __attribute__((__weak__)) 11180b57cec5SDimitry Andric#endif 11190b57cec5SDimitry Andric 11200b57cec5SDimitry Andric// Thread API 11210b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_THREADS) && \ 11220b57cec5SDimitry Andric !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ 11230b57cec5SDimitry Andric !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ 11240b57cec5SDimitry Andric !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 11250b57cec5SDimitry Andric# if defined(__FreeBSD__) || \ 11260b57cec5SDimitry Andric defined(__wasi__) || \ 11270b57cec5SDimitry Andric defined(__NetBSD__) || \ 11280b57cec5SDimitry Andric defined(__linux__) || \ 11290b57cec5SDimitry Andric defined(__GNU__) || \ 11300b57cec5SDimitry Andric defined(__APPLE__) || \ 11310b57cec5SDimitry Andric defined(__CloudABI__) || \ 11320b57cec5SDimitry Andric defined(__sun__) || \ 11330b57cec5SDimitry Andric (defined(__MINGW32__) && __has_include(<pthread.h>)) 11340b57cec5SDimitry Andric# define _LIBCPP_HAS_THREAD_API_PTHREAD 1135480093f4SDimitry Andric# elif defined(__Fuchsia__) 1136*5ffd83dbSDimitry Andric // TODO(44575): Switch to C11 thread API when possible. 1137*5ffd83dbSDimitry Andric# define _LIBCPP_HAS_THREAD_API_PTHREAD 11380b57cec5SDimitry Andric# elif defined(_LIBCPP_WIN32API) 11390b57cec5SDimitry Andric# define _LIBCPP_HAS_THREAD_API_WIN32 11400b57cec5SDimitry Andric# else 11410b57cec5SDimitry Andric# error "No thread API" 11420b57cec5SDimitry Andric# endif // _LIBCPP_HAS_THREAD_API 11430b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_THREADS 11440b57cec5SDimitry Andric 1145e40139ffSDimitry Andric#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 1146e40139ffSDimitry Andric#if defined(__ANDROID__) && __ANDROID_API__ >= 30 1147e40139ffSDimitry Andric#define _LIBCPP_HAS_COND_CLOCKWAIT 1148e40139ffSDimitry Andric#elif defined(_LIBCPP_GLIBC_PREREQ) 1149e40139ffSDimitry Andric#if _LIBCPP_GLIBC_PREREQ(2, 30) 1150e40139ffSDimitry Andric#define _LIBCPP_HAS_COND_CLOCKWAIT 1151e40139ffSDimitry Andric#endif 1152e40139ffSDimitry Andric#endif 1153e40139ffSDimitry Andric#endif 1154e40139ffSDimitry Andric 11550b57cec5SDimitry Andric#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 11560b57cec5SDimitry Andric#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ 11570b57cec5SDimitry Andric _LIBCPP_HAS_NO_THREADS is not defined. 11580b57cec5SDimitry Andric#endif 11590b57cec5SDimitry Andric 11600b57cec5SDimitry Andric#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 11610b57cec5SDimitry Andric#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ 11620b57cec5SDimitry Andric _LIBCPP_HAS_NO_THREADS is defined. 11630b57cec5SDimitry Andric#endif 11640b57cec5SDimitry Andric 11650b57cec5SDimitry Andric#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) 11660b57cec5SDimitry Andric#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ 11670b57cec5SDimitry Andric _LIBCPP_HAS_NO_THREADS is defined. 11680b57cec5SDimitry Andric#endif 11690b57cec5SDimitry Andric 1170e40139ffSDimitry Andric#if defined(__STDCPP_THREADS__) && defined(_LIBCPP_HAS_NO_THREADS) 1171e40139ffSDimitry Andric#error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set. 1172e40139ffSDimitry Andric#endif 1173e40139ffSDimitry Andric 1174e40139ffSDimitry Andric#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) 1175e40139ffSDimitry Andric#define __STDCPP_THREADS__ 1 1176e40139ffSDimitry Andric#endif 1177e40139ffSDimitry Andric 1178e40139ffSDimitry Andric// The glibc and Bionic implementation of pthreads implements 11790b57cec5SDimitry Andric// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 11800b57cec5SDimitry Andric// mutexes have no destroy mechanism. 1181e40139ffSDimitry Andric// 1182e40139ffSDimitry Andric// This optimization can't be performed on Apple platforms, where 1183e40139ffSDimitry Andric// pthread_mutex_destroy can allow the kernel to release resources. 1184e40139ffSDimitry Andric// See https://llvm.org/D64298 for details. 1185e40139ffSDimitry Andric// 1186e40139ffSDimitry Andric// TODO(EricWF): Enable this optimization on Bionic after speaking to their 1187e40139ffSDimitry Andric// respective stakeholders. 11880b57cec5SDimitry Andric#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ 1189480093f4SDimitry Andric || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \ 11900b57cec5SDimitry Andric || defined(_LIBCPP_HAS_THREAD_API_WIN32) 11910b57cec5SDimitry Andric# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 11920b57cec5SDimitry Andric#endif 11930b57cec5SDimitry Andric 11940b57cec5SDimitry Andric// Destroying a condvar is a nop on Windows. 1195e40139ffSDimitry Andric// 1196e40139ffSDimitry Andric// This optimization can't be performed on Apple platforms, where 1197e40139ffSDimitry Andric// pthread_cond_destroy can allow the kernel to release resources. 1198e40139ffSDimitry Andric// See https://llvm.org/D64298 for details. 1199e40139ffSDimitry Andric// 12000b57cec5SDimitry Andric// TODO(EricWF): This is potentially true for some pthread implementations 12010b57cec5SDimitry Andric// as well. 1202480093f4SDimitry Andric#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ 1203480093f4SDimitry Andric defined(_LIBCPP_HAS_THREAD_API_WIN32) 12040b57cec5SDimitry Andric# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 12050b57cec5SDimitry Andric#endif 12060b57cec5SDimitry Andric 12070b57cec5SDimitry Andric// Systems that use capability-based security (FreeBSD with Capsicum, 12080b57cec5SDimitry Andric// Nuxi CloudABI) may only provide local filesystem access (using *at()). 12090b57cec5SDimitry Andric// Functions like open(), rename(), unlink() and stat() should not be 12100b57cec5SDimitry Andric// used, as they attempt to access the global filesystem namespace. 12110b57cec5SDimitry Andric#ifdef __CloudABI__ 12120b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 12130b57cec5SDimitry Andric#endif 12140b57cec5SDimitry Andric 12150b57cec5SDimitry Andric// CloudABI is intended for running networked services. Processes do not 12160b57cec5SDimitry Andric// have standard input and output channels. 12170b57cec5SDimitry Andric#ifdef __CloudABI__ 12180b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_STDIN 12190b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_STDOUT 12200b57cec5SDimitry Andric#endif 12210b57cec5SDimitry Andric 12220b57cec5SDimitry Andric// Some systems do not provide gets() in their C library, for security reasons. 12230b57cec5SDimitry Andric#ifndef _LIBCPP_C_HAS_NO_GETS 12240b57cec5SDimitry Andric# if defined(_LIBCPP_MSVCRT) || \ 1225e40139ffSDimitry Andric (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) 12260b57cec5SDimitry Andric# define _LIBCPP_C_HAS_NO_GETS 12270b57cec5SDimitry Andric# endif 12280b57cec5SDimitry Andric#endif 12290b57cec5SDimitry Andric 12300b57cec5SDimitry Andric#if defined(__BIONIC__) || defined(__CloudABI__) || \ 12310b57cec5SDimitry Andric defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) 12320b57cec5SDimitry Andric#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 12330b57cec5SDimitry Andric#endif 12340b57cec5SDimitry Andric 12350b57cec5SDimitry Andric// Thread-unsafe functions such as strtok() and localtime() 12360b57cec5SDimitry Andric// are not available. 12370b57cec5SDimitry Andric#ifdef __CloudABI__ 12380b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS 12390b57cec5SDimitry Andric#endif 12400b57cec5SDimitry Andric 12410b57cec5SDimitry Andric#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) 12420b57cec5SDimitry Andric# define _LIBCPP_HAS_C_ATOMIC_IMP 12430b57cec5SDimitry Andric#elif defined(_LIBCPP_COMPILER_GCC) 12440b57cec5SDimitry Andric# define _LIBCPP_HAS_GCC_ATOMIC_IMP 12450b57cec5SDimitry Andric#endif 12460b57cec5SDimitry Andric 12470b57cec5SDimitry Andric#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ 12480b57cec5SDimitry Andric !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ 12490b57cec5SDimitry Andric !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \ 12500b57cec5SDimitry Andric || defined(_LIBCPP_HAS_NO_THREADS) 12510b57cec5SDimitry Andric# define _LIBCPP_HAS_NO_ATOMIC_HEADER 12520b57cec5SDimitry Andric#else 12530b57cec5SDimitry Andric# ifndef _LIBCPP_ATOMIC_FLAG_TYPE 12540b57cec5SDimitry Andric# define _LIBCPP_ATOMIC_FLAG_TYPE bool 12550b57cec5SDimitry Andric# endif 12560b57cec5SDimitry Andric# ifdef _LIBCPP_FREESTANDING 12570b57cec5SDimitry Andric# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS 12580b57cec5SDimitry Andric# endif 12590b57cec5SDimitry Andric#endif 12600b57cec5SDimitry Andric 12610b57cec5SDimitry Andric#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 12620b57cec5SDimitry Andric#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 12630b57cec5SDimitry Andric#endif 12640b57cec5SDimitry Andric 12650b57cec5SDimitry Andric#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) 12660b57cec5SDimitry Andric# if defined(__clang__) && __has_attribute(acquire_capability) 12670b57cec5SDimitry Andric// Work around the attribute handling in clang. When both __declspec and 12680b57cec5SDimitry Andric// __attribute__ are present, the processing goes awry preventing the definition 12690b57cec5SDimitry Andric// of the types. 12700b57cec5SDimitry Andric# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) 12710b57cec5SDimitry Andric# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 12720b57cec5SDimitry Andric# endif 12730b57cec5SDimitry Andric# endif 12740b57cec5SDimitry Andric#endif 12750b57cec5SDimitry Andric 1276480093f4SDimitry Andric#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION 1277480093f4SDimitry Andric# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1278480093f4SDimitry Andric# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) 1279480093f4SDimitry Andric# else 1280480093f4SDimitry Andric# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) 1281480093f4SDimitry Andric# endif 1282480093f4SDimitry Andric#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION 1283480093f4SDimitry Andric 12840b57cec5SDimitry Andric#if __has_attribute(require_constant_initialization) 12850b57cec5SDimitry Andric# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) 12860b57cec5SDimitry Andric#else 12870b57cec5SDimitry Andric# define _LIBCPP_SAFE_STATIC 12880b57cec5SDimitry Andric#endif 12890b57cec5SDimitry Andric 12900b57cec5SDimitry Andric#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 12910b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF 12920b57cec5SDimitry Andric#endif 12930b57cec5SDimitry Andric 12940b57cec5SDimitry Andric#if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900 12950b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED 12960b57cec5SDimitry Andric#endif 12970b57cec5SDimitry Andric 12980b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) 12990b57cec5SDimitry Andric# if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) 13000b57cec5SDimitry Andric# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS 13010b57cec5SDimitry Andric# endif 13020b57cec5SDimitry Andric#endif 13030b57cec5SDimitry Andric 13040b57cec5SDimitry Andric#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) 13050b57cec5SDimitry Andric# define _LIBCPP_DIAGNOSE_WARNING(...) \ 13060b57cec5SDimitry Andric __attribute__((diagnose_if(__VA_ARGS__, "warning"))) 13070b57cec5SDimitry Andric# define _LIBCPP_DIAGNOSE_ERROR(...) \ 13080b57cec5SDimitry Andric __attribute__((diagnose_if(__VA_ARGS__, "error"))) 13090b57cec5SDimitry Andric#else 13100b57cec5SDimitry Andric# define _LIBCPP_DIAGNOSE_WARNING(...) 13110b57cec5SDimitry Andric# define _LIBCPP_DIAGNOSE_ERROR(...) 13120b57cec5SDimitry Andric#endif 13130b57cec5SDimitry Andric 13140b57cec5SDimitry Andric// Use a function like macro to imply that it must be followed by a semicolon 13150b57cec5SDimitry Andric#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) 13160b57cec5SDimitry Andric# define _LIBCPP_FALLTHROUGH() [[fallthrough]] 13170b57cec5SDimitry Andric#elif __has_cpp_attribute(clang::fallthrough) 13180b57cec5SDimitry Andric# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] 1319480093f4SDimitry Andric#elif __has_attribute(fallthrough) || _GNUC_VER >= 700 13200b57cec5SDimitry Andric# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) 13210b57cec5SDimitry Andric#else 13220b57cec5SDimitry Andric# define _LIBCPP_FALLTHROUGH() ((void)0) 13230b57cec5SDimitry Andric#endif 13240b57cec5SDimitry Andric 13250b57cec5SDimitry Andric#if __has_attribute(__nodebug__) 13260b57cec5SDimitry Andric#define _LIBCPP_NODEBUG __attribute__((__nodebug__)) 13270b57cec5SDimitry Andric#else 13280b57cec5SDimitry Andric#define _LIBCPP_NODEBUG 13290b57cec5SDimitry Andric#endif 13300b57cec5SDimitry Andric 13310b57cec5SDimitry Andric#ifndef _LIBCPP_NODEBUG_TYPE 13320b57cec5SDimitry Andric#if __has_attribute(__nodebug__) && \ 1333e40139ffSDimitry Andric (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900) 13340b57cec5SDimitry Andric#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug)) 13350b57cec5SDimitry Andric#else 13360b57cec5SDimitry Andric#define _LIBCPP_NODEBUG_TYPE 13370b57cec5SDimitry Andric#endif 13380b57cec5SDimitry Andric#endif // !defined(_LIBCPP_NODEBUG_TYPE) 13390b57cec5SDimitry Andric 13400b57cec5SDimitry Andric#if defined(_LIBCPP_ABI_MICROSOFT) && \ 13410b57cec5SDimitry Andric (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) 13420b57cec5SDimitry Andric# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) 13430b57cec5SDimitry Andric#else 13440b57cec5SDimitry Andric# define _LIBCPP_DECLSPEC_EMPTY_BASES 13450b57cec5SDimitry Andric#endif 13460b57cec5SDimitry Andric 13470b57cec5SDimitry Andric#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) 13480b57cec5SDimitry Andric#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR 13490b57cec5SDimitry Andric#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS 13500b57cec5SDimitry Andric#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE 13510b57cec5SDimitry Andric#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS 13520b57cec5SDimitry Andric#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 13530b57cec5SDimitry Andric 13540b57cec5SDimitry Andric#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 13550b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES 13560b57cec5SDimitry Andric#endif 13570b57cec5SDimitry Andric 13580b57cec5SDimitry Andric#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) 13590b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_IS_AGGREGATE 13600b57cec5SDimitry Andric#endif 13610b57cec5SDimitry Andric 13620b57cec5SDimitry Andric#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L 13630b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_COROUTINES 13640b57cec5SDimitry Andric#endif 13650b57cec5SDimitry Andric 136655e4f9d5SDimitry Andric#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L 13670b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR 136855e4f9d5SDimitry Andric#endif 13690b57cec5SDimitry Andric 13700b57cec5SDimitry Andric// Decide whether to use availability macros. 13710b57cec5SDimitry Andric#if !defined(_LIBCPP_BUILDING_LIBRARY) && \ 1372*5ffd83dbSDimitry Andric !defined(_LIBCXXABI_BUILDING_LIBRARY) && \ 13730b57cec5SDimitry Andric !defined(_LIBCPP_DISABLE_AVAILABILITY) && \ 13740b57cec5SDimitry Andric __has_feature(attribute_availability_with_strict) && \ 13750b57cec5SDimitry Andric __has_feature(attribute_availability_in_templates) && \ 13760b57cec5SDimitry Andric __has_extension(pragma_clang_attribute_external_declaration) 13770b57cec5SDimitry Andric# ifdef __APPLE__ 13780b57cec5SDimitry Andric# define _LIBCPP_USE_AVAILABILITY_APPLE 13790b57cec5SDimitry Andric# endif 13800b57cec5SDimitry Andric#endif 13810b57cec5SDimitry Andric 13820b57cec5SDimitry Andric// Define availability macros. 13830b57cec5SDimitry Andric#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) 13840b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \ 13850b57cec5SDimitry Andric __attribute__((availability(macosx,strict,introduced=10.12))) \ 13860b57cec5SDimitry Andric __attribute__((availability(ios,strict,introduced=10.0))) \ 13870b57cec5SDimitry Andric __attribute__((availability(tvos,strict,introduced=10.0))) \ 13880b57cec5SDimitry Andric __attribute__((availability(watchos,strict,introduced=3.0))) 13890b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \ 1390*5ffd83dbSDimitry Andric __attribute__((availability(macosx,strict,introduced=10.13))) \ 1391*5ffd83dbSDimitry Andric __attribute__((availability(ios,strict,introduced=11.0))) \ 1392*5ffd83dbSDimitry Andric __attribute__((availability(tvos,strict,introduced=11.0))) \ 1393*5ffd83dbSDimitry Andric __attribute__((availability(watchos,strict,introduced=4.0))) 13940b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \ 13950b57cec5SDimitry Andric _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 13960b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \ 13970b57cec5SDimitry Andric _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 13980b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \ 13990b57cec5SDimitry Andric __attribute__((availability(macosx,strict,introduced=10.12))) \ 14000b57cec5SDimitry Andric __attribute__((availability(ios,strict,introduced=10.0))) \ 14010b57cec5SDimitry Andric __attribute__((availability(tvos,strict,introduced=10.0))) \ 14020b57cec5SDimitry Andric __attribute__((availability(watchos,strict,introduced=3.0))) 14030b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \ 14040b57cec5SDimitry Andric __attribute__((availability(macosx,strict,introduced=10.12))) \ 14050b57cec5SDimitry Andric __attribute__((availability(ios,strict,introduced=10.0))) \ 14060b57cec5SDimitry Andric __attribute__((availability(tvos,strict,introduced=10.0))) \ 14070b57cec5SDimitry Andric __attribute__((availability(watchos,strict,introduced=3.0))) 14080b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \ 14090b57cec5SDimitry Andric __attribute__((availability(ios,strict,introduced=6.0))) 14100b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \ 14110b57cec5SDimitry Andric __attribute__((availability(macosx,strict,introduced=10.9))) \ 14120b57cec5SDimitry Andric __attribute__((availability(ios,strict,introduced=7.0))) 14130b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \ 14140b57cec5SDimitry Andric __attribute__((availability(macosx,strict,introduced=10.9))) \ 14150b57cec5SDimitry Andric __attribute__((availability(ios,strict,introduced=7.0))) 14160b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \ 14170b57cec5SDimitry Andric __attribute__((availability(macosx,strict,introduced=10.9))) \ 14180b57cec5SDimitry Andric __attribute__((availability(ios,strict,introduced=7.0))) 14190b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM \ 14200b57cec5SDimitry Andric __attribute__((availability(macosx,strict,introduced=10.15))) \ 14210b57cec5SDimitry Andric __attribute__((availability(ios,strict,introduced=13.0))) \ 14220b57cec5SDimitry Andric __attribute__((availability(tvos,strict,introduced=13.0))) \ 14230b57cec5SDimitry Andric __attribute__((availability(watchos,strict,introduced=6.0))) 14240b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \ 14250b57cec5SDimitry Andric _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \ 14260b57cec5SDimitry Andric _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \ 14270b57cec5SDimitry Andric _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \ 14280b57cec5SDimitry Andric _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))") 14290b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \ 14300b57cec5SDimitry Andric _Pragma("clang attribute pop") \ 14310b57cec5SDimitry Andric _Pragma("clang attribute pop") \ 14320b57cec5SDimitry Andric _Pragma("clang attribute pop") \ 14330b57cec5SDimitry Andric _Pragma("clang attribute pop") 1434*5ffd83dbSDimitry Andric# define _LIBCPP_AVAILABILITY_TO_CHARS \ 1435*5ffd83dbSDimitry Andric _LIBCPP_AVAILABILITY_FILESYSTEM 1436*5ffd83dbSDimitry Andric# define _LIBCPP_AVAILABILITY_SYNC \ 1437*5ffd83dbSDimitry Andric __attribute__((unavailable)) 14380b57cec5SDimitry Andric#else 14390b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_SHARED_MUTEX 14400b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS 14410b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 14420b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST 14430b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS 14440b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE 14450b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FUTURE_ERROR 14460b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE 14470b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY 14480b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR 14490b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM 14500b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH 14510b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP 1452*5ffd83dbSDimitry Andric# define _LIBCPP_AVAILABILITY_TO_CHARS 1453*5ffd83dbSDimitry Andric# define _LIBCPP_AVAILABILITY_SYNC 14540b57cec5SDimitry Andric#endif 14550b57cec5SDimitry Andric 14560b57cec5SDimitry Andric// Define availability that depends on _LIBCPP_NO_EXCEPTIONS. 14570b57cec5SDimitry Andric#ifdef _LIBCPP_NO_EXCEPTIONS 14580b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FUTURE 14590b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST 14600b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS 14610b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS 14620b57cec5SDimitry Andric#else 14630b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR 14640b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST 14650b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 14660b57cec5SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS 14670b57cec5SDimitry Andric#endif 14680b57cec5SDimitry Andric 14690b57cec5SDimitry Andric// The stream API was dropped and re-added in the dylib shipped on macOS 14700b57cec5SDimitry Andric// and iOS. We can only assume the dylib to provide these definitions for 14710b57cec5SDimitry Andric// macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available 14720b57cec5SDimitry Andric// from the headers, but not from the dylib. Explicit instantiation 14730b57cec5SDimitry Andric// declarations for streams exist conditionally to this; if we provide 14740b57cec5SDimitry Andric// an explicit instantiation declaration and we try to deploy to a dylib 14750b57cec5SDimitry Andric// that does not provide those symbols, we'll get a load-time error. 14760b57cec5SDimitry Andric#if !defined(_LIBCPP_BUILDING_LIBRARY) && \ 14770b57cec5SDimitry Andric ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ 14780b57cec5SDimitry Andric __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \ 14790b57cec5SDimitry Andric (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ 14800b57cec5SDimitry Andric __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000)) 14810b57cec5SDimitry Andric# define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB 14820b57cec5SDimitry Andric#endif 14830b57cec5SDimitry Andric 14840b57cec5SDimitry Andric#if defined(_LIBCPP_COMPILER_IBM) 14850b57cec5SDimitry Andric#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO 14860b57cec5SDimitry Andric#endif 14870b57cec5SDimitry Andric 14880b57cec5SDimitry Andric#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) 14890b57cec5SDimitry Andric# define _LIBCPP_PUSH_MACROS 14900b57cec5SDimitry Andric# define _LIBCPP_POP_MACROS 14910b57cec5SDimitry Andric#else 14920b57cec5SDimitry Andric // Don't warn about macro conflicts when we can restore them at the 14930b57cec5SDimitry Andric // end of the header. 14940b57cec5SDimitry Andric# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS 14950b57cec5SDimitry Andric# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS 14960b57cec5SDimitry Andric# endif 14970b57cec5SDimitry Andric# if defined(_LIBCPP_COMPILER_MSVC) 14980b57cec5SDimitry Andric# define _LIBCPP_PUSH_MACROS \ 14990b57cec5SDimitry Andric __pragma(push_macro("min")) \ 15000b57cec5SDimitry Andric __pragma(push_macro("max")) 15010b57cec5SDimitry Andric# define _LIBCPP_POP_MACROS \ 15020b57cec5SDimitry Andric __pragma(pop_macro("min")) \ 15030b57cec5SDimitry Andric __pragma(pop_macro("max")) 15040b57cec5SDimitry Andric# else 15050b57cec5SDimitry Andric# define _LIBCPP_PUSH_MACROS \ 15060b57cec5SDimitry Andric _Pragma("push_macro(\"min\")") \ 15070b57cec5SDimitry Andric _Pragma("push_macro(\"max\")") 15080b57cec5SDimitry Andric# define _LIBCPP_POP_MACROS \ 15090b57cec5SDimitry Andric _Pragma("pop_macro(\"min\")") \ 15100b57cec5SDimitry Andric _Pragma("pop_macro(\"max\")") 15110b57cec5SDimitry Andric# endif 15120b57cec5SDimitry Andric#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) 15130b57cec5SDimitry Andric 15140b57cec5SDimitry Andric#ifndef _LIBCPP_NO_AUTO_LINK 15150b57cec5SDimitry Andric# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 15160b57cec5SDimitry Andric# if defined(_DLL) 15170b57cec5SDimitry Andric# pragma comment(lib, "c++.lib") 15180b57cec5SDimitry Andric# else 15190b57cec5SDimitry Andric# pragma comment(lib, "libc++.lib") 15200b57cec5SDimitry Andric# endif 15210b57cec5SDimitry Andric# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 15220b57cec5SDimitry Andric#endif // _LIBCPP_NO_AUTO_LINK 15230b57cec5SDimitry Andric 15240b57cec5SDimitry Andric#define _LIBCPP_UNUSED_VAR(x) ((void)(x)) 15250b57cec5SDimitry Andric 1526e40139ffSDimitry Andric// Configures the fopen close-on-exec mode character, if any. This string will 1527e40139ffSDimitry Andric// be appended to any mode string used by fstream for fopen/fdopen. 1528e40139ffSDimitry Andric// 1529e40139ffSDimitry Andric// Not all platforms support this, but it helps avoid fd-leaks on platforms that 1530e40139ffSDimitry Andric// do. 1531e40139ffSDimitry Andric#if defined(__BIONIC__) 1532e40139ffSDimitry Andric# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" 1533e40139ffSDimitry Andric#else 1534e40139ffSDimitry Andric# define _LIBCPP_FOPEN_CLOEXEC_MODE 1535e40139ffSDimitry Andric#endif 1536e40139ffSDimitry Andric 1537*5ffd83dbSDimitry Andric#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P 1538*5ffd83dbSDimitry Andric#define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x) 1539*5ffd83dbSDimitry Andric#else 1540*5ffd83dbSDimitry Andric#define _LIBCPP_BUILTIN_CONSTANT_P(x) false 1541*5ffd83dbSDimitry Andric#endif 1542*5ffd83dbSDimitry Andric 1543*5ffd83dbSDimitry Andric// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set 1544*5ffd83dbSDimitry Andric// of functions used in cstdio may not be available for low API levels when 1545*5ffd83dbSDimitry Andric// using 64-bit file offsets on LP32. 1546*5ffd83dbSDimitry Andric#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 1547*5ffd83dbSDimitry Andric#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS 1548*5ffd83dbSDimitry Andric#endif 1549*5ffd83dbSDimitry Andric 15500b57cec5SDimitry Andric#endif // __cplusplus 15510b57cec5SDimitry Andric 15520b57cec5SDimitry Andric#endif // _LIBCPP_CONFIG 1553