13e519524SHoward Hinnant// -*- C++ -*- 2eb8650a7SLouis Dionne//===----------------------------------------------------------------------===// 33e519524SHoward Hinnant// 457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information. 657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 73e519524SHoward Hinnant// 83e519524SHoward Hinnant//===----------------------------------------------------------------------===// 93e519524SHoward Hinnant 10cc82a1b0SLouis Dionne#ifndef _LIBCPP___CONFIG 11cc82a1b0SLouis Dionne#define _LIBCPP___CONFIG 123e519524SHoward Hinnant 13c06a8f9cSLouis Dionne#include <__config_site> 14c06a8f9cSLouis Dionne 1560506cbcSEric Fiselier#if defined(_MSC_VER) && !defined(__clang__) 1687996f90SSaleem Abdulrasool# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1760506cbcSEric Fiselier# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 1860506cbcSEric Fiselier# endif 1987996f90SSaleem Abdulrasool#endif 2060506cbcSEric Fiselier 2160506cbcSEric Fiselier#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 223e519524SHoward Hinnant# pragma GCC system_header 23073458b1SHoward Hinnant#endif 243e519524SHoward Hinnant 25bcb9b9fcSGergely Nagy#if defined(__apple_build_version__) 26bcb9b9fcSGergely Nagy# define _LIBCPP_COMPILER_CLANG_BASED 27bcb9b9fcSGergely Nagy# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) 28bcb9b9fcSGergely Nagy#elif defined(__clang__) 29bcb9b9fcSGergely Nagy# define _LIBCPP_COMPILER_CLANG_BASED 30bcb9b9fcSGergely Nagy# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) 31bcb9b9fcSGergely Nagy#elif defined(__GNUC__) 32bcb9b9fcSGergely Nagy# define _LIBCPP_COMPILER_GCC 33bcb9b9fcSGergely Nagy#elif defined(_MSC_VER) 34bcb9b9fcSGergely Nagy# define _LIBCPP_COMPILER_MSVC 35bcb9b9fcSGergely Nagy#endif 36bcb9b9fcSGergely Nagy 3760506cbcSEric Fiselier#ifdef __cplusplus 3860506cbcSEric Fiselier 39*a8af9f67STom Stellard# define _LIBCPP_VERSION 15007 403e519524SHoward Hinnant 41d2e86866SLouis Dionne# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y 42d2e86866SLouis Dionne# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) 43d2e86866SLouis Dionne 44d2e86866SLouis Dionne// Valid C++ identifier that revs with every libc++ version. This can be used to 45d2e86866SLouis Dionne// generate identifiers that must be unique for every released libc++ version. 46d2e86866SLouis Dionne# define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION) 47d2e86866SLouis Dionne 4844cc78daShyd-dev# if __STDC_HOSTED__ == 0 496de760acSDavide Italiano# define _LIBCPP_FREESTANDING 506de760acSDavide Italiano# endif 516de760acSDavide Italiano 52998a5c88SEric Fiselier# ifndef _LIBCPP_STD_VER 53998a5c88SEric Fiselier# if __cplusplus <= 201103L 54998a5c88SEric Fiselier# define _LIBCPP_STD_VER 11 55998a5c88SEric Fiselier# elif __cplusplus <= 201402L 56998a5c88SEric Fiselier# define _LIBCPP_STD_VER 14 57998a5c88SEric Fiselier# elif __cplusplus <= 201703L 58998a5c88SEric Fiselier# define _LIBCPP_STD_VER 17 59044b892cSMarek Kurdej# elif __cplusplus <= 202002L 60044b892cSMarek Kurdej# define _LIBCPP_STD_VER 20 61998a5c88SEric Fiselier# else 6224c12bfbSNikolas Klauser# define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification 63998a5c88SEric Fiselier# endif 64998a5c88SEric Fiselier# endif // _LIBCPP_STD_VER 65998a5c88SEric Fiselier 66538b3f41SShoaib Meenai# if defined(__ELF__) 67538b3f41SShoaib Meenai# define _LIBCPP_OBJECT_FORMAT_ELF 1 68538b3f41SShoaib Meenai# elif defined(__MACH__) 69538b3f41SShoaib Meenai# define _LIBCPP_OBJECT_FORMAT_MACHO 1 70538b3f41SShoaib Meenai# elif defined(_WIN32) 71538b3f41SShoaib Meenai# define _LIBCPP_OBJECT_FORMAT_COFF 1 725029d676SSam Clegg# elif defined(__wasm__) 735029d676SSam Clegg# define _LIBCPP_OBJECT_FORMAT_WASM 1 741cf41139SJake Egan# elif defined(_AIX) 751cf41139SJake Egan# define _LIBCPP_OBJECT_FORMAT_XCOFF 1 76538b3f41SShoaib Meenai# else 7748138e73SLouis Dionne// ... add new file formats here ... 78538b3f41SShoaib Meenai# endif 79538b3f41SShoaib Meenai 8024c12bfbSNikolas Klauser# if _LIBCPP_ABI_VERSION >= 2 814f671370SShoaib Meenai// Change short string representation so that string data starts at offset 0, 8265da7bc3SEvgeniy Stepanov// improving its alignment in some cases. 83a66a7b30SEvgeniy Stepanov# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 8465da7bc3SEvgeniy Stepanov// Fix deque iterator type in order to support incomplete types. 8565da7bc3SEvgeniy Stepanov# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 867fa845e7SNico Weber// Fix undefined behavior in how std::list stores its linked nodes. 87b88ea354SEric Fiselier# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 88d05b10abSEric Fiselier// Fix undefined behavior in how __tree stores its end and parent nodes. 89d05b10abSEric Fiselier# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 907fa845e7SNico Weber// Fix undefined behavior in how __hash_table stores its pointer types. 9140492ba4SEric Fiselier# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 9207b9cd36SEric Fiselier# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 9375d0dcfdSEric Fiselier# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 94c7cd73e8SShoaib Meenai// Define a key function for `bad_function_call` in the library, to centralize 95c7cd73e8SShoaib Meenai// its vtable and typeinfo to libc++ rather than having all other libraries 96c7cd73e8SShoaib Meenai// using that class define their own copies. 97c7cd73e8SShoaib Meenai# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 98434dc0a5SKonstantin Varlamov// Override the default return value of exception::what() for 99434dc0a5SKonstantin Varlamov// bad_function_call::what() with a string that is specific to 100434dc0a5SKonstantin Varlamov// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break 101434dc0a5SKonstantin Varlamov// because it changes the vtable layout of bad_function_call. 102434dc0a5SKonstantin Varlamov# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE 10338bc3df8SAditya Kumar// Enable optimized version of __do_get_(un)signed which avoids redundant copies. 10438bc3df8SAditya Kumar# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET 1051055cb91SLouis Dionne// Give reverse_iterator<T> one data member of type T, not two. 1061055cb91SLouis Dionne// Also, in C++17 and later, don't derive iterator types from std::iterator. 1071055cb91SLouis Dionne# define _LIBCPP_ABI_NO_ITERATOR_BASES 1080ed52538SEric Fiselier// Use the smallest possible integer type to represent the index of the variant. 10977bca6d2SLouis Dionne// Previously libc++ used "unsigned int" exclusively. 1100ed52538SEric Fiselier# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION 11108e231ddSEric Fiselier// Unstable attempt to provide a more optimized std::function 11208e231ddSEric Fiselier# define _LIBCPP_ABI_OPTIMIZED_FUNCTION 1131931c430SMarshall Clow// All the regex constants must be distinct and nonzero. 1141931c430SMarshall Clow# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO 11567532646SMartijn Vels// Re-worked external template instantiations for std::string with a focus on 11667532646SMartijn Vels// performance and fast-path inlining. 11767532646SMartijn Vels# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION 11876887bc4SVy Nguyen// Enable clang::trivial_abi on std::unique_ptr. 11976887bc4SVy Nguyen# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI 12076887bc4SVy Nguyen// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr 12176887bc4SVy Nguyen# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI 122d202c764SLouis Dionne// std::random_device holds some state when it uses an implementation that gets 123d202c764SLouis Dionne// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this 124d202c764SLouis Dionne// implementation to another one on a platform that has already shipped 125d202c764SLouis Dionne// std::random_device, one needs to retain the same object layout to remain ABI 126d202c764SLouis Dionne// compatible. This switch removes these workarounds for platforms that don't care 127d202c764SLouis Dionne// about ABI compatibility. 128d202c764SLouis Dionne# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT 129fe7cd1d1SLouis Dionne// Don't export the legacy __basic_string_common class and its methods from the built library. 1305173f43cSNikolas Klauser# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON 131fe7cd1d1SLouis Dionne// Don't export the legacy __vector_base_common class and its methods from the built library. 132b82da8b5SNikolas Klauser# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON 133667925d4SNikolas Klauser// According to the Standard, `bitset::operator[] const` returns bool 134667925d4SNikolas Klauser# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL 13589818f2dSMark de Wever// Remove the base 10 implementation of std::to_chars from the dylib. 13689818f2dSMark de Wever// The implementation moved to the header, but we still export the symbols from 13789818f2dSMark de Wever// the dylib for backwards compatibility. 13889818f2dSMark de Wever# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 13935b6413dSEric Fiselier# elif _LIBCPP_ABI_VERSION == 1 1401cf41139SJake Egan# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) 14111f60453SEric Fiselier// Enable compiling copies of now inline methods into the dylib to support 142538b3f41SShoaib Meenai// applications compiled against older libraries. This is unnecessary with 143538b3f41SShoaib Meenai// COFF dllexport semantics, since dllexport forces a non-inline definition 144538b3f41SShoaib Meenai// of inline functions to be emitted anyway. Our own non-inline copy would 1451cf41139SJake Egan// conflict with the dllexport-emitted copy, so we disable it. For XCOFF, 1461cf41139SJake Egan// the linker will take issue with the symbols in the shared object if the 1471cf41139SJake Egan// weak inline methods get visibility (such as from -fvisibility-inlines-hidden), 1481cf41139SJake Egan// so disable it. 14911f60453SEric Fiselier# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS 1509aca97d6SEric Fiselier# endif 15135b6413dSEric Fiselier// Feature macros for disabling pre ABI v1 features. All of these options 15235b6413dSEric Fiselier// are deprecated. 15335b6413dSEric Fiselier# if defined(__FreeBSD__) 15435b6413dSEric Fiselier# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 15535b6413dSEric Fiselier# endif 15635b6413dSEric Fiselier# endif 15735b6413dSEric Fiselier 15824c12bfbSNikolas Klauser# if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 159997d41cdSLouis Dionne// Enable additional explicit instantiations of iostreams components. This 160997d41cdSLouis Dionne// reduces the number of weak definitions generated in programs that use 161997d41cdSLouis Dionne// iostreams by providing a single strong definition in the shared library. 162997d41cdSLouis Dionne# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 163434dc0a5SKonstantin Varlamov 164434dc0a5SKonstantin Varlamov// Define a key function for `bad_function_call` in the library, to centralize 165434dc0a5SKonstantin Varlamov// its vtable and typeinfo to libc++ rather than having all other libraries 166434dc0a5SKonstantin Varlamov// using that class define their own copies. 167434dc0a5SKonstantin Varlamov# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 168997d41cdSLouis Dionne# endif 169997d41cdSLouis Dionne 170a7c2a628SNikolas Klauser# define _LIBCPP_TOSTRING2(x) # x 171a7c2a628SNikolas Klauser# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) 172a7c2a628SNikolas Klauser 17354613ab4SEric Fiselier# if __cplusplus < 201103L 17454613ab4SEric Fiselier# define _LIBCPP_CXX03_LANG 17554613ab4SEric Fiselier# endif 176e825d8b7SEric Fiselier 177e825d8b7SEric Fiselier# ifndef __has_attribute 178e825d8b7SEric Fiselier# define __has_attribute(__x) 0 179e825d8b7SEric Fiselier# endif 1802b772b93SLogan Chien 181e825d8b7SEric Fiselier# ifndef __has_builtin 182e825d8b7SEric Fiselier# define __has_builtin(__x) 0 183e825d8b7SEric Fiselier# endif 1842b772b93SLogan Chien 185749adebaSEric Fiselier# ifndef __has_extension 186749adebaSEric Fiselier# define __has_extension(__x) 0 187749adebaSEric Fiselier# endif 1882b772b93SLogan Chien 189e825d8b7SEric Fiselier# ifndef __has_feature 190e825d8b7SEric Fiselier# define __has_feature(__x) 0 191e825d8b7SEric Fiselier# endif 1922b772b93SLogan Chien 1931644c12eSMarshall Clow# ifndef __has_cpp_attribute 1941644c12eSMarshall Clow# define __has_cpp_attribute(__x) 0 1951644c12eSMarshall Clow# endif 1962b772b93SLogan Chien 197e825d8b7SEric Fiselier// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by 198e825d8b7SEric Fiselier// the compiler and '1' otherwise. 199e825d8b7SEric Fiselier# ifndef __is_identifier 200e825d8b7SEric Fiselier# define __is_identifier(__x) 1 201e825d8b7SEric Fiselier# endif 2022b772b93SLogan Chien 203b43f17c8SEric Fiselier# ifndef __has_declspec_attribute 204b43f17c8SEric Fiselier# define __has_declspec_attribute(__x) 0 205b43f17c8SEric Fiselier# endif 206e825d8b7SEric Fiselier 2071e33f12aSEric Fiselier# define __has_keyword(__x) !(__is_identifier(__x)) 2081e33f12aSEric Fiselier 2092a6a3fc4SAlexander Richardson# ifndef __has_include 2102a6a3fc4SAlexander Richardson# define __has_include(...) 0 211a1bc823aSEric Fiselier# endif 212a1bc823aSEric Fiselier 213929d5de2SNikolas Klauser# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L 214929d5de2SNikolas Klauser# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11" 2155de7cacfSEric Fiselier# endif 2165de7cacfSEric Fiselier 21764d63f48SNikolas Klauser# ifdef _LIBCPP_COMPILER_MSVC 21864d63f48SNikolas Klauser# error If you successfully use libc++ with MSVC please tell the libc++ developers and consider upstreaming your \ 21964d63f48SNikolas Klauserchanges. We are not aware of anybody using this configuration and know that at least some code is currently broken. \ 22064d63f48SNikolas KlauserIf there are users of this configuration we are happy to provide support. 22164d63f48SNikolas Klauser# endif 22264d63f48SNikolas Klauser 223330fe017SEric Fiselier// FIXME: ABI detection should be done via compiler builtin macros. This 224330fe017SEric Fiselier// is just a placeholder until Clang implements such macros. For now assume 225d4563850SShoaib Meenai// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, 226d4563850SShoaib Meenai// and allow the user to explicitly specify the ABI to handle cases where this 227d4563850SShoaib Meenai// heuristic falls short. 228a4a3d40eSShoaib Meenai# if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) 229a4a3d40eSShoaib Meenai# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" 230a4a3d40eSShoaib Meenai# elif defined(_LIBCPP_ABI_FORCE_ITANIUM) 231a4a3d40eSShoaib Meenai# define _LIBCPP_ABI_ITANIUM 232a4a3d40eSShoaib Meenai# elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) 233a4a3d40eSShoaib Meenai# define _LIBCPP_ABI_MICROSOFT 234a4a3d40eSShoaib Meenai# else 235330fe017SEric Fiselier# if defined(_WIN32) && defined(_MSC_VER) 236330fe017SEric Fiselier# define _LIBCPP_ABI_MICROSOFT 237330fe017SEric Fiselier# else 238330fe017SEric Fiselier# define _LIBCPP_ABI_ITANIUM 239330fe017SEric Fiselier# endif 240d4563850SShoaib Meenai# endif 241330fe017SEric Fiselier 242e69290dcSEric Fiselier# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) 243e69290dcSEric Fiselier# define _LIBCPP_ABI_VCRUNTIME 244e69290dcSEric Fiselier# endif 245e69290dcSEric Fiselier 246deb3b555SLouis Dionne# if __has_feature(experimental_library) 247deb3b555SLouis Dionne# ifndef _LIBCPP_ENABLE_EXPERIMENTAL 248deb3b555SLouis Dionne# define _LIBCPP_ENABLE_EXPERIMENTAL 249deb3b555SLouis Dionne# endif 250deb3b555SLouis Dionne# endif 251deb3b555SLouis Dionne 2528711fcaeSLouis Dionne// Incomplete features get their own specific disabling flags. This makes it 2538711fcaeSLouis Dionne// easier to grep for target specific flags once the feature is complete. 2548711fcaeSLouis Dionne# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) 2558711fcaeSLouis Dionne# define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT 2568711fcaeSLouis Dionne# define _LIBCPP_HAS_NO_INCOMPLETE_RANGES 2578711fcaeSLouis Dionne# endif 2588711fcaeSLouis Dionne 259c991709fSDan Albert// Need to detect which libc we're using if we're on Linux. 260c991709fSDan Albert# if defined(__linux__) 261c991709fSDan Albert# include <features.h> 2624566d827SPeter Collingbourne# if defined(__GLIBC_PREREQ) 2634566d827SPeter Collingbourne# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) 2644566d827SPeter Collingbourne# else 2654566d827SPeter Collingbourne# define _LIBCPP_GLIBC_PREREQ(a, b) 0 2664566d827SPeter Collingbourne# endif // defined(__GLIBC_PREREQ) 267c991709fSDan Albert# endif // defined(__linux__) 268e825d8b7SEric Fiselier 269a1da7396SMuiez Ahmed# if defined(__MVS__) 270a1da7396SMuiez Ahmed# include <features.h> // for __NATIVE_ASCII_F 271a1da7396SMuiez Ahmed# endif 272a1da7396SMuiez Ahmed 2733e519524SHoward Hinnant# ifdef __LITTLE_ENDIAN__ 2743e519524SHoward Hinnant# if __LITTLE_ENDIAN__ 275da018394SEric Fiselier# define _LIBCPP_LITTLE_ENDIAN 276b3371f6fSHoward Hinnant# endif // __LITTLE_ENDIAN__ 277b3371f6fSHoward Hinnant# endif // __LITTLE_ENDIAN__ 2783e519524SHoward Hinnant 2793e519524SHoward Hinnant# ifdef __BIG_ENDIAN__ 2803e519524SHoward Hinnant# if __BIG_ENDIAN__ 281da018394SEric Fiselier# define _LIBCPP_BIG_ENDIAN 282b3371f6fSHoward Hinnant# endif // __BIG_ENDIAN__ 283b3371f6fSHoward Hinnant# endif // __BIG_ENDIAN__ 2843e519524SHoward Hinnant 2855e61cfdbSDan Albert# ifdef __BYTE_ORDER__ 2865e61cfdbSDan Albert# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 287da018394SEric Fiselier# define _LIBCPP_LITTLE_ENDIAN 2885e61cfdbSDan Albert# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 289da018394SEric Fiselier# define _LIBCPP_BIG_ENDIAN 2905e61cfdbSDan Albert# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 2915e61cfdbSDan Albert# endif // __BYTE_ORDER__ 2925e61cfdbSDan Albert 2932a072ddeSDavid Chisnall# ifdef __FreeBSD__ 2942a072ddeSDavid Chisnall# include <sys/endian.h> 295d5367db9SDimitry Andric# include <osreldate.h> 2962a072ddeSDavid Chisnall# if _BYTE_ORDER == _LITTLE_ENDIAN 297da018394SEric Fiselier# define _LIBCPP_LITTLE_ENDIAN 298b3371f6fSHoward Hinnant# else // _BYTE_ORDER == _LITTLE_ENDIAN 299da018394SEric Fiselier# define _LIBCPP_BIG_ENDIAN 300b3371f6fSHoward Hinnant# endif // _BYTE_ORDER == _LITTLE_ENDIAN 301b3371f6fSHoward Hinnant# endif // __FreeBSD__ 3022a072ddeSDavid Chisnall 30379f99ba6SBrad Smith# if defined(__NetBSD__) || defined(__OpenBSD__) 30450544e7eSJoerg Sonnenberger# include <sys/endian.h> 30550544e7eSJoerg Sonnenberger# if _BYTE_ORDER == _LITTLE_ENDIAN 306da018394SEric Fiselier# define _LIBCPP_LITTLE_ENDIAN 30750544e7eSJoerg Sonnenberger# else // _BYTE_ORDER == _LITTLE_ENDIAN 308da018394SEric Fiselier# define _LIBCPP_BIG_ENDIAN 30950544e7eSJoerg Sonnenberger# endif // _BYTE_ORDER == _LITTLE_ENDIAN 31079f99ba6SBrad Smith# endif // defined(__NetBSD__) || defined(__OpenBSD__) 31150544e7eSJoerg Sonnenberger 312b2826a1dSSaleem Abdulrasool# if defined(_WIN32) 3131ec02625SEric Fiselier# define _LIBCPP_WIN32API 314da018394SEric Fiselier# define _LIBCPP_LITTLE_ENDIAN 315b2826a1dSSaleem Abdulrasool# define _LIBCPP_SHORT_WCHAR 1 31677bca6d2SLouis Dionne// Both MinGW and native MSVC provide a "MSVC"-like environment 3171ec02625SEric Fiselier# define _LIBCPP_MSVCRT_LIKE 318e59dd000SBruno Cardoso Lopes// If mingw not explicitly detected, assume using MS C runtime only if 319e59dd000SBruno Cardoso Lopes// a MS compatibility version is specified. 320e59dd000SBruno Cardoso Lopes# if defined(_MSC_VER) && !defined(__MINGW32__) 3210be8f64cSHoward Hinnant# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library 3225f878d4bSHoward Hinnant# endif 32386eebc5bSSaleem Abdulrasool# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) 32486eebc5bSSaleem Abdulrasool# define _LIBCPP_HAS_BITSCAN64 32586eebc5bSSaleem Abdulrasool# endif 3264801624eSPeter Collingbourne# define _LIBCPP_HAS_OPEN_WITH_WCHAR 327b2826a1dSSaleem Abdulrasool# endif // defined(_WIN32) 3283e71464dSHoward Hinnant 32914c25b80SDavid Chisnall# ifdef __sun__ 33014c25b80SDavid Chisnall# include <sys/isa_defs.h> 33114c25b80SDavid Chisnall# ifdef _LITTLE_ENDIAN 332da018394SEric Fiselier# define _LIBCPP_LITTLE_ENDIAN 33314c25b80SDavid Chisnall# else 334da018394SEric Fiselier# define _LIBCPP_BIG_ENDIAN 33514c25b80SDavid Chisnall# endif 33614c25b80SDavid Chisnall# endif // __sun__ 33714c25b80SDavid Chisnall 338f53fafbaSXing Xue# if defined(_AIX) && !defined(__64BIT__) 339f53fafbaSXing Xue// The size of wchar is 2 byte on 32-bit mode on AIX. 340f53fafbaSXing Xue# define _LIBCPP_SHORT_WCHAR 1 341f53fafbaSXing Xue# endif 342f53fafbaSXing Xue 343beff7152SLouis Dionne// Libc++ supports various implementations of std::random_device. 344beff7152SLouis Dionne// 345beff7152SLouis Dionne// _LIBCPP_USING_DEV_RANDOM 346beff7152SLouis Dionne// Read entropy from the given file, by default `/dev/urandom`. 347beff7152SLouis Dionne// If a token is provided, it is assumed to be the path to a file 348beff7152SLouis Dionne// to read entropy from. This is the default behavior if nothing 349beff7152SLouis Dionne// else is specified. This implementation requires storing state 350beff7152SLouis Dionne// inside `std::random_device`. 351beff7152SLouis Dionne// 352beff7152SLouis Dionne// _LIBCPP_USING_ARC4_RANDOM 353beff7152SLouis Dionne// Use arc4random(). This allows obtaining random data even when 354beff7152SLouis Dionne// using sandboxing mechanisms. On some platforms like Apple, this 355beff7152SLouis Dionne// is the recommended source of entropy for user-space programs. 356beff7152SLouis Dionne// When this option is used, the token passed to `std::random_device`'s 357beff7152SLouis Dionne// constructor *must* be "/dev/urandom" -- anything else is an error. 358beff7152SLouis Dionne// 359beff7152SLouis Dionne// _LIBCPP_USING_GETENTROPY 360beff7152SLouis Dionne// Use getentropy(). 361beff7152SLouis Dionne// When this option is used, the token passed to `std::random_device`'s 362beff7152SLouis Dionne// constructor *must* be "/dev/urandom" -- anything else is an error. 363beff7152SLouis Dionne// 3643064dd8cSRoland McGrath// _LIBCPP_USING_FUCHSIA_CPRNG 3653064dd8cSRoland McGrath// Use Fuchsia's zx_cprng_draw() system call, which is specified to 3663064dd8cSRoland McGrath// deliver high-quality entropy and cannot fail. 3673064dd8cSRoland McGrath// When this option is used, the token passed to `std::random_device`'s 3683064dd8cSRoland McGrath// constructor *must* be "/dev/urandom" -- anything else is an error. 3693064dd8cSRoland McGrath// 370beff7152SLouis Dionne// _LIBCPP_USING_NACL_RANDOM 371beff7152SLouis Dionne// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, 372beff7152SLouis Dionne// including accesses to the special files under `/dev`. This implementation 373beff7152SLouis Dionne// uses the NaCL syscall `nacl_secure_random_init()` to get entropy. 374beff7152SLouis Dionne// When this option is used, the token passed to `std::random_device`'s 375beff7152SLouis Dionne// constructor *must* be "/dev/urandom" -- anything else is an error. 376beff7152SLouis Dionne// 377beff7152SLouis Dionne// _LIBCPP_USING_WIN32_RANDOM 378beff7152SLouis Dionne// Use rand_s(), for use on Windows. 379beff7152SLouis Dionne// When this option is used, the token passed to `std::random_device`'s 380beff7152SLouis Dionne// constructor *must* be "/dev/urandom" -- anything else is an error. 381ac251726SNikolas Klauser# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ 382ac251726SNikolas Klauser defined(__DragonFly__) || defined(__sun__) 383beff7152SLouis Dionne# define _LIBCPP_USING_ARC4_RANDOM 384b86771a2SSam Clegg# elif defined(__wasi__) || defined(__EMSCRIPTEN__) 385beff7152SLouis Dionne# define _LIBCPP_USING_GETENTROPY 3863064dd8cSRoland McGrath# elif defined(__Fuchsia__) 3873064dd8cSRoland McGrath# define _LIBCPP_USING_FUCHSIA_CPRNG 388beff7152SLouis Dionne# elif defined(__native_client__) 389beff7152SLouis Dionne# define _LIBCPP_USING_NACL_RANDOM 390beff7152SLouis Dionne# elif defined(_LIBCPP_WIN32API) 391beff7152SLouis Dionne# define _LIBCPP_USING_WIN32_RANDOM 392beff7152SLouis Dionne# else 393beff7152SLouis Dionne# define _LIBCPP_USING_DEV_RANDOM 394beff7152SLouis Dionne# endif 395beff7152SLouis Dionne 396da018394SEric Fiselier# if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 397128ba719SHoward Hinnant# include <endian.h> 398128ba719SHoward Hinnant# if __BYTE_ORDER == __LITTLE_ENDIAN 399da018394SEric Fiselier# define _LIBCPP_LITTLE_ENDIAN 400128ba719SHoward Hinnant# elif __BYTE_ORDER == __BIG_ENDIAN 401da018394SEric Fiselier# define _LIBCPP_BIG_ENDIAN 402b3371f6fSHoward Hinnant# else // __BYTE_ORDER == __BIG_ENDIAN 4033e519524SHoward Hinnant# error unable to determine endian 4043e519524SHoward Hinnant# endif 405da018394SEric Fiselier# endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 4063e519524SHoward Hinnant 407b4f962cdSEric Fiselier# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) 4083e58a6a7SEvgeniy Stepanov# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) 4093e58a6a7SEvgeniy Stepanov# else 4103e58a6a7SEvgeniy Stepanov# define _LIBCPP_NO_CFI 4113e58a6a7SEvgeniy Stepanov# endif 4123e58a6a7SEvgeniy Stepanov 413d108bf85SEric Fiselier# ifndef _LIBCPP_CXX03_LANG 414929d5de2SNikolas Klauser 415d108bf85SEric Fiselier# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) 416929d5de2SNikolas Klauser# define _ALIGNAS_TYPE(x) alignas(x) 417929d5de2SNikolas Klauser# define _ALIGNAS(x) alignas(x) 418929d5de2SNikolas Klauser# define _LIBCPP_NORETURN [[noreturn]] 419929d5de2SNikolas Klauser# define _NOEXCEPT noexcept 420929d5de2SNikolas Klauser# define _NOEXCEPT_(x) noexcept(x) 421929d5de2SNikolas Klauser 422d108bf85SEric Fiselier# else 423929d5de2SNikolas Klauser 424929d5de2SNikolas Klauser# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) 425929d5de2SNikolas Klauser# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 426929d5de2SNikolas Klauser# define _ALIGNAS(x) __attribute__((__aligned__(x))) 427929d5de2SNikolas Klauser# define _LIBCPP_NORETURN __attribute__((noreturn)) 428929d5de2SNikolas Klauser# define _LIBCPP_HAS_NO_NOEXCEPT 429929d5de2SNikolas Klauser# define nullptr __nullptr 430929d5de2SNikolas Klauser# define _NOEXCEPT throw() 431929d5de2SNikolas Klauser# define _NOEXCEPT_(x) 432929d5de2SNikolas Klauser 433929d5de2SNikolas Klausertypedef __char16_t char16_t; 434929d5de2SNikolas Klausertypedef __char32_t char32_t; 435929d5de2SNikolas Klauser 436929d5de2SNikolas Klauser# endif 437929d5de2SNikolas Klauser 438929d5de2SNikolas Klauser# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L 439929d5de2SNikolas Klauser# define _LIBCPP_NO_EXCEPTIONS 440d108bf85SEric Fiselier# endif 441d108bf85SEric Fiselier 442d108bf85SEric Fiselier# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) 443d108bf85SEric Fiselier 4445c703f0fSMarek Kurdej# if defined(_LIBCPP_COMPILER_CLANG_BASED) 445eb269257SHoward Hinnant 446ac251726SNikolas Klauser# if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) 447a66a7b30SEvgeniy Stepanov# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 448c3a57e91STim Northover# endif 449c3a57e91STim Northover 45064ec101eSDouglas Gregor// Objective-C++ features (opt-in) 45164ec101eSDouglas Gregor# if __has_feature(objc_arc) 45264ec101eSDouglas Gregor# define _LIBCPP_HAS_OBJC_ARC 45364ec101eSDouglas Gregor# endif 45464ec101eSDouglas Gregor 45564ec101eSDouglas Gregor# if __has_feature(objc_arc_weak) 45664ec101eSDouglas Gregor# define _LIBCPP_HAS_OBJC_ARC_WEAK 45764ec101eSDouglas Gregor# endif 45864ec101eSDouglas Gregor 4598ae404a2SLouis Dionne# if __has_extension(blocks) 4608ae404a2SLouis Dionne# define _LIBCPP_HAS_EXTENSION_BLOCKS 4618ae404a2SLouis Dionne# endif 4628ae404a2SLouis Dionne 463f76c4241SLouis Dionne# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) 464f76c4241SLouis Dionne# define _LIBCPP_HAS_BLOCKS_RUNTIME 465f76c4241SLouis Dionne# endif 466f76c4241SLouis Dionne 467fb4e4646SLouis Dionne# if !__has_feature(address_sanitizer) 46891c71dddSMarshall Clow# define _LIBCPP_HAS_NO_ASAN 46991c71dddSMarshall Clow# endif 47091c71dddSMarshall Clow 4717087a51bSMarshall Clow// Allow for build-time disabling of unsigned integer sanitization 472fb4e4646SLouis Dionne# if __has_attribute(no_sanitize) 47338fc9fe1SSaleem Abdulrasool# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) 4747087a51bSMarshall Clow# endif 4757087a51bSMarshall Clow 476cb3eb306SLouis Dionne# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 477cb3eb306SLouis Dionne 478801f6a49SLouis Dionne# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 479801f6a49SLouis Dionne 480541f9e28SEric Fiselier# elif defined(_LIBCPP_COMPILER_GCC) 481eb269257SHoward Hinnant 482fb4e4646SLouis Dionne# if !defined(__SANITIZE_ADDRESS__) 48391c71dddSMarshall Clow# define _LIBCPP_HAS_NO_ASAN 48491c71dddSMarshall Clow# endif 48591c71dddSMarshall Clow 486cb3eb306SLouis Dionne# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 487cb3eb306SLouis Dionne 488801f6a49SLouis Dionne# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 489801f6a49SLouis Dionne 490541f9e28SEric Fiselier# elif defined(_LIBCPP_COMPILER_MSVC) 491073458b1SHoward Hinnant 492541f9e28SEric Fiselier# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) 493541f9e28SEric Fiselier 494541f9e28SEric Fiselier# if _MSC_VER < 1900 495541f9e28SEric Fiselier# error "MSVC versions prior to Visual Studio 2015 are not supported" 496541f9e28SEric Fiselier# endif 497541f9e28SEric Fiselier 498535a86c3SRichard Smith# define _LIBCPP_NORETURN __declspec(noreturn) 499073458b1SHoward Hinnant 5002b772b93SLogan Chien# define _LIBCPP_WEAK 5012b772b93SLogan Chien 50291c71dddSMarshall Clow# define _LIBCPP_HAS_NO_ASAN 50391c71dddSMarshall Clow 504cb3eb306SLouis Dionne# define _LIBCPP_ALWAYS_INLINE __forceinline 505cb3eb306SLouis Dionne 50638cd7de5STim Shen# define _LIBCPP_HAS_NO_VECTOR_EXTENSION 50738cd7de5STim Shen 508801f6a49SLouis Dionne# define _LIBCPP_DISABLE_EXTENSION_WARNING 509801f6a49SLouis Dionne 510ee78181fSLouis Dionne# endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC] 5113e519524SHoward Hinnant 512b2826a1dSSaleem Abdulrasool# if defined(_LIBCPP_OBJECT_FORMAT_COFF) 5132b772b93SLogan Chien 5144bdb80faSPeter Collingbourne# ifdef _DLL 5154bdb80faSPeter Collingbourne# define _LIBCPP_CRT_FUNC __declspec(dllimport) 5164bdb80faSPeter Collingbourne# else 5174bdb80faSPeter Collingbourne# define _LIBCPP_CRT_FUNC 5184bdb80faSPeter Collingbourne# endif 5194bdb80faSPeter Collingbourne 520dfa88927SMartin Storsjö# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY)) 52149e2967fSEric Fiselier# define _LIBCPP_DLL_VIS 522190994e4SShoaib Meenai# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 523190994e4SShoaib Meenai# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 524dce4218dSShoaib Meenai# define _LIBCPP_OVERRIDABLE_FUNC_VIS 5259b3222f6SLouis Dionne# define _LIBCPP_EXPORTED_FROM_ABI 52654644216SEric Fiselier# elif defined(_LIBCPP_BUILDING_LIBRARY) 52754644216SEric Fiselier# define _LIBCPP_DLL_VIS __declspec(dllexport) 5282bbb7fedSMartin Storsjo# if defined(__MINGW32__) 5292bbb7fedSMartin Storsjo# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 5302bbb7fedSMartin Storsjo# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 5312bbb7fedSMartin Storsjo# else 53254644216SEric Fiselier# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 53354644216SEric Fiselier# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS 5342bbb7fedSMartin Storsjo# endif 535dce4218dSShoaib Meenai# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS 5369b3222f6SLouis Dionne# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) 53754644216SEric Fiselier# else 53854644216SEric Fiselier# define _LIBCPP_DLL_VIS __declspec(dllimport) 53954644216SEric Fiselier# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 54054644216SEric Fiselier# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 541dce4218dSShoaib Meenai# define _LIBCPP_OVERRIDABLE_FUNC_VIS 5429b3222f6SLouis Dionne# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) 54349e2967fSEric Fiselier# endif 54454644216SEric Fiselier 54549e2967fSEric Fiselier# define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS 54649e2967fSEric Fiselier# define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS 54749e2967fSEric Fiselier# define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS 54849e2967fSEric Fiselier# define _LIBCPP_HIDDEN 549bad28c44SShoaib Meenai# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 550e2f2d1edSEric Fiselier# define _LIBCPP_TEMPLATE_VIS 551c793f68dSMartin Storsjö# define _LIBCPP_TEMPLATE_DATA_VIS 55249e2967fSEric Fiselier# define _LIBCPP_ENUM_VIS 553b2826a1dSSaleem Abdulrasool 554fc6100c1SShoaib Meenai# else 555758504b8SNikolas Klauser 556758504b8SNikolas Klauser# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 557758504b8SNikolas Klauser# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis))) 558758504b8SNikolas Klauser# else 559758504b8SNikolas Klauser# define _LIBCPP_VISIBILITY(vis) 56049e2967fSEric Fiselier# endif 56149e2967fSEric Fiselier 562758504b8SNikolas Klauser# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden") 563758504b8SNikolas Klauser# define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default") 564758504b8SNikolas Klauser# define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default") 565758504b8SNikolas Klauser# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default") 566758504b8SNikolas Klauser# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default") 567758504b8SNikolas Klauser# define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default") 568758504b8SNikolas Klauser# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default") 569758504b8SNikolas Klauser# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 570758504b8SNikolas Klauser 5710f050528SNikolas Klauser// TODO: Make this a proper customization point or remove the option to override it. 5720f050528SNikolas Klauser# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS 5730f050528SNikolas Klauser# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default") 5740f050528SNikolas Klauser# endif 5750f050528SNikolas Klauser 5765e5d8672SShoaib Meenai# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 577bad28c44SShoaib Meenai// The inline should be removed once PR32114 is resolved 578bad28c44SShoaib Meenai# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN 5795e5d8672SShoaib Meenai# else 5805e5d8672SShoaib Meenai# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 5815e5d8672SShoaib Meenai# endif 582bad28c44SShoaib Meenai 583bda3c7dfSShoaib Meenai# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 584bda3c7dfSShoaib Meenai# if __has_attribute(__type_visibility__) 585bda3c7dfSShoaib Meenai# define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default"))) 586bda3c7dfSShoaib Meenai# else 587bda3c7dfSShoaib Meenai# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) 588bda3c7dfSShoaib Meenai# endif 589bda3c7dfSShoaib Meenai# else 590bda3c7dfSShoaib Meenai# define _LIBCPP_TEMPLATE_VIS 591bda3c7dfSShoaib Meenai# endif 59249e2967fSEric Fiselier 593fc6100c1SShoaib Meenai# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 59449e2967fSEric Fiselier# define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default"))) 59549e2967fSEric Fiselier# else 59649e2967fSEric Fiselier# define _LIBCPP_ENUM_VIS 59749e2967fSEric Fiselier# endif 59849e2967fSEric Fiselier 599758504b8SNikolas Klauser# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) 600190994e4SShoaib Meenai 601e9d85264SLouis Dionne# if __has_attribute(exclude_from_explicit_instantiation) 602e9d85264SLouis Dionne# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__)) 603e9d85264SLouis Dionne# else 604e9d85264SLouis Dionne// Try to approximate the effect of exclude_from_explicit_instantiation 605e9d85264SLouis Dionne// (which is that entities are not assumed to be provided by explicit 60677bca6d2SLouis Dionne// template instantiations in the dylib) by always inlining those entities. 607e9d85264SLouis Dionne# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE 608e9d85264SLouis Dionne# endif 609e9d85264SLouis Dionne 610d2e86866SLouis Dionne// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved 611d2e86866SLouis Dionne// on two levels: 612d2e86866SLouis Dionne// 1. The symbol is given hidden visibility, which ensures that users won't start exporting 613d2e86866SLouis Dionne// symbols from their dynamic library by means of using the libc++ headers. This ensures 614d2e86866SLouis Dionne// that those symbols stay private to the dynamic library in which it is defined. 615d2e86866SLouis Dionne// 616d2e86866SLouis Dionne// 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures 617d2e86866SLouis Dionne// that no ODR violation can arise from mixing two TUs compiled with different versions 618d2e86866SLouis Dionne// of libc++ where we would have changed the definition of a symbol. If the symbols shared 619d2e86866SLouis Dionne// the same name, the ODR would require that their definitions be token-by-token equivalent, 620d2e86866SLouis Dionne// which basically prevents us from being able to make any change to any function in our 621d2e86866SLouis Dionne// headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at 622d2e86866SLouis Dionne// each release, which lets us change the definition of these symbols at our leisure. 623d2e86866SLouis Dionne// Note that historically, this has been achieved in various ways, including force-inlining 624d2e86866SLouis Dionne// all functions or giving internal linkage to all functions. Both these (previous) solutions 625d2e86866SLouis Dionne// suffer from drawbacks that lead notably to code bloat. 626d2e86866SLouis Dionne// 627d2e86866SLouis Dionne// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend 628d2e86866SLouis Dionne// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library. 629d2e86866SLouis Dionne// 630d2e86866SLouis Dionne// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing 631d2e86866SLouis Dionne// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and 632d2e86866SLouis Dionne// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70. 633d2e86866SLouis Dionne# ifndef _LIBCPP_NO_ABI_TAG 634d2e86866SLouis Dionne# define _LIBCPP_HIDE_FROM_ABI \ 635d2e86866SLouis Dionne _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ 636d2e86866SLouis Dionne __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER)))) 63761cd6870SLouis Dionne# else 638e9d85264SLouis Dionne# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 63961cd6870SLouis Dionne# endif 64049e2967fSEric Fiselier 641ba71bd7cSLouis Dionne# ifdef _LIBCPP_BUILDING_LIBRARY 642ba71bd7cSLouis Dionne# if _LIBCPP_ABI_VERSION > 1 643ba71bd7cSLouis Dionne# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 644fc6100c1SShoaib Meenai# else 645ba71bd7cSLouis Dionne# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 646fc6100c1SShoaib Meenai# endif 647ba71bd7cSLouis Dionne# else 648ba71bd7cSLouis Dionne# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 649f8f31c49SEric Fiselier# endif 650f8f31c49SEric Fiselier 651ba71bd7cSLouis Dionne// Just so we can migrate to the new macros gradually. 652ba71bd7cSLouis Dionne# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI 653ba71bd7cSLouis Dionne 6542f3e8b3dSEric Fiselier// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. 655ac251726SNikolas Klauser// clang-format off 656fe13c13cSEric Fiselier# define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { 6572f3e8b3dSEric Fiselier# define _LIBCPP_END_NAMESPACE_STD }} 658453620f5SNikolas Klauser# define _VSTD std 659ac251726SNikolas Klauser 6602f3e8b3dSEric Fiselier_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD 6612f3e8b3dSEric Fiselier 662453620f5SNikolas Klauser# if _LIBCPP_STD_VER > 14 6632f3e8b3dSEric Fiselier# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 6642f3e8b3dSEric Fiselier _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { 6652f3e8b3dSEric Fiselier# else 6662f3e8b3dSEric Fiselier# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 6672f3e8b3dSEric Fiselier _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { 6682f3e8b3dSEric Fiselier# endif 6692f3e8b3dSEric Fiselier 670ac251726SNikolas Klauser# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }} 671ac251726SNikolas Klauser// clang-format on 6722f3e8b3dSEric Fiselier 67324c12bfbSNikolas Klauser# define _VSTD_FS std::__fs::filesystem 6742f3e8b3dSEric Fiselier 67549e2967fSEric Fiselier# if __has_attribute(__enable_if__) 67649e2967fSEric Fiselier# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, ""))) 67749e2967fSEric Fiselier# endif 67849e2967fSEric Fiselier 679e180ecabSStephan Tolksdorf# ifndef __SIZEOF_INT128__ 680e180ecabSStephan Tolksdorf# define _LIBCPP_HAS_NO_INT128 681e180ecabSStephan Tolksdorf# endif 682e180ecabSStephan Tolksdorf 68354613ab4SEric Fiselier# ifdef _LIBCPP_CXX03_LANG 6845c739665SEric Fiselier# define static_assert(...) _Static_assert(__VA_ARGS__) 6855c739665SEric Fiselier# define decltype(...) __decltype(__VA_ARGS__) 68654613ab4SEric Fiselier# endif // _LIBCPP_CXX03_LANG 6873e519524SHoward Hinnant 688395c7330SEric Fiselier# ifdef _LIBCPP_CXX03_LANG 689788c9979SHoward Hinnant# define _LIBCPP_CONSTEXPR 690788c9979SHoward Hinnant# else 691788c9979SHoward Hinnant# define _LIBCPP_CONSTEXPR constexpr 692db3e9975SHoward Hinnant# endif 693db3e9975SHoward Hinnant 694bf434a5fSRichard Smith# ifndef __cpp_consteval 695bf434a5fSRichard Smith# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR 696bf434a5fSRichard Smith# else 697bf434a5fSRichard Smith# define _LIBCPP_CONSTEVAL consteval 698bf434a5fSRichard Smith# endif 699bf434a5fSRichard Smith 7006317bfb2SNuno Lopes# ifdef __GNUC__ 7015d79eaa8SLouis Dionne# define _LIBCPP_NOALIAS __attribute__((__malloc__)) 7026317bfb2SNuno Lopes# else 7035d79eaa8SLouis Dionne# define _LIBCPP_NOALIAS 7046317bfb2SNuno Lopes# endif 7056317bfb2SNuno Lopes 706a9c9183cSLouis Dionne# if __has_attribute(using_if_exists) 707a9c9183cSLouis Dionne# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) 708a9c9183cSLouis Dionne# else 709a9c9183cSLouis Dionne# define _LIBCPP_USING_IF_EXISTS 710a9c9183cSLouis Dionne# endif 711a9c9183cSLouis Dionne 71293b33390SMark de Wever# ifdef _LIBCPP_CXX03_LANG 713ac251726SNikolas Klauser# define _LIBCPP_DECLARE_STRONG_ENUM(x) \ 714ac251726SNikolas Klauser struct _LIBCPP_TYPE_VIS x { \ 715ac251726SNikolas Klauser enum __lx 716ac251726SNikolas Klauser// clang-format off 71775689c10SHoward Hinnant# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 71854d333a6SHoward Hinnant __lx __v_; \ 719dc7200b4SLouis Dionne _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ 720dc7200b4SLouis Dionne _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 721dc7200b4SLouis Dionne _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \ 72275689c10SHoward Hinnant }; 723ac251726SNikolas Klauser// clang-format on 724ac251726SNikolas Klauser 72593b33390SMark de Wever# else // _LIBCPP_CXX03_LANG 72649e2967fSEric Fiselier# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x 72775689c10SHoward Hinnant# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 72893b33390SMark de Wever# endif // _LIBCPP_CXX03_LANG 72975689c10SHoward Hinnant 730ac251726SNikolas Klauser# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \ 731ac251726SNikolas Klauser defined(__NetBSD__) 7324084c9ebSAlexis Hunt# define _LIBCPP_LOCALE__L_EXTENSIONS 1 7334084c9ebSAlexis Hunt# endif 73421a697b8SYaron Keren 73569e76f80SMarshall Clow# ifdef __FreeBSD__ 7365e8e0448SDavid Chisnall# define _DECLARE_C99_LDBL_MATH 1 7375e8e0448SDavid Chisnall# endif 7384084c9ebSAlexis Hunt 7396a2a5e0aSReid Kleckner// If we are getting operator new from the MSVC CRT, then allocation overloads 7406a2a5e0aSReid Kleckner// for align_val_t were added in 19.12, aka VS 2017 version 15.3. 7416a2a5e0aSReid Kleckner# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 74242f9868cSEric Fiselier# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 743e69290dcSEric Fiselier# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) 74477bca6d2SLouis Dionne// We're deferring to Microsoft's STL to provide aligned new et al. We don't 74542f9868cSEric Fiselier// have it unless the language feature test macro is defined. 74642f9868cSEric Fiselier# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 747aa8a5b80SZbigniew Sarbinowski# elif defined(__MVS__) 748aa8a5b80SZbigniew Sarbinowski# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 74942f9868cSEric Fiselier# endif 7506a2a5e0aSReid Kleckner 751ac251726SNikolas Klauser# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) 75253ac1776SLouis Dionne# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION 75353ac1776SLouis Dionne# endif 754f2918d1cSEric Fiselier 75569e76f80SMarshall Clow# if defined(__APPLE__) || defined(__FreeBSD__) 7569978e370SHoward Hinnant# define _LIBCPP_HAS_DEFAULTRUNELOCALE 757f0235197SAlexis Hunt# endif 758f0235197SAlexis Hunt 75969e76f80SMarshall Clow# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) 7600081892dSAlexis Hunt# define _LIBCPP_WCTYPE_IS_MASK 7610081892dSAlexis Hunt# endif 7620081892dSAlexis Hunt 7637dad0bd6SMarshall Clow# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) 7645c40c994SArthur O'Dwyer# define _LIBCPP_HAS_NO_CHAR8_T 7657dad0bd6SMarshall Clow# endif 7667dad0bd6SMarshall Clow 767ea5cd3b4SLouis Dionne// Deprecation macros. 768a470a13aSLouis Dionne// 769a470a13aSLouis Dionne// Deprecations warnings are always enabled, except when users explicitly opt-out 770a470a13aSLouis Dionne// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. 771a470a13aSLouis Dionne# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) 772ea5cd3b4SLouis Dionne# if __has_attribute(deprecated) 773ea5cd3b4SLouis Dionne# define _LIBCPP_DEPRECATED __attribute__((deprecated)) 774971e9c80SNikolas Klauser# define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m))) 775ea5cd3b4SLouis Dionne# elif _LIBCPP_STD_VER > 11 7768392ab20SMarshall Clow# define _LIBCPP_DEPRECATED [[deprecated]] 777971e9c80SNikolas Klauser# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]] 7788392ab20SMarshall Clow# else 7798392ab20SMarshall Clow# define _LIBCPP_DEPRECATED 780971e9c80SNikolas Klauser# define _LIBCPP_DEPRECATED_(m) 7818392ab20SMarshall Clow# endif 782ea5cd3b4SLouis Dionne# else 783ea5cd3b4SLouis Dionne# define _LIBCPP_DEPRECATED 784971e9c80SNikolas Klauser# define _LIBCPP_DEPRECATED_(m) 785ea5cd3b4SLouis Dionne# endif 786ea5cd3b4SLouis Dionne 787ea5cd3b4SLouis Dionne# if !defined(_LIBCPP_CXX03_LANG) 788ea5cd3b4SLouis Dionne# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED 789ea5cd3b4SLouis Dionne# else 790ea5cd3b4SLouis Dionne# define _LIBCPP_DEPRECATED_IN_CXX11 791ea5cd3b4SLouis Dionne# endif 792ea5cd3b4SLouis Dionne 79324c12bfbSNikolas Klauser# if _LIBCPP_STD_VER > 11 794ea5cd3b4SLouis Dionne# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED 795ea5cd3b4SLouis Dionne# else 796ea5cd3b4SLouis Dionne# define _LIBCPP_DEPRECATED_IN_CXX14 797ea5cd3b4SLouis Dionne# endif 798ea5cd3b4SLouis Dionne 79924c12bfbSNikolas Klauser# if _LIBCPP_STD_VER > 14 800ea5cd3b4SLouis Dionne# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED 801ea5cd3b4SLouis Dionne# else 802ea5cd3b4SLouis Dionne# define _LIBCPP_DEPRECATED_IN_CXX17 803ea5cd3b4SLouis Dionne# endif 8048392ab20SMarshall Clow 805841132efSMarek Kurdej# if _LIBCPP_STD_VER > 17 806841132efSMarek Kurdej# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED 807841132efSMarek Kurdej# else 808841132efSMarek Kurdej# define _LIBCPP_DEPRECATED_IN_CXX20 809841132efSMarek Kurdej# endif 810841132efSMarek Kurdej 8115c40c994SArthur O'Dwyer# if !defined(_LIBCPP_HAS_NO_CHAR8_T) 8126be11e35SMartin Storsjö# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED 8136be11e35SMartin Storsjö# else 8146be11e35SMartin Storsjö# define _LIBCPP_DEPRECATED_WITH_CHAR8_T 8156be11e35SMartin Storsjö# endif 8166be11e35SMartin Storsjö 817a9727033SRichard Smith// Macros to enter and leave a state where deprecation warnings are suppressed. 818fb4e4646SLouis Dionne# if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) 819a9727033SRichard Smith# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ 820ac251726SNikolas Klauser _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ 8212e4755ffSLouis Dionne _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 822ac251726SNikolas Klauser# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop") 823fb4e4646SLouis Dionne# else 824a9727033SRichard Smith# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH 825a9727033SRichard Smith# define _LIBCPP_SUPPRESS_DEPRECATED_POP 826a9727033SRichard Smith# endif 827a9727033SRichard Smith 828f20d2672SMarshall Clow# if _LIBCPP_STD_VER <= 11 8297988106bSMarshall Clow# define _LIBCPP_EXPLICIT_AFTER_CXX11 830f20d2672SMarshall Clow# else 8317988106bSMarshall Clow# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit 832f20d2672SMarshall Clow# endif 833f20d2672SMarshall Clow 83477b32055SLouis Dionne# if _LIBCPP_STD_VER > 11 835371aac1aSEric Fiselier# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr 836371aac1aSEric Fiselier# else 837371aac1aSEric Fiselier# define _LIBCPP_CONSTEXPR_AFTER_CXX11 838371aac1aSEric Fiselier# endif 839371aac1aSEric Fiselier 84077b32055SLouis Dionne# if _LIBCPP_STD_VER > 14 841a58d430cSEric Fiselier# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr 842a58d430cSEric Fiselier# else 843a58d430cSEric Fiselier# define _LIBCPP_CONSTEXPR_AFTER_CXX14 844a58d430cSEric Fiselier# endif 845a58d430cSEric Fiselier 84677b32055SLouis Dionne# if _LIBCPP_STD_VER > 17 8471644c12eSMarshall Clow# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr 8481644c12eSMarshall Clow# else 8491644c12eSMarshall Clow# define _LIBCPP_CONSTEXPR_AFTER_CXX17 8501644c12eSMarshall Clow# endif 8511644c12eSMarshall Clow 852c65d39a4SRoman Lebedev# if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) 853928cad59SLouis Dionne# define _LIBCPP_NODISCARD [[nodiscard]] 8545c703f0fSMarek Kurdej# elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) 855928cad59SLouis Dionne# define _LIBCPP_NODISCARD [[clang::warn_unused_result]] 856c65d39a4SRoman Lebedev# else 857c65d39a4SRoman Lebedev// We can't use GCC's [[gnu::warn_unused_result]] and 858c65d39a4SRoman Lebedev// __attribute__((warn_unused_result)), because GCC does not silence them via 859c65d39a4SRoman Lebedev// (void) cast. 860928cad59SLouis Dionne# define _LIBCPP_NODISCARD 861c65d39a4SRoman Lebedev# endif 862c65d39a4SRoman Lebedev 863c65d39a4SRoman Lebedev// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not 864c65d39a4SRoman Lebedev// specified as such as an extension. 865c65d39a4SRoman Lebedev# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 866928cad59SLouis Dionne# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD 867c65d39a4SRoman Lebedev# else 868c65d39a4SRoman Lebedev# define _LIBCPP_NODISCARD_EXT 869c65d39a4SRoman Lebedev# endif 870c65d39a4SRoman Lebedev 871ac251726SNikolas Klauser# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) 872928cad59SLouis Dionne# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD 8731644c12eSMarshall Clow# else 8741644c12eSMarshall Clow# define _LIBCPP_NODISCARD_AFTER_CXX17 8751644c12eSMarshall Clow# endif 8761644c12eSMarshall Clow 87781875a67SLouis Dionne# if __has_attribute(no_destroy) 87881875a67SLouis Dionne# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) 87981875a67SLouis Dionne# else 88081875a67SLouis Dionne# define _LIBCPP_NO_DESTROY 88181875a67SLouis Dionne# endif 88281875a67SLouis Dionne 8835c520bd9SMarshall Clow# ifndef _LIBCPP_HAS_NO_ASAN 884971e9c80SNikolas Klauser extern "C" _LIBCPP_FUNC_VIS void 885971e9c80SNikolas Klauser __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); 8865c520bd9SMarshall Clow# endif 8875c520bd9SMarshall Clow 888f7a8c4f3SHoward Hinnant// Try to find out if RTTI is disabled. 889929d5de2SNikolas Klauser# if !defined(__cpp_rtti) || __cpp_rtti < 199711L 890f7a8c4f3SHoward Hinnant# define _LIBCPP_NO_RTTI 891f7a8c4f3SHoward Hinnant# endif 892f7a8c4f3SHoward Hinnant 893a942f2ffSHoward Hinnant# ifndef _LIBCPP_WEAK 894a942f2ffSHoward Hinnant# define _LIBCPP_WEAK __attribute__((__weak__)) 895a942f2ffSHoward Hinnant# endif 896a942f2ffSHoward Hinnant 897c7e4239fSAsiri Rathnayake// Thread API 898ac251726SNikolas Klauser// clang-format off 89972cffa55SEric Fiselier# if !defined(_LIBCPP_HAS_NO_THREADS) && \ 90068050fd6SAsiri Rathnayake !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ 901a1bc823aSEric Fiselier !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ 90268050fd6SAsiri Rathnayake !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 903ac251726SNikolas Klauser 904c7e4239fSAsiri Rathnayake# if defined(__FreeBSD__) || \ 9053efd6e37SDan Gohman defined(__wasi__) || \ 906c7e4239fSAsiri Rathnayake defined(__NetBSD__) || \ 90779f99ba6SBrad Smith defined(__OpenBSD__) || \ 908f0785c1fSXiang Xiao defined(__NuttX__) || \ 909c7e4239fSAsiri Rathnayake defined(__linux__) || \ 910c2b375adSLouis Dionne defined(__GNU__) || \ 911c7e4239fSAsiri Rathnayake defined(__APPLE__) || \ 912e9ee5179SEric Fiselier defined(__sun__) || \ 913e6c89a49SZbigniew Sarbinowski defined(__MVS__) || \ 914b86771a2SSam Clegg defined(_AIX) || \ 915b86771a2SSam Clegg defined(__EMSCRIPTEN__) 916ac251726SNikolas Klauser// clang-format on 917b9599b1bSBen Craig# define _LIBCPP_HAS_THREAD_API_PTHREAD 918ab9aefeeSPetr Hosek# elif defined(__Fuchsia__) 9199050d0fbSPetr Hosek// TODO(44575): Switch to C11 thread API when possible. 9209050d0fbSPetr Hosek# define _LIBCPP_HAS_THREAD_API_PTHREAD 9216d7d0becSSaleem Abdulrasool# elif defined(_LIBCPP_WIN32API) 9226d7d0becSSaleem Abdulrasool# define _LIBCPP_HAS_THREAD_API_WIN32 923c7e4239fSAsiri Rathnayake# else 924c7e4239fSAsiri Rathnayake# error "No thread API" 925b9599b1bSBen Craig# endif // _LIBCPP_HAS_THREAD_API 926c7e4239fSAsiri Rathnayake# endif // _LIBCPP_HAS_NO_THREADS 927c7e4239fSAsiri Rathnayake 92885e26f56SDan Albert# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 92985e26f56SDan Albert# if defined(__ANDROID__) && __ANDROID_API__ >= 30 93085e26f56SDan Albert# define _LIBCPP_HAS_COND_CLOCKWAIT 93185e26f56SDan Albert# elif defined(_LIBCPP_GLIBC_PREREQ) 93285e26f56SDan Albert# if _LIBCPP_GLIBC_PREREQ(2, 30) 93385e26f56SDan Albert# define _LIBCPP_HAS_COND_CLOCKWAIT 93485e26f56SDan Albert# endif 93585e26f56SDan Albert# endif 93685e26f56SDan Albert# endif 93785e26f56SDan Albert 938b9599b1bSBen Craig# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 939b9599b1bSBen Craig# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ 940b9599b1bSBen Craig _LIBCPP_HAS_NO_THREADS is not defined. 941b9599b1bSBen Craig# endif 942c7e4239fSAsiri Rathnayake 9438c2bf45dSAsiri Rathnayake# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 94401eb4780SAsiri Rathnayake# error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ 9458c2bf45dSAsiri Rathnayake _LIBCPP_HAS_NO_THREADS is defined. 9468c2bf45dSAsiri Rathnayake# endif 9478c2bf45dSAsiri Rathnayake 9482050bedfSEric Fiselier# if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) 9492050bedfSEric Fiselier# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ 9502050bedfSEric Fiselier _LIBCPP_HAS_NO_THREADS is defined. 9512050bedfSEric Fiselier# endif 9522050bedfSEric Fiselier 9539aae539dSNico Weber# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) 9549aae539dSNico Weber# define __STDCPP_THREADS__ 1 9559aae539dSNico Weber# endif 9569aae539dSNico Weber 957568bb7eeSLouis Dionne// The glibc and Bionic implementation of pthreads implements 9588cedf04aSEric Fiselier// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 9598cedf04aSEric Fiselier// mutexes have no destroy mechanism. 960568bb7eeSLouis Dionne// 961568bb7eeSLouis Dionne// This optimization can't be performed on Apple platforms, where 962568bb7eeSLouis Dionne// pthread_mutex_destroy can allow the kernel to release resources. 963568bb7eeSLouis Dionne// See https://llvm.org/D64298 for details. 964568bb7eeSLouis Dionne// 965568bb7eeSLouis Dionne// TODO(EricWF): Enable this optimization on Bionic after speaking to their 966568bb7eeSLouis Dionne// respective stakeholders. 967ac251726SNikolas Klauser// clang-format off 968ac251726SNikolas Klauser# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \ 969ac251726SNikolas Klauser (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ 970ac251726SNikolas Klauser defined(_LIBCPP_HAS_THREAD_API_WIN32) 971ac251726SNikolas Klauser// clang-format on 9728baf8383SEric Fiselier# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 9738baf8383SEric Fiselier# endif 9748baf8383SEric Fiselier 9758cedf04aSEric Fiselier// Destroying a condvar is a nop on Windows. 976568bb7eeSLouis Dionne// 977568bb7eeSLouis Dionne// This optimization can't be performed on Apple platforms, where 978568bb7eeSLouis Dionne// pthread_cond_destroy can allow the kernel to release resources. 979568bb7eeSLouis Dionne// See https://llvm.org/D64298 for details. 980568bb7eeSLouis Dionne// 9818cedf04aSEric Fiselier// TODO(EricWF): This is potentially true for some pthread implementations 9828cedf04aSEric Fiselier// as well. 983ac251726SNikolas Klauser# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) 9848cedf04aSEric Fiselier# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 9858cedf04aSEric Fiselier# endif 9868cedf04aSEric Fiselier 9875bd4a480SDimitry Andric// Some systems do not provide gets() in their C library, for security reasons. 988ac251726SNikolas Klauser# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__) 9895bd4a480SDimitry Andric# define _LIBCPP_C_HAS_NO_GETS 9905bd4a480SDimitry Andric# endif 9915bd4a480SDimitry Andric 992ac251726SNikolas Klauser# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ 993a1da7396SMuiez Ahmed defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) 994900086deSDan Albert# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 995900086deSDan Albert# endif 996900086deSDan Albert 9971e33f12aSEric Fiselier# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) 998749adebaSEric Fiselier# define _LIBCPP_HAS_C_ATOMIC_IMP 999ae62727aSRichard Smith# elif defined(_LIBCPP_COMPILER_GCC) 1000749adebaSEric Fiselier# define _LIBCPP_HAS_GCC_ATOMIC_IMP 1001749adebaSEric Fiselier# endif 1002749adebaSEric Fiselier 1003ac251726SNikolas Klauser# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ 100492832e48SLouis Dionne !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) 1005749adebaSEric Fiselier# define _LIBCPP_HAS_NO_ATOMIC_HEADER 10066de760acSDavide Italiano# else 10076de760acSDavide Italiano# ifndef _LIBCPP_ATOMIC_FLAG_TYPE 10086de760acSDavide Italiano# define _LIBCPP_ATOMIC_FLAG_TYPE bool 10096de760acSDavide Italiano# endif 10106de760acSDavide Italiano# ifdef _LIBCPP_FREESTANDING 10116de760acSDavide Italiano# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS 10126de760acSDavide Italiano# endif 1013749adebaSEric Fiselier# endif 1014749adebaSEric Fiselier 1015ec880422SMarshall Clow# ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1016ec880422SMarshall Clow# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1017ec880422SMarshall Clow# endif 1018ec880422SMarshall Clow 10193444e9faSSaleem Abdulrasool# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) 10203444e9faSSaleem Abdulrasool# if defined(__clang__) && __has_attribute(acquire_capability) 10213444e9faSSaleem Abdulrasool// Work around the attribute handling in clang. When both __declspec and 10223444e9faSSaleem Abdulrasool// __attribute__ are present, the processing goes awry preventing the definition 1023de5d38efSMartin Storsjö// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus 1024de5d38efSMartin Storsjö// combining the two does work. 1025de5d38efSMartin Storsjö# if !defined(_MSC_VER) 10267865b2e9SEric Fiselier# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 10277865b2e9SEric Fiselier# endif 10283444e9faSSaleem Abdulrasool# endif 10293444e9faSSaleem Abdulrasool# endif 10307865b2e9SEric Fiselier 1031fda3825cSEric Fiselier# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1032fda3825cSEric Fiselier# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) 1033fda3825cSEric Fiselier# else 1034fda3825cSEric Fiselier# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) 1035fda3825cSEric Fiselier# endif 1036fda3825cSEric Fiselier 103705337a75SArthur O'Dwyer# if _LIBCPP_STD_VER > 17 103805337a75SArthur O'Dwyer# define _LIBCPP_CONSTINIT constinit 103905337a75SArthur O'Dwyer# elif __has_attribute(require_constant_initialization) 104005337a75SArthur O'Dwyer# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__)) 10414efaa309SEric Fiselier# else 104205337a75SArthur O'Dwyer# define _LIBCPP_CONSTINIT 10434efaa309SEric Fiselier# endif 10444efaa309SEric Fiselier 1045b1e7a12eSEric Fiselier# if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) 1046ac251726SNikolas Klauser# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning"))) 1047ac251726SNikolas Klauser# define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error"))) 1048b1e7a12eSEric Fiselier# else 1049b1e7a12eSEric Fiselier# define _LIBCPP_DIAGNOSE_WARNING(...) 1050b1e7a12eSEric Fiselier# define _LIBCPP_DIAGNOSE_ERROR(...) 1051b1e7a12eSEric Fiselier# endif 1052b1e7a12eSEric Fiselier 1053807790a0SEric Fiselier// Use a function like macro to imply that it must be followed by a semicolon 1054929d5de2SNikolas Klauser# if __has_cpp_attribute(fallthrough) 105560cce5c7SReid Kleckner# define _LIBCPP_FALLTHROUGH() [[fallthrough]] 1056a4cb5aefSLouis Dionne# elif __has_attribute(__fallthrough__) 1057807790a0SEric Fiselier# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) 1058807790a0SEric Fiselier# else 1059807790a0SEric Fiselier# define _LIBCPP_FALLTHROUGH() ((void)0) 1060807790a0SEric Fiselier# endif 1061807790a0SEric Fiselier 106214d48692SEric Fiselier# if __has_attribute(__nodebug__) 106314d48692SEric Fiselier# define _LIBCPP_NODEBUG __attribute__((__nodebug__)) 1064d63dd874SEric Fiselier# else 1065d63dd874SEric Fiselier# define _LIBCPP_NODEBUG 1066d63dd874SEric Fiselier# endif 1067d63dd874SEric Fiselier 10687c2f5827SAmy Huang# if __has_attribute(__standalone_debug__) 10697c2f5827SAmy Huang# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) 10707c2f5827SAmy Huang# else 10717c2f5827SAmy Huang# define _LIBCPP_STANDALONE_DEBUG 10727c2f5827SAmy Huang# endif 10737c2f5827SAmy Huang 10742a2c228cSRichard Smith# if __has_attribute(__preferred_name__) 10752a2c228cSRichard Smith# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) 10762a2c228cSRichard Smith# else 10772a2c228cSRichard Smith# define _LIBCPP_PREFERRED_NAME(x) 10782a2c228cSRichard Smith# endif 10792a2c228cSRichard Smith 1080f4c1258dSLouis Dionne// We often repeat things just for handling wide characters in the library. 1081f4c1258dSLouis Dionne// When wide characters are disabled, it can be useful to have a quick way of 1082f4c1258dSLouis Dionne// disabling it without having to resort to #if-#endif, which has a larger 1083f4c1258dSLouis Dionne// impact on readability. 1084f4c1258dSLouis Dionne# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) 1085f4c1258dSLouis Dionne# define _LIBCPP_IF_WIDE_CHARACTERS(...) 1086f4c1258dSLouis Dionne# else 1087f4c1258dSLouis Dionne# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ 1088f4c1258dSLouis Dionne# endif 1089f4c1258dSLouis Dionne 1090ac251726SNikolas Klauser# if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) 1091b43f17c8SEric Fiselier# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) 1092b43f17c8SEric Fiselier# else 1093b43f17c8SEric Fiselier# define _LIBCPP_DECLSPEC_EMPTY_BASES 1094b43f17c8SEric Fiselier# endif 1095b43f17c8SEric Fiselier 10962a1bfa98SEric Fiselier# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) 109707e93d3bSEric Fiselier# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR 10987d210c78SMarshall Clow# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS 1099d42d9e10SArthur O'Dwyer# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE 1100d42d9e10SArthur O'Dwyer# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS 1101681cde7dSNikolas Klauser# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION 11022a1bfa98SEric Fiselier# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 11032a1bfa98SEric Fiselier 11048d802f78SLouis Dionne// Leave the deprecation notices in by default, but don't remove unary_function and 11058d802f78SLouis Dionne// binary_function entirely just yet. That way, folks will have one release to act 11068d802f78SLouis Dionne// on the deprecation warnings. 11078d802f78SLouis Dionne# ifndef _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION 11088d802f78SLouis Dionne# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION 11098d802f78SLouis Dionne# endif 11108d802f78SLouis Dionne 1111d42d9e10SArthur O'Dwyer# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) 1112d42d9e10SArthur O'Dwyer# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS 1113374f938fSIlya Biryukov# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION 1114dc066888SArthur O'Dwyer# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS 1115d42d9e10SArthur O'Dwyer# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS 1116d42d9e10SArthur O'Dwyer# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR 11172ff5a56eSwmbat# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS 1118d42d9e10SArthur O'Dwyer# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES 1119d42d9e10SArthur O'Dwyer 11202e6ae1d3SChuanqi Xu# if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L 11212e6ae1d3SChuanqi Xu# define _LIBCPP_HAS_NO_CXX20_COROUTINES 1122eb04c8caSEric Fiselier# endif 1123eb04c8caSEric Fiselier 112457039058SNikolas Klauser# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") 112557039058SNikolas Klauser# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") 1126a016efb1SEric Fiselier 1127fcac3c96SPeter Collingbourne# ifndef _LIBCPP_NO_AUTO_LINK 112874f41817SSaleem Abdulrasool# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 11296c5b0d6bSMartin Storsjö# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 1130ae20590cSSaleem Abdulrasool# pragma comment(lib, "c++.lib") 113174f41817SSaleem Abdulrasool# else 1132ae20590cSSaleem Abdulrasool# pragma comment(lib, "libc++.lib") 113374f41817SSaleem Abdulrasool# endif 113474f41817SSaleem Abdulrasool# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1135fcac3c96SPeter Collingbourne# endif // _LIBCPP_NO_AUTO_LINK 113656312f5aSEric Fiselier 1137a7e90599SDan Albert// Configures the fopen close-on-exec mode character, if any. This string will 1138a7e90599SDan Albert// be appended to any mode string used by fstream for fopen/fdopen. 1139a7e90599SDan Albert// 1140a7e90599SDan Albert// Not all platforms support this, but it helps avoid fd-leaks on platforms that 1141a7e90599SDan Albert// do. 1142a7e90599SDan Albert# if defined(__BIONIC__) 1143a7e90599SDan Albert# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" 1144a7e90599SDan Albert# else 1145a7e90599SDan Albert# define _LIBCPP_FOPEN_CLOEXEC_MODE 1146a7e90599SDan Albert# endif 1147a7e90599SDan Albert 114875c44086SDan Albert// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set 114975c44086SDan Albert// of functions used in cstdio may not be available for low API levels when 115075c44086SDan Albert// using 64-bit file offsets on LP32. 115175c44086SDan Albert# if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 115275c44086SDan Albert# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS 115375c44086SDan Albert# endif 115475c44086SDan Albert 11552c7e24c4SZbigniew Sarbinowski# if __has_attribute(init_priority) 11567c49052bSLouis Dionne// TODO: Remove this once we drop support for building libc++ with old Clangs 11577c49052bSLouis Dionne# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ 11587c49052bSLouis Dionne (defined(__apple_build_version__) && __apple_build_version__ < 13000000) 11592c7e24c4SZbigniew Sarbinowski# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) 11602c7e24c4SZbigniew Sarbinowski# else 11617c49052bSLouis Dionne# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) 11627c49052bSLouis Dionne# endif 11637c49052bSLouis Dionne# else 11642c7e24c4SZbigniew Sarbinowski# define _LIBCPP_INIT_PRIORITY_MAX 11652c7e24c4SZbigniew Sarbinowski# endif 11662c7e24c4SZbigniew Sarbinowski 11670aa637b2SArthur O'Dwyer# if defined(__GNUC__) || defined(__clang__) 11687dc9a03cSLouis Dionne// The attribute uses 1-based indices for ordinary and static member functions. 11697dc9a03cSLouis Dionne// The attribute uses 2-based indices for non-static member functions. 11707dc9a03cSLouis Dionne# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ 11717dc9a03cSLouis Dionne __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) 11720aa637b2SArthur O'Dwyer# else 11737dc9a03cSLouis Dionne# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ 11740aa637b2SArthur O'Dwyer# endif 11750aa637b2SArthur O'Dwyer 11768a0a706fSMartin Storsjö# if __has_cpp_attribute(msvc::no_unique_address) 11778a0a706fSMartin Storsjö// MSVC implements [[no_unique_address]] as a silent no-op currently. 11788a0a706fSMartin Storsjö// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) 11798a0a706fSMartin Storsjö// However, MSVC implements [[msvc::no_unique_address]] which does what 11808a0a706fSMartin Storsjö// [[no_unique_address]] is supposed to do, in general. 11818a0a706fSMartin Storsjö 11828a0a706fSMartin Storsjö// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or 11838a0a706fSMartin Storsjö// [[msvc::no_unique_address]] though. If/when it does implement 11848a0a706fSMartin Storsjö// [[msvc::no_unique_address]], this should be preferred though. 11858a0a706fSMartin Storsjö# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] 11868a0a706fSMartin Storsjö# elif __has_cpp_attribute(no_unique_address) 11878a0a706fSMartin Storsjö# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]] 11888a0a706fSMartin Storsjö# else 11898a0a706fSMartin Storsjö# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ 11908a0a706fSMartin Storsjö// Note that this can be replaced by #error as soon as clang-cl 11918a0a706fSMartin Storsjö// implements msvc::no_unique_address, since there should be no C++20 11928a0a706fSMartin Storsjö// compiler that doesn't support one of the two attributes at that point. 11935185f4a0SArthur O'Dwyer// We generally don't want to use this macro outside of C++20-only code, 11948a0a706fSMartin Storsjö// because using it conditionally in one language version only would make 11958a0a706fSMartin Storsjö// the ABI inconsistent. 11968a0a706fSMartin Storsjö# endif 11978a0a706fSMartin Storsjö 1198a7c2a628SNikolas Klauser# ifdef _LIBCPP_COMPILER_CLANG_BASED 1199a7c2a628SNikolas Klauser# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") 1200a7c2a628SNikolas Klauser# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") 1201a7c2a628SNikolas Klauser# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) 1202a7c2a628SNikolas Klauser# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1203a7c2a628SNikolas Klauser# elif defined(_LIBCPP_COMPILER_GCC) 1204a7c2a628SNikolas Klauser# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") 1205a7c2a628SNikolas Klauser# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") 1206a7c2a628SNikolas Klauser# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1207a7c2a628SNikolas Klauser# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) 1208a7c2a628SNikolas Klauser# else 1209a7c2a628SNikolas Klauser# define _LIBCPP_DIAGNOSTIC_PUSH 1210a7c2a628SNikolas Klauser# define _LIBCPP_DIAGNOSTIC_POP 1211a7c2a628SNikolas Klauser# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1212a7c2a628SNikolas Klauser# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1213a7c2a628SNikolas Klauser# endif 1214a7c2a628SNikolas Klauser 121596918f2aSStefan Pintilie# if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC) 121696918f2aSStefan Pintilie# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)") 121796918f2aSStefan Pintilie# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)") 121896918f2aSStefan Pintilie# else 121996918f2aSStefan Pintilie# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */ 122096918f2aSStefan Pintilie# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ 122196918f2aSStefan Pintilie# endif 122296918f2aSStefan Pintilie 122360f7bdfdSXing Xue# if __has_attribute(__packed__) 122460f7bdfdSXing Xue# define _LIBCPP_PACKED __attribute__((__packed__)) 122560f7bdfdSXing Xue# else 122660f7bdfdSXing Xue# define _LIBCPP_PACKED 122760f7bdfdSXing Xue# endif 122860f7bdfdSXing Xue 122956312f5aSEric Fiselier#endif // __cplusplus 123056312f5aSEric Fiselier 1231cc82a1b0SLouis Dionne#endif // _LIBCPP___CONFIG 1232