Warning, /include/c++/v1/__cxx03/__config is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP___CXX03___CONFIG
0011 #define _LIBCPP___CXX03___CONFIG
0012
0013 #include <__cxx03/__configuration/abi.h>
0014 #include <__cxx03/__configuration/availability.h>
0015 #include <__cxx03/__configuration/compiler.h>
0016 #include <__cxx03/__configuration/config_site_shim.h>
0017 #include <__cxx03/__configuration/platform.h>
0018
0019 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
0020 # pragma GCC system_header
0021 #endif
0022
0023 #ifdef __cplusplus
0024
0025 // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
0026
0027 // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
0028 // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
0029 // defined to XXYYZZ.
0030 # define _LIBCPP_VERSION 190100
0031
0032 # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
0033 # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
0034
0035 # if __STDC_HOSTED__ == 0
0036 # define _LIBCPP_FREESTANDING
0037 # endif
0038
0039 // HARDENING {
0040
0041 // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
0042 // equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20.
0043 # ifdef _LIBCPP_ENABLE_ASSERTIONS
0044 # warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
0045 # if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
0046 # error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
0047 # endif
0048 # if _LIBCPP_ENABLE_ASSERTIONS
0049 # define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_EXTENSIVE
0050 # endif
0051 # endif
0052
0053 // The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:
0054 //
0055 // - `_LIBCPP_HARDENING_MODE_NONE`;
0056 // - `_LIBCPP_HARDENING_MODE_FAST`;
0057 // - `_LIBCPP_HARDENING_MODE_EXTENSIVE`;
0058 // - `_LIBCPP_HARDENING_MODE_DEBUG`.
0059 //
0060 // These values have the following effects:
0061 //
0062 // - `_LIBCPP_HARDENING_MODE_NONE` -- sets the hardening mode to "none" which disables all runtime hardening checks;
0063 //
0064 // - `_LIBCPP_HARDENING_MODE_FAST` -- sets that hardening mode to "fast". The fast mode enables security-critical checks
0065 // that can be done with relatively little runtime overhead in constant time;
0066 //
0067 // - `_LIBCPP_HARDENING_MODE_EXTENSIVE` -- sets the hardening mode to "extensive". The extensive mode is a superset of
0068 // the fast mode that additionally enables checks that are relatively cheap and prevent common types of logic errors
0069 // but are not necessarily security-critical;
0070 //
0071 // - `_LIBCPP_HARDENING_MODE_DEBUG` -- sets the hardening mode to "debug". The debug mode is a superset of the extensive
0072 // mode and enables all checks available in the library, including internal assertions. Checks that are part of the
0073 // debug mode can be very expensive and thus the debug mode is intended to be used for testing, not in production.
0074
0075 // Inside the library, assertions are categorized so they can be cherry-picked based on the chosen hardening mode. These
0076 // macros are only for internal use -- users should only pick one of the high-level hardening modes described above.
0077 //
0078 // - `_LIBCPP_ASSERT_VALID_INPUT_RANGE` -- checks that ranges (whether expressed as an iterator pair, an iterator and
0079 // a sentinel, an iterator and a count, or a `std::range`) given as input to library functions are valid:
0080 // - the sentinel is reachable from the begin iterator;
0081 // - TODO(hardening): both iterators refer to the same container.
0082 //
0083 // - `_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS` -- checks that any attempts to access a container element, whether through
0084 // the container object or through an iterator, are valid and do not attempt to go out of bounds or otherwise access
0085 // a non-existent element. For iterator checks to work, bounded iterators must be enabled in the ABI. Types like
0086 // `optional` and `function` are considered one-element containers for the purposes of this check.
0087 //
0088 // - `_LIBCPP_ASSERT_NON_NULL` -- checks that the pointer being dereferenced is not null. On most modern platforms zero
0089 // address does not refer to an actual location in memory, so a null pointer dereference would not compromize the
0090 // memory security of a program (however, it is still undefined behavior that can result in strange errors due to
0091 // compiler optimizations).
0092 //
0093 // - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the
0094 // given ranges do not overlap.
0095 //
0096 // - `_LIBCPP_ASSERT_VALID_DEALLOCATION` -- checks that an attempt to deallocate memory is valid (e.g. the given object
0097 // was allocated by the given allocator). Violating this category typically results in a memory leak.
0098 //
0099 // - `_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL` -- checks that a call to an external API doesn't fail in
0100 // an unexpected manner. This includes triggering documented cases of undefined behavior in an external library (like
0101 // attempting to unlock an unlocked mutex in pthreads). Any API external to the library falls under this category
0102 // (from system calls to compiler intrinsics). We generally don't expect these failures to compromize memory safety or
0103 // otherwise create an immediate security issue.
0104 //
0105 // - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure
0106 // the containers have compatible allocators.
0107 //
0108 // - `_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN` -- checks that the given argument is within the domain of valid arguments
0109 // for the function. Violating this typically produces an incorrect result (e.g. the clamp algorithm returns the
0110 // original value without clamping it due to incorrect functors) or puts an object into an invalid state (e.g.
0111 // a string view where only a subset of elements is possible to access). This category is for assertions violating
0112 // which doesn't cause any immediate issues in the library -- whatever the consequences are, they will happen in the
0113 // user code.
0114 //
0115 // - `_LIBCPP_ASSERT_PEDANTIC` -- checks prerequisites which are imposed by the Standard, but violating which happens to
0116 // be benign in our implementation.
0117 //
0118 // - `_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT` -- checks that the given argument satisfies the semantic requirements imposed
0119 // by the Standard. Typically, there is no simple way to completely prove that a semantic requirement is satisfied;
0120 // thus, this would often be a heuristic check and it might be quite expensive.
0121 //
0122 // - `_LIBCPP_ASSERT_INTERNAL` -- checks that internal invariants of the library hold. These assertions don't depend on
0123 // user input.
0124 //
0125 // - `_LIBCPP_ASSERT_UNCATEGORIZED` -- for assertions that haven't been properly classified yet.
0126
0127 // clang-format off
0128 # define _LIBCPP_HARDENING_MODE_NONE (1 << 1)
0129 # define _LIBCPP_HARDENING_MODE_FAST (1 << 2)
0130 # define _LIBCPP_HARDENING_MODE_EXTENSIVE (1 << 4) // Deliberately not ordered.
0131 # define _LIBCPP_HARDENING_MODE_DEBUG (1 << 3)
0132 // clang-format on
0133
0134 # ifndef _LIBCPP_HARDENING_MODE
0135
0136 # ifndef _LIBCPP_HARDENING_MODE_DEFAULT
0137 # error _LIBCPP_HARDENING_MODE_DEFAULT is not defined. This definition should be set at configuration time in the \
0138 `__config_site` header, please make sure your installation of libc++ is not broken.
0139 # endif
0140
0141 # define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT
0142 # endif
0143
0144 # if _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_NONE && \
0145 _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_FAST && \
0146 _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_EXTENSIVE && \
0147 _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_DEBUG
0148 # error _LIBCPP_HARDENING_MODE must be set to one of the following values: \
0149 _LIBCPP_HARDENING_MODE_NONE, \
0150 _LIBCPP_HARDENING_MODE_FAST, \
0151 _LIBCPP_HARDENING_MODE_EXTENSIVE, \
0152 _LIBCPP_HARDENING_MODE_DEBUG
0153 # endif
0154
0155 // } HARDENING
0156
0157 # define _LIBCPP_TOSTRING2(x) #x
0158 # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
0159
0160 // NOLINTNEXTLINE(libcpp-cpp-version-check)
0161 # if __cplusplus < 201103L
0162 # define _LIBCPP_CXX03_LANG
0163 # endif
0164
0165 # ifndef __has_constexpr_builtin
0166 # define __has_constexpr_builtin(x) 0
0167 # endif
0168
0169 // This checks wheter a Clang module is built
0170 # ifndef __building_module
0171 # define __building_module(...) 0
0172 # endif
0173
0174 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
0175 // the compiler and '1' otherwise.
0176 # ifndef __is_identifier
0177 # define __is_identifier(__x) 1
0178 # endif
0179
0180 # ifndef __has_declspec_attribute
0181 # define __has_declspec_attribute(__x) 0
0182 # endif
0183
0184 # define __has_keyword(__x) !(__is_identifier(__x))
0185
0186 # ifndef __has_warning
0187 # define __has_warning(...) 0
0188 # endif
0189
0190 # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
0191 # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
0192 # endif
0193
0194 // FIXME: ABI detection should be done via compiler builtin macros. This
0195 // is just a placeholder until Clang implements such macros. For now assume
0196 // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
0197 // and allow the user to explicitly specify the ABI to handle cases where this
0198 // heuristic falls short.
0199 # if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
0200 # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
0201 # elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
0202 # define _LIBCPP_ABI_ITANIUM
0203 # elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
0204 # define _LIBCPP_ABI_MICROSOFT
0205 # else
0206 # if defined(_WIN32) && defined(_MSC_VER)
0207 # define _LIBCPP_ABI_MICROSOFT
0208 # else
0209 # define _LIBCPP_ABI_ITANIUM
0210 # endif
0211 # endif
0212
0213 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
0214 # define _LIBCPP_ABI_VCRUNTIME
0215 # endif
0216
0217 # if __has_feature(experimental_library)
0218 # ifndef _LIBCPP_ENABLE_EXPERIMENTAL
0219 # define _LIBCPP_ENABLE_EXPERIMENTAL
0220 # endif
0221 # endif
0222
0223 // Incomplete features get their own specific disabling flags. This makes it
0224 // easier to grep for target specific flags once the feature is complete.
0225 # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
0226 # define _LIBCPP_HAS_NO_INCOMPLETE_PSTL
0227 # define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN
0228 # define _LIBCPP_HAS_NO_EXPERIMENTAL_TZDB
0229 # define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
0230 # endif
0231
0232 # if defined(__MVS__)
0233 # include <features.h> // for __NATIVE_ASCII_F
0234 # endif
0235
0236 # if defined(_WIN32)
0237 # define _LIBCPP_WIN32API
0238 # define _LIBCPP_SHORT_WCHAR 1
0239 // Both MinGW and native MSVC provide a "MSVC"-like environment
0240 # define _LIBCPP_MSVCRT_LIKE
0241 // If mingw not explicitly detected, assume using MS C runtime only if
0242 // a MS compatibility version is specified.
0243 # if defined(_MSC_VER) && !defined(__MINGW32__)
0244 # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
0245 # endif
0246 # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
0247 # define _LIBCPP_HAS_BITSCAN64
0248 # endif
0249 # define _LIBCPP_HAS_OPEN_WITH_WCHAR
0250 # endif // defined(_WIN32)
0251
0252 # if defined(_AIX) && !defined(__64BIT__)
0253 // The size of wchar is 2 byte on 32-bit mode on AIX.
0254 # define _LIBCPP_SHORT_WCHAR 1
0255 # endif
0256
0257 // Libc++ supports various implementations of std::random_device.
0258 //
0259 // _LIBCPP_USING_DEV_RANDOM
0260 // Read entropy from the given file, by default `/dev/urandom`.
0261 // If a token is provided, it is assumed to be the path to a file
0262 // to read entropy from. This is the default behavior if nothing
0263 // else is specified. This implementation requires storing state
0264 // inside `std::random_device`.
0265 //
0266 // _LIBCPP_USING_ARC4_RANDOM
0267 // Use arc4random(). This allows obtaining random data even when
0268 // using sandboxing mechanisms. On some platforms like Apple, this
0269 // is the recommended source of entropy for user-space programs.
0270 // When this option is used, the token passed to `std::random_device`'s
0271 // constructor *must* be "/dev/urandom" -- anything else is an error.
0272 //
0273 // _LIBCPP_USING_GETENTROPY
0274 // Use getentropy().
0275 // When this option is used, the token passed to `std::random_device`'s
0276 // constructor *must* be "/dev/urandom" -- anything else is an error.
0277 //
0278 // _LIBCPP_USING_FUCHSIA_CPRNG
0279 // Use Fuchsia's zx_cprng_draw() system call, which is specified to
0280 // deliver high-quality entropy and cannot fail.
0281 // When this option is used, the token passed to `std::random_device`'s
0282 // constructor *must* be "/dev/urandom" -- anything else is an error.
0283 //
0284 // _LIBCPP_USING_NACL_RANDOM
0285 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
0286 // including accesses to the special files under `/dev`. This implementation
0287 // uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
0288 // When this option is used, the token passed to `std::random_device`'s
0289 // constructor *must* be "/dev/urandom" -- anything else is an error.
0290 //
0291 // _LIBCPP_USING_WIN32_RANDOM
0292 // Use rand_s(), for use on Windows.
0293 // When this option is used, the token passed to `std::random_device`'s
0294 // constructor *must* be "/dev/urandom" -- anything else is an error.
0295 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
0296 defined(__DragonFly__)
0297 # define _LIBCPP_USING_ARC4_RANDOM
0298 # elif defined(__wasi__) || defined(__EMSCRIPTEN__)
0299 # define _LIBCPP_USING_GETENTROPY
0300 # elif defined(__Fuchsia__)
0301 # define _LIBCPP_USING_FUCHSIA_CPRNG
0302 # elif defined(__native_client__)
0303 # define _LIBCPP_USING_NACL_RANDOM
0304 # elif defined(_LIBCPP_WIN32API)
0305 # define _LIBCPP_USING_WIN32_RANDOM
0306 # else
0307 # define _LIBCPP_USING_DEV_RANDOM
0308 # endif
0309
0310 # ifndef _LIBCPP_CXX03_LANG
0311
0312 # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
0313 # define _ALIGNAS_TYPE(x) alignas(x)
0314 # define _ALIGNAS(x) alignas(x)
0315 # define _LIBCPP_NORETURN [[noreturn]]
0316 # define _NOEXCEPT noexcept
0317 # define _NOEXCEPT_(...) noexcept(__VA_ARGS__)
0318 # define _LIBCPP_CONSTEXPR constexpr
0319
0320 # else
0321
0322 # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
0323 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
0324 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
0325 # define _LIBCPP_NORETURN __attribute__((__noreturn__))
0326 # define _LIBCPP_HAS_NO_NOEXCEPT
0327 # define nullptr __nullptr
0328 # define _NOEXCEPT throw()
0329 # define _NOEXCEPT_(...)
0330 # define static_assert(...) _Static_assert(__VA_ARGS__)
0331 # define decltype(...) __decltype(__VA_ARGS__)
0332 # define _LIBCPP_CONSTEXPR
0333
0334 typedef __char16_t char16_t;
0335 typedef __char32_t char32_t;
0336
0337 # endif
0338
0339 # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
0340
0341 // Objective-C++ features (opt-in)
0342 # if __has_feature(objc_arc)
0343 # define _LIBCPP_HAS_OBJC_ARC
0344 # endif
0345
0346 # if __has_feature(objc_arc_weak)
0347 # define _LIBCPP_HAS_OBJC_ARC_WEAK
0348 # endif
0349
0350 # if __has_extension(blocks)
0351 # define _LIBCPP_HAS_EXTENSION_BLOCKS
0352 # endif
0353
0354 # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
0355 # define _LIBCPP_HAS_BLOCKS_RUNTIME
0356 # endif
0357
0358 # if !__has_feature(address_sanitizer)
0359 # define _LIBCPP_HAS_NO_ASAN
0360 # endif
0361
0362 # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
0363
0364 # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
0365
0366 # if defined(_LIBCPP_OBJECT_FORMAT_COFF)
0367
0368 # ifdef _DLL
0369 # define _LIBCPP_CRT_FUNC __declspec(dllimport)
0370 # else
0371 # define _LIBCPP_CRT_FUNC
0372 # endif
0373
0374 # if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
0375 # define _LIBCPP_DLL_VIS
0376 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
0377 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
0378 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
0379 # define _LIBCPP_EXPORTED_FROM_ABI
0380 # elif defined(_LIBCPP_BUILDING_LIBRARY)
0381 # define _LIBCPP_DLL_VIS __declspec(dllexport)
0382 # if defined(__MINGW32__)
0383 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
0384 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
0385 # else
0386 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
0387 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
0388 # endif
0389 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
0390 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
0391 # else
0392 # define _LIBCPP_DLL_VIS __declspec(dllimport)
0393 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
0394 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
0395 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
0396 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
0397 # endif
0398
0399 # define _LIBCPP_HIDDEN
0400 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
0401 # define _LIBCPP_TEMPLATE_VIS
0402 # define _LIBCPP_TEMPLATE_DATA_VIS
0403 # define _LIBCPP_TYPE_VISIBILITY_DEFAULT
0404
0405 # else
0406
0407 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
0408 # define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
0409 # else
0410 # define _LIBCPP_VISIBILITY(vis)
0411 # endif
0412
0413 # define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
0414 # define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
0415 # define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
0416 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
0417 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
0418
0419 // TODO: Make this a proper customization point or remove the option to override it.
0420 # ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
0421 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
0422 # endif
0423
0424 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
0425 // The inline should be removed once PR32114 is resolved
0426 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
0427 # else
0428 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
0429 # endif
0430
0431 // GCC doesn't support the type_visibility attribute, so we have to keep the visibility attribute on templates
0432 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !__has_attribute(__type_visibility__)
0433 # define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
0434 # else
0435 # define _LIBCPP_TEMPLATE_VIS
0436 # endif
0437
0438 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
0439 # define _LIBCPP_TYPE_VISIBILITY_DEFAULT __attribute__((__type_visibility__("default")))
0440 # else
0441 # define _LIBCPP_TYPE_VISIBILITY_DEFAULT
0442 # endif
0443
0444 # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
0445
0446 # if __has_attribute(exclude_from_explicit_instantiation)
0447 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
0448 # else
0449 // Try to approximate the effect of exclude_from_explicit_instantiation
0450 // (which is that entities are not assumed to be provided by explicit
0451 // template instantiations in the dylib) by always inlining those entities.
0452 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
0453 # endif
0454
0455 # ifdef _LIBCPP_COMPILER_CLANG_BASED
0456 # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
0457 # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
0458 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
0459 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
0460 # elif defined(_LIBCPP_COMPILER_GCC)
0461 # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
0462 # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
0463 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
0464 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
0465 # else
0466 # define _LIBCPP_DIAGNOSTIC_PUSH
0467 # define _LIBCPP_DIAGNOSTIC_POP
0468 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
0469 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
0470 # endif
0471
0472 # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
0473 # define _LIBCPP_HARDENING_SIG f
0474 # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
0475 # define _LIBCPP_HARDENING_SIG s
0476 # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
0477 # define _LIBCPP_HARDENING_SIG d
0478 # else
0479 # define _LIBCPP_HARDENING_SIG n // "none"
0480 # endif
0481
0482 # ifdef _LIBCPP_HAS_NO_EXCEPTIONS
0483 # define _LIBCPP_EXCEPTIONS_SIG n
0484 # else
0485 # define _LIBCPP_EXCEPTIONS_SIG e
0486 # endif
0487
0488 # define _LIBCPP_ODR_SIGNATURE \
0489 _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION)
0490
0491 // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
0492 // on two levels:
0493 // 1. The symbol is given hidden visibility, which ensures that users won't start exporting
0494 // symbols from their dynamic library by means of using the libc++ headers. This ensures
0495 // that those symbols stay private to the dynamic library in which it is defined.
0496 //
0497 // 2. The symbol is given an ABI tag that encodes the ODR-relevant properties of the library.
0498 // This ensures that no ODR violation can arise from mixing two TUs compiled with different
0499 // versions or configurations of libc++ (such as exceptions vs no-exceptions). Indeed, if the
0500 // program contains two definitions of a function, the ODR requires them to be token-by-token
0501 // equivalent, and the linker is allowed to pick either definition and discard the other one.
0502 //
0503 // For example, if a program contains a copy of `vector::at()` compiled with exceptions enabled
0504 // *and* a copy of `vector::at()` compiled with exceptions disabled (by means of having two TUs
0505 // compiled with different settings), the two definitions are both visible by the linker and they
0506 // have the same name, but they have a meaningfully different implementation (one throws an exception
0507 // and the other aborts the program). This violates the ODR and makes the program ill-formed, and in
0508 // practice what will happen is that the linker will pick one of the definitions at random and will
0509 // discard the other one. This can quite clearly lead to incorrect program behavior.
0510 //
0511 // A similar reasoning holds for many other properties that are ODR-affecting. Essentially any
0512 // property that causes the code of a function to differ from the code in another configuration
0513 // can be considered ODR-affecting. In practice, we don't encode all such properties in the ABI
0514 // tag, but we encode the ones that we think are most important: library version, exceptions, and
0515 // hardening mode.
0516 //
0517 // Note that historically, solving this problem has been achieved in various ways, including
0518 // force-inlining all functions or giving internal linkage to all functions. Both these previous
0519 // solutions suffer from drawbacks that lead notably to code bloat.
0520 //
0521 // Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
0522 // on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
0523 //
0524 // Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
0525 // instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
0526 // name of a virtual function is part of its ABI, since some architectures like arm64e can sign
0527 // the virtual function pointer in the vtable based on the mangled name of the function. Since
0528 // we use an ABI tag that changes with each released version, the mangled name of the virtual
0529 // function would change, which is incorrect. Note that it doesn't make much sense to change
0530 // the implementation of a virtual function in an ABI-incompatible way in the first place,
0531 // since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
0532 //
0533 // The macro can be applied to record and enum types. When the tagged type is nested in
0534 // a record this "parent" record needs to have the macro too. Another use case for applying
0535 // this macro to records and unions is to apply an ABI tag to inline constexpr variables.
0536 // This can be useful for inline variables that are implementation details which are expected
0537 // to change in the future.
0538 //
0539 // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
0540 // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
0541 // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
0542 # ifndef _LIBCPP_NO_ABI_TAG
0543 # define _LIBCPP_HIDE_FROM_ABI \
0544 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
0545 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
0546 # else
0547 # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
0548 # endif
0549 # define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
0550
0551 # ifdef _LIBCPP_BUILDING_LIBRARY
0552 # if _LIBCPP_ABI_VERSION > 1
0553 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
0554 # else
0555 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
0556 # endif
0557 # else
0558 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
0559 # endif
0560
0561 // TODO: Remove this workaround once we drop support for Clang 16
0562 # if __has_warning("-Wc++23-extensions")
0563 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
0564 # else
0565 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions")
0566 # endif
0567
0568 // Clang modules take a significant compile time hit when pushing and popping diagnostics.
0569 // Since all the headers are marked as system headers in the modulemap, we can simply disable this
0570 // pushing and popping when building with clang modules.
0571 # if !__has_feature(modules)
0572 # define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
0573 _LIBCPP_DIAGNOSTIC_PUSH \
0574 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
0575 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
0576 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
0577 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
0578 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \
0579 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
0580 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
0581 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
0582 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
0583 # define _LIBCPP_POP_EXTENSION_DIAGNOSTICS _LIBCPP_DIAGNOSTIC_POP
0584 # else
0585 # define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS
0586 # define _LIBCPP_POP_EXTENSION_DIAGNOSTICS
0587 # endif
0588
0589 // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
0590 // clang-format off
0591 # define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
0592 namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
0593 inline namespace _LIBCPP_ABI_NAMESPACE {
0594 # define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS
0595
0596 #ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
0597 # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem {
0598 # define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD
0599 #else
0600 # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
0601 inline namespace __fs { namespace filesystem {
0602
0603 # define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
0604 #endif
0605
0606 // clang-format on
0607
0608 # if __has_attribute(__enable_if__)
0609 # define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
0610 # endif
0611
0612 # if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
0613 # define _LIBCPP_HAS_NO_INT128
0614 # endif
0615
0616 # ifdef _LIBCPP_CXX03_LANG
0617 # define _LIBCPP_DECLARE_STRONG_ENUM(x) \
0618 struct _LIBCPP_EXPORTED_FROM_ABI x { \
0619 enum __lx
0620 // clang-format off
0621 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
0622 __lx __v_; \
0623 _LIBCPP_HIDE_FROM_ABI x(__lx __v) : __v_(__v) {} \
0624 _LIBCPP_HIDE_FROM_ABI explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
0625 _LIBCPP_HIDE_FROM_ABI operator int() const { return __v_; } \
0626 };
0627 // clang-format on
0628
0629 # else // _LIBCPP_CXX03_LANG
0630 # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class x
0631 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
0632 # endif // _LIBCPP_CXX03_LANG
0633
0634 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
0635 # define _LIBCPP_LOCALE__L_EXTENSIONS 1
0636 # endif
0637
0638 # ifdef __FreeBSD__
0639 # define _DECLARE_C99_LDBL_MATH 1
0640 # endif
0641
0642 // If we are getting operator new from the MSVC CRT, then allocation overloads
0643 // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
0644 # if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
0645 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
0646 # elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
0647 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
0648 // have it unless the language feature test macro is defined.
0649 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
0650 # elif defined(__MVS__)
0651 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
0652 # endif
0653
0654 # if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
0655 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
0656 # endif
0657
0658 // It is not yet possible to use aligned_alloc() on all Apple platforms since
0659 // 10.15 was the first version to ship an implementation of aligned_alloc().
0660 # if defined(__APPLE__)
0661 # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
0662 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500)
0663 # define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
0664 # endif
0665 # elif defined(__ANDROID__) && __ANDROID_API__ < 28
0666 // Android only provides aligned_alloc when targeting API 28 or higher.
0667 # define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
0668 # endif
0669
0670 # if defined(__APPLE__) || defined(__FreeBSD__)
0671 # define _LIBCPP_HAS_DEFAULTRUNELOCALE
0672 # endif
0673
0674 # if defined(__APPLE__) || defined(__FreeBSD__)
0675 # define _LIBCPP_WCTYPE_IS_MASK
0676 # endif
0677
0678 # if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
0679 # define _LIBCPP_HAS_NO_CHAR8_T
0680 # endif
0681
0682 // Deprecation macros.
0683 //
0684 // Deprecations warnings are always enabled, except when users explicitly opt-out
0685 // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
0686 # if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
0687 # if __has_attribute(__deprecated__)
0688 # define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
0689 # define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
0690 # elif _LIBCPP_STD_VER >= 14
0691 # define _LIBCPP_DEPRECATED [[deprecated]]
0692 # define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
0693 # else
0694 # define _LIBCPP_DEPRECATED
0695 # define _LIBCPP_DEPRECATED_(m)
0696 # endif
0697 # else
0698 # define _LIBCPP_DEPRECATED
0699 # define _LIBCPP_DEPRECATED_(m)
0700 # endif
0701
0702 # if _LIBCPP_STD_VER < 20
0703 # define _LIBCPP_DEPRECATED_ATOMIC_SYNC \
0704 _LIBCPP_DEPRECATED_("The C++20 synchronization library has been deprecated prior to C++20. Please update to " \
0705 "using -std=c++20 if you need to use these facilities.")
0706 # else
0707 # define _LIBCPP_DEPRECATED_ATOMIC_SYNC /* nothing */
0708 # endif
0709
0710 # if !defined(_LIBCPP_CXX03_LANG)
0711 # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
0712 # else
0713 # define _LIBCPP_DEPRECATED_IN_CXX11
0714 # endif
0715
0716 # if _LIBCPP_STD_VER >= 14
0717 # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
0718 # else
0719 # define _LIBCPP_DEPRECATED_IN_CXX14
0720 # endif
0721
0722 # if _LIBCPP_STD_VER >= 17
0723 # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
0724 # else
0725 # define _LIBCPP_DEPRECATED_IN_CXX17
0726 # endif
0727
0728 # if _LIBCPP_STD_VER >= 20
0729 # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
0730 # else
0731 # define _LIBCPP_DEPRECATED_IN_CXX20
0732 # endif
0733
0734 # if _LIBCPP_STD_VER >= 23
0735 # define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
0736 # else
0737 # define _LIBCPP_DEPRECATED_IN_CXX23
0738 # endif
0739
0740 # if _LIBCPP_STD_VER >= 26
0741 # define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
0742 # else
0743 # define _LIBCPP_DEPRECATED_IN_CXX26
0744 # endif
0745
0746 # if !defined(_LIBCPP_HAS_NO_CHAR8_T)
0747 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
0748 # else
0749 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T
0750 # endif
0751
0752 // Macros to enter and leave a state where deprecation warnings are suppressed.
0753 # if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
0754 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
0755 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
0756 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
0757 # define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
0758 # else
0759 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
0760 # define _LIBCPP_SUPPRESS_DEPRECATED_POP
0761 # endif
0762
0763 # if _LIBCPP_STD_VER <= 11
0764 # define _LIBCPP_EXPLICIT_SINCE_CXX14
0765 # else
0766 # define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit
0767 # endif
0768
0769 # if _LIBCPP_STD_VER >= 23
0770 # define _LIBCPP_EXPLICIT_SINCE_CXX23 explicit
0771 # else
0772 # define _LIBCPP_EXPLICIT_SINCE_CXX23
0773 # endif
0774
0775 # if _LIBCPP_STD_VER >= 14
0776 # define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
0777 # else
0778 # define _LIBCPP_CONSTEXPR_SINCE_CXX14
0779 # endif
0780
0781 # if _LIBCPP_STD_VER >= 17
0782 # define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
0783 # else
0784 # define _LIBCPP_CONSTEXPR_SINCE_CXX17
0785 # endif
0786
0787 # if _LIBCPP_STD_VER >= 20
0788 # define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
0789 # else
0790 # define _LIBCPP_CONSTEXPR_SINCE_CXX20
0791 # endif
0792
0793 # if _LIBCPP_STD_VER >= 23
0794 # define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
0795 # else
0796 # define _LIBCPP_CONSTEXPR_SINCE_CXX23
0797 # endif
0798
0799 # ifndef _LIBCPP_WEAK
0800 # define _LIBCPP_WEAK __attribute__((__weak__))
0801 # endif
0802
0803 // Thread API
0804 // clang-format off
0805 # if !defined(_LIBCPP_HAS_NO_THREADS) && \
0806 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
0807 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
0808 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
0809
0810 # if defined(__FreeBSD__) || \
0811 defined(__wasi__) || \
0812 defined(__NetBSD__) || \
0813 defined(__OpenBSD__) || \
0814 defined(__NuttX__) || \
0815 defined(__linux__) || \
0816 defined(__GNU__) || \
0817 defined(__APPLE__) || \
0818 defined(__MVS__) || \
0819 defined(_AIX) || \
0820 defined(__EMSCRIPTEN__)
0821 // clang-format on
0822 # define _LIBCPP_HAS_THREAD_API_PTHREAD
0823 # elif defined(__Fuchsia__)
0824 // TODO(44575): Switch to C11 thread API when possible.
0825 # define _LIBCPP_HAS_THREAD_API_PTHREAD
0826 # elif defined(_LIBCPP_WIN32API)
0827 # define _LIBCPP_HAS_THREAD_API_WIN32
0828 # else
0829 # error "No thread API"
0830 # endif // _LIBCPP_HAS_THREAD_API
0831 # endif // _LIBCPP_HAS_NO_THREADS
0832
0833 # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
0834 # if defined(__ANDROID__) && __ANDROID_API__ >= 30
0835 # define _LIBCPP_HAS_COND_CLOCKWAIT
0836 # elif defined(_LIBCPP_GLIBC_PREREQ)
0837 # if _LIBCPP_GLIBC_PREREQ(2, 30)
0838 # define _LIBCPP_HAS_COND_CLOCKWAIT
0839 # endif
0840 # endif
0841 # endif
0842
0843 # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
0844 # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
0845 _LIBCPP_HAS_NO_THREADS is not defined.
0846 # endif
0847
0848 # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
0849 # error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
0850 _LIBCPP_HAS_NO_THREADS is defined.
0851 # endif
0852
0853 # if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
0854 # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
0855 _LIBCPP_HAS_NO_THREADS is defined.
0856 # endif
0857
0858 # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
0859 # define __STDCPP_THREADS__ 1
0860 # endif
0861
0862 // The glibc and Bionic implementation of pthreads implements
0863 // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
0864 // mutexes have no destroy mechanism.
0865 //
0866 // This optimization can't be performed on Apple platforms, where
0867 // pthread_mutex_destroy can allow the kernel to release resources.
0868 // See https://llvm.org/D64298 for details.
0869 //
0870 // TODO(EricWF): Enable this optimization on Bionic after speaking to their
0871 // respective stakeholders.
0872 // clang-format off
0873 # if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \
0874 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
0875 defined(_LIBCPP_HAS_THREAD_API_WIN32)
0876 // clang-format on
0877 # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
0878 # endif
0879
0880 // Destroying a condvar is a nop on Windows.
0881 //
0882 // This optimization can't be performed on Apple platforms, where
0883 // pthread_cond_destroy can allow the kernel to release resources.
0884 // See https://llvm.org/D64298 for details.
0885 //
0886 // TODO(EricWF): This is potentially true for some pthread implementations
0887 // as well.
0888 # if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)
0889 # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
0890 # endif
0891
0892 # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
0893 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
0894 # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
0895 # endif
0896
0897 # if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
0898 # define _LIBCPP_HAS_C_ATOMIC_IMP
0899 # elif defined(_LIBCPP_COMPILER_GCC)
0900 # define _LIBCPP_HAS_GCC_ATOMIC_IMP
0901 # endif
0902
0903 # if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
0904 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
0905 # define _LIBCPP_HAS_NO_ATOMIC_HEADER
0906 # else
0907 # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
0908 # define _LIBCPP_ATOMIC_FLAG_TYPE bool
0909 # endif
0910 # endif
0911
0912 # if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__)
0913 # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((__no_thread_safety_analysis__))
0914 # else
0915 # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
0916 # endif
0917
0918 # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
0919 # if defined(__clang__) && __has_attribute(acquire_capability)
0920 // Work around the attribute handling in clang. When both __declspec and
0921 // __attribute__ are present, the processing goes awry preventing the definition
0922 // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
0923 // combining the two does work.
0924 # if !defined(_MSC_VER)
0925 # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
0926 # endif
0927 # endif
0928 # endif
0929
0930 # ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
0931 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
0932 # else
0933 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
0934 # endif
0935
0936 # if _LIBCPP_STD_VER >= 20
0937 # define _LIBCPP_CONSTINIT constinit
0938 # elif __has_attribute(__require_constant_initialization__)
0939 # define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
0940 # else
0941 # define _LIBCPP_CONSTINIT
0942 # endif
0943
0944 # if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
0945 // The CUDA SDK contains an unfortunate definition for the __noinline__ macro,
0946 // which breaks the regular __attribute__((__noinline__)) syntax. Therefore,
0947 // when compiling for CUDA we use the non-underscored version of the noinline
0948 // attribute.
0949 //
0950 // This is a temporary workaround and we still expect the CUDA SDK team to solve
0951 // this issue properly in the SDK headers.
0952 //
0953 // See https://github.com/llvm/llvm-project/pull/73838 for more details.
0954 # define _LIBCPP_NOINLINE __attribute__((noinline))
0955 # elif __has_attribute(__noinline__)
0956 # define _LIBCPP_NOINLINE __attribute__((__noinline__))
0957 # else
0958 # define _LIBCPP_NOINLINE
0959 # endif
0960
0961 // We often repeat things just for handling wide characters in the library.
0962 // When wide characters are disabled, it can be useful to have a quick way of
0963 // disabling it without having to resort to #if-#endif, which has a larger
0964 // impact on readability.
0965 # if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
0966 # define _LIBCPP_IF_WIDE_CHARACTERS(...)
0967 # else
0968 # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
0969 # endif
0970
0971 // clang-format off
0972 # define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") _Pragma("push_macro(\"refresh\")") _Pragma("push_macro(\"move\")") _Pragma("push_macro(\"erase\")")
0973 # define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") _Pragma("pop_macro(\"refresh\")") _Pragma("pop_macro(\"move\")") _Pragma("pop_macro(\"erase\")")
0974 // clang-format on
0975
0976 # ifndef _LIBCPP_NO_AUTO_LINK
0977 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
0978 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
0979 # pragma comment(lib, "c++.lib")
0980 # else
0981 # pragma comment(lib, "libc++.lib")
0982 # endif
0983 # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
0984 # endif // _LIBCPP_NO_AUTO_LINK
0985
0986 // Configures the fopen close-on-exec mode character, if any. This string will
0987 // be appended to any mode string used by fstream for fopen/fdopen.
0988 //
0989 // Not all platforms support this, but it helps avoid fd-leaks on platforms that
0990 // do.
0991 # if defined(__BIONIC__)
0992 # define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
0993 # else
0994 # define _LIBCPP_FOPEN_CLOEXEC_MODE
0995 # endif
0996
0997 # if __has_cpp_attribute(msvc::no_unique_address)
0998 // MSVC implements [[no_unique_address]] as a silent no-op currently.
0999 // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
1000 // However, MSVC implements [[msvc::no_unique_address]] which does what
1001 // [[no_unique_address]] is supposed to do, in general.
1002
1003 // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
1004 // [[msvc::no_unique_address]] though. If/when it does implement
1005 // [[msvc::no_unique_address]], this should be preferred though.
1006 # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
1007 # elif __has_cpp_attribute(no_unique_address)
1008 # define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
1009 # else
1010 # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
1011 // Note that this can be replaced by #error as soon as clang-cl
1012 // implements msvc::no_unique_address, since there should be no C++20
1013 // compiler that doesn't support one of the two attributes at that point.
1014 // We generally don't want to use this macro outside of C++20-only code,
1015 // because using it conditionally in one language version only would make
1016 // the ABI inconsistent.
1017 # endif
1018
1019 // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
1020 // functions is gradually being added to existing C libraries. The conditions
1021 // below check for known C library versions and conditions under which these
1022 // functions are declared by the C library.
1023 # define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1024 // GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
1025 // __cpp_char8_t is defined or if C2X extensions are enabled. Determining
1026 // the latter depends on internal GNU libc details that are not appropriate
1027 // to depend on here, so any declarations present when __cpp_char8_t is not
1028 // defined are ignored.
1029 # if defined(_LIBCPP_GLIBC_PREREQ)
1030 # if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
1031 # undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1032 # endif
1033 # endif
1034
1035 // There are a handful of public standard library types that are intended to
1036 // support CTAD but don't need any explicit deduction guides to do so. This
1037 // macro is used to mark them as such, which suppresses the
1038 // '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
1039 // with these classes.
1040 # if _LIBCPP_STD_VER >= 17
1041 # ifdef _LIBCPP_COMPILER_CLANG_BASED
1042 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
1043 template <class... _Tag> \
1044 [[maybe_unused]] _ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...>
1045 # else
1046 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(ClassName) \
1047 template <class... _Tag> \
1048 ClassName(typename _Tag::__allow_ctad...)->ClassName<_Tag...>
1049 # endif
1050 # else
1051 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
1052 # endif
1053
1054 // TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use
1055 // compiler intrinsics in the Objective-C++ mode.
1056 # ifdef __OBJC__
1057 # define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS
1058 # endif
1059
1060 # define _PSTL_PRAGMA(x) _Pragma(#x)
1061
1062 // Enable SIMD for compilers that support OpenMP 4.0
1063 # if (defined(_OPENMP) && _OPENMP >= 201307)
1064
1065 # define _PSTL_UDR_PRESENT
1066 # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
1067 # define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
1068 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
1069 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
1070 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
1071 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
1072
1073 // Declaration of reduction functor, where
1074 // NAME - the name of the functor
1075 // OP - type of the callable object with the reduction operation
1076 // omp_in - refers to the local partial result
1077 // omp_out - refers to the final value of the combiner operator
1078 // omp_priv - refers to the private copy of the initial value
1079 // omp_orig - refers to the original variable to be reduced
1080 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
1081 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
1082
1083 # elif defined(_LIBCPP_COMPILER_CLANG_BASED)
1084
1085 # define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
1086 # define _PSTL_PRAGMA_DECLARE_SIMD
1087 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
1088 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
1089 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
1090 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
1091 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
1092
1093 # else // (defined(_OPENMP) && _OPENMP >= 201307)
1094
1095 # define _PSTL_PRAGMA_SIMD
1096 # define _PSTL_PRAGMA_DECLARE_SIMD
1097 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
1098 # define _PSTL_PRAGMA_SIMD_SCAN(PRM)
1099 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
1100 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
1101 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
1102
1103 # endif // (defined(_OPENMP) && _OPENMP >= 201307)
1104
1105 # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
1106
1107 // Optional attributes - these are useful for a better QoI, but not required to be available
1108
1109 # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
1110 # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
1111 # else
1112 # define _LIBCPP_NO_CFI
1113 # endif
1114
1115 # if __has_attribute(__malloc__)
1116 # define _LIBCPP_NOALIAS __attribute__((__malloc__))
1117 # else
1118 # define _LIBCPP_NOALIAS
1119 # endif
1120
1121 # if __has_attribute(__using_if_exists__)
1122 # define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
1123 # else
1124 # define _LIBCPP_USING_IF_EXISTS
1125 # endif
1126
1127 # if __has_cpp_attribute(__nodiscard__)
1128 # define _LIBCPP_NODISCARD [[__nodiscard__]]
1129 # else
1130 // We can't use GCC's [[gnu::warn_unused_result]] and
1131 // __attribute__((warn_unused_result)), because GCC does not silence them via
1132 // (void) cast.
1133 # define _LIBCPP_NODISCARD
1134 # endif
1135
1136 # if __has_attribute(__no_destroy__)
1137 # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1138 # else
1139 # define _LIBCPP_NO_DESTROY
1140 # endif
1141
1142 # if __has_attribute(__diagnose_if__)
1143 # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
1144 # else
1145 # define _LIBCPP_DIAGNOSE_WARNING(...)
1146 # endif
1147
1148 // Use a function like macro to imply that it must be followed by a semicolon
1149 # if __has_cpp_attribute(fallthrough)
1150 # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1151 # elif __has_attribute(__fallthrough__)
1152 # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1153 # else
1154 # define _LIBCPP_FALLTHROUGH() ((void)0)
1155 # endif
1156
1157 # if __has_cpp_attribute(_Clang::__lifetimebound__)
1158 # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1159 # else
1160 # define _LIBCPP_LIFETIMEBOUND
1161 # endif
1162
1163 # if __has_attribute(__nodebug__)
1164 # define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1165 # else
1166 # define _LIBCPP_NODEBUG
1167 # endif
1168
1169 # if __has_attribute(__standalone_debug__)
1170 # define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
1171 # else
1172 # define _LIBCPP_STANDALONE_DEBUG
1173 # endif
1174
1175 # if __has_attribute(__preferred_name__)
1176 # define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
1177 # else
1178 # define _LIBCPP_PREFERRED_NAME(x)
1179 # endif
1180
1181 # if __has_attribute(__no_sanitize__)
1182 # define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1183 # else
1184 # define _LIBCPP_NO_SANITIZE(...)
1185 # endif
1186
1187 # if __has_attribute(__init_priority__)
1188 # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
1189 # else
1190 # define _LIBCPP_INIT_PRIORITY_MAX
1191 # endif
1192
1193 # if __has_attribute(__format__)
1194 // The attribute uses 1-based indices for ordinary and static member functions.
1195 // The attribute uses 2-based indices for non-static member functions.
1196 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1197 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1198 # else
1199 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
1200 # endif
1201
1202 # if __has_attribute(__packed__)
1203 # define _LIBCPP_PACKED __attribute__((__packed__))
1204 # else
1205 # define _LIBCPP_PACKED
1206 # endif
1207
1208 # if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
1209 # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1210 # else
1211 # define _LIBCPP_DECLSPEC_EMPTY_BASES
1212 # endif
1213
1214 // Allow for build-time disabling of unsigned integer sanitization
1215 # if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
1216 # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
1217 # else
1218 # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1219 # endif
1220
1221 // Clang-18 has support for deducing this, but it does not set the FTM.
1222 # if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800)
1223 # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
1224 # endif
1225
1226 #endif // __cplusplus
1227
1228 #endif // _LIBCPP___CXX03___CONFIG