1e8d8bef9SDimitry Andric// -*- C++ -*- 2e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 3e8d8bef9SDimitry Andric// 4e8d8bef9SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5e8d8bef9SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6e8d8bef9SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7e8d8bef9SDimitry Andric// 8e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 9e8d8bef9SDimitry Andric 10e8d8bef9SDimitry Andric#ifndef _LIBCPP___AVAILABILITY 11e8d8bef9SDimitry Andric#define _LIBCPP___AVAILABILITY 12e8d8bef9SDimitry Andric 13e8d8bef9SDimitry Andric#include <__config> 14e8d8bef9SDimitry Andric 15e8d8bef9SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 16e8d8bef9SDimitry Andric# pragma GCC system_header 17e8d8bef9SDimitry Andric#endif 18e8d8bef9SDimitry Andric 19e8d8bef9SDimitry Andric// Libc++ is shipped by various vendors. In particular, it is used as a system 20e8d8bef9SDimitry Andric// library on macOS, iOS and other Apple platforms. In order for users to be 21e8d8bef9SDimitry Andric// able to compile a binary that is intended to be deployed to an older version 22e8d8bef9SDimitry Andric// of a platform, Clang provides availability attributes [1]. These attributes 23e8d8bef9SDimitry Andric// can be placed on declarations and are used to describe the life cycle of a 24e8d8bef9SDimitry Andric// symbol in the library. 25e8d8bef9SDimitry Andric// 26e8d8bef9SDimitry Andric// The main goal is to ensure a compile-time error if a symbol that hasn't been 27e8d8bef9SDimitry Andric// introduced in a previously released library is used in a program that targets 28e8d8bef9SDimitry Andric// that previously released library. Normally, this would be a load-time error 29e8d8bef9SDimitry Andric// when one tries to launch the program against the older library. 30e8d8bef9SDimitry Andric// 31e8d8bef9SDimitry Andric// For example, the filesystem library was introduced in the dylib in macOS 10.15. 32e8d8bef9SDimitry Andric// If a user compiles on a macOS 10.15 host but targets macOS 10.13 with their 33e8d8bef9SDimitry Andric// program, the compiler would normally not complain (because the required 34e8d8bef9SDimitry Andric// declarations are in the headers), but the dynamic loader would fail to find 35e8d8bef9SDimitry Andric// the symbols when actually trying to launch the program on macOS 10.13. To 36e8d8bef9SDimitry Andric// turn this into a compile-time issue instead, declarations are annotated with 37e8d8bef9SDimitry Andric// when they were introduced, and the compiler can produce a diagnostic if the 38e8d8bef9SDimitry Andric// program references something that isn't available on the deployment target. 39e8d8bef9SDimitry Andric// 40e8d8bef9SDimitry Andric// This mechanism is general in nature, and any vendor can add their markup to 41e8d8bef9SDimitry Andric// the library (see below). Whenever a new feature is added that requires support 42fe013be4SDimitry Andric// in the shared library, two macros are added below to allow marking the feature 43fe013be4SDimitry Andric// as unavailable: 44fe013be4SDimitry Andric// 1. A macro named `_LIBCPP_AVAILABILITY_HAS_NO_<feature>` which must be defined 45fe013be4SDimitry Andric// exactly when compiling for a target that doesn't support the feature. 46fe013be4SDimitry Andric// 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must always be defined 47fe013be4SDimitry Andric// and must expand to the proper availability attribute for the platform. 48fe013be4SDimitry Andric// 49fe013be4SDimitry Andric// When vendors decide to ship the feature as part of their shared library, they 50fe013be4SDimitry Andric// can update these macros appropriately for their platform, and the library will 51fe013be4SDimitry Andric// use those to provide an optimal user experience. 52e8d8bef9SDimitry Andric// 534652422eSDimitry Andric// Furthermore, many features in the standard library have corresponding 54fe013be4SDimitry Andric// feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_NO_<feature>` macros 55fe013be4SDimitry Andric// are checked by the corresponding feature-test macros generated by 56fe013be4SDimitry Andric// generate_feature_test_macro_components.py to ensure that the library 57fe013be4SDimitry Andric// doesn't announce a feature as being implemented if it is unavailable on 58fe013be4SDimitry Andric// the deployment target. 594652422eSDimitry Andric// 60e8d8bef9SDimitry Andric// Note that this mechanism is disabled by default in the "upstream" libc++. 61e8d8bef9SDimitry Andric// Availability annotations are only meaningful when shipping libc++ inside 62e8d8bef9SDimitry Andric// a platform (i.e. as a system library), and so vendors that want them should 63e8d8bef9SDimitry Andric// turn those annotations on at CMake configuration time. 64e8d8bef9SDimitry Andric// 65e8d8bef9SDimitry Andric// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability 66e8d8bef9SDimitry Andric 67e8d8bef9SDimitry Andric// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY 68e8d8bef9SDimitry Andric// for a while. 69e8d8bef9SDimitry Andric#if defined(_LIBCPP_DISABLE_AVAILABILITY) 70e8d8bef9SDimitry Andric# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) 71e8d8bef9SDimitry Andric# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS 72e8d8bef9SDimitry Andric# endif 73e8d8bef9SDimitry Andric#endif 74e8d8bef9SDimitry Andric 75*c9eafe97SDimitry Andric// Availability markup is disabled when building the library, or when a non-Clang 76*c9eafe97SDimitry Andric// compiler is used because only Clang supports the necessary attributes. 77e8d8bef9SDimitry Andric// doesn't support the proper attributes. 78*c9eafe97SDimitry Andric#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED) 79e8d8bef9SDimitry Andric# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) 80e8d8bef9SDimitry Andric# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS 81e8d8bef9SDimitry Andric# endif 82e8d8bef9SDimitry Andric#endif 83e8d8bef9SDimitry Andric 84e8d8bef9SDimitry Andric#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) 85e8d8bef9SDimitry Andric 86e8d8bef9SDimitry Andric// These macros control the availability of std::bad_optional_access and 87e8d8bef9SDimitry Andric// other exception types. These were put in the shared library to prevent 88e8d8bef9SDimitry Andric// code bloat from every user program defining the vtable for these exception 89e8d8bef9SDimitry Andric// types. 9081ad6265SDimitry Andric// 9181ad6265SDimitry Andric// Note that when exceptions are disabled, the methods that normally throw 9281ad6265SDimitry Andric// these exceptions can be used even on older deployment targets, but those 9381ad6265SDimitry Andric// methods will abort instead of throwing. 94c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS 1 95e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 96fe013be4SDimitry Andric 97c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS 1 98e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS 99fe013be4SDimitry Andric 100c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST 1 101e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST 102e8d8bef9SDimitry Andric 103a58f00eaSDimitry Andric// These macros controls the availability of __cxa_init_primary_exception 104a58f00eaSDimitry Andric// in the built library, which std::make_exception_ptr might use 105a58f00eaSDimitry Andric// (see libcxx/include/__exception/exception_ptr.h). 106a58f00eaSDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 1 107a58f00eaSDimitry Andric# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION 108a58f00eaSDimitry Andric 109e8d8bef9SDimitry Andric// These macros control the availability of all parts of <filesystem> that 110e8d8bef9SDimitry Andric// depend on something in the dylib. 111c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1 112fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY 113fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH 114fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP 115e8d8bef9SDimitry Andric 1160eae32dcSDimitry Andric// This controls the availability of floating-point std::to_chars functions. 1170eae32dcSDimitry Andric// These overloads were added later than the integer overloads. 118c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 1 1190eae32dcSDimitry Andric# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT 1200eae32dcSDimitry Andric 121e8d8bef9SDimitry Andric// This controls the availability of the C++20 synchronization library, 122e8d8bef9SDimitry Andric// which requires shared library support for various operations 12381ad6265SDimitry Andric// (see libcxx/src/atomic.cpp). This includes <barier>, <latch>, 12481ad6265SDimitry Andric// <semaphore>, and notification functions on std::atomic. 125c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_SYNC 1 126e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_SYNC 127fe6060f1SDimitry Andric 128bdd1243dSDimitry Andric// This controls whether the library claims to provide a default verbose 129bdd1243dSDimitry Andric// termination function, and consequently whether the headers will try 130bdd1243dSDimitry Andric// to use it when the mechanism isn't overriden at compile-time. 131c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT 1 132fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_VERBOSE_ABORT 133fe013be4SDimitry Andric 134fe013be4SDimitry Andric// This controls the availability of the C++17 std::pmr library, 135fe013be4SDimitry Andric// which is implemented in large part in the built library. 136c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_PMR 1 137fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_PMR 13881ad6265SDimitry Andric 139c9157d92SDimitry Andric// This controls the availability of the C++20 time zone database. 140c9157d92SDimitry Andric// The parser code is built in the library. 141c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_TZDB 1 142c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_TZDB 143c9157d92SDimitry Andric 144e710425bSDimitry Andric// This controls the availability of C++23 <print>, which 145e710425bSDimitry Andric// has a dependency on the built library (it needs access to 146e710425bSDimitry Andric// the underlying buffer types of std::cout, std::cerr, and std::clog. 147e710425bSDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_PRINT 1 148e710425bSDimitry Andric# define _LIBCPP_AVAILABILITY_PRINT 149e710425bSDimitry Andric 150c9157d92SDimitry Andric// Enable additional explicit instantiations of iostreams components. This 151c9157d92SDimitry Andric// reduces the number of weak definitions generated in programs that use 152c9157d92SDimitry Andric// iostreams by providing a single strong definition in the shared library. 153c9157d92SDimitry Andric// 154c9157d92SDimitry Andric// TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation, 155c9157d92SDimitry Andric// or once libc++ doesn't use the attribute anymore. 156c9157d92SDimitry Andric// TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed. 157c9157d92SDimitry Andric# if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32) 158c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 1 159c9157d92SDimitry Andric# else 160c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0 161c9157d92SDimitry Andric# endif 162c9157d92SDimitry Andric 163e8d8bef9SDimitry Andric#elif defined(__APPLE__) 164e8d8bef9SDimitry Andric 165c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS \ 166c9157d92SDimitry Andric (!defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 50000) 1674652422eSDimitry Andric 168c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS 169c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS 1704652422eSDimitry Andric 171c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((availability(watchos, strict, introduced = 5.0))) 172c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 173c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 1744652422eSDimitry Andric 175a58f00eaSDimitry Andric// TODO: Update once this is released 176a58f00eaSDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0 177a58f00eaSDimitry Andric# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION __attribute__((unavailable)) 178a58f00eaSDimitry Andric 179fe013be4SDimitry Andric// <filesystem> 180c9157d92SDimitry Andric// clang-format off 1814652422eSDimitry Andric# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ 1824652422eSDimitry Andric (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \ 1834652422eSDimitry Andric (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \ 1844652422eSDimitry Andric (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) 185c9157d92SDimitry Andric// clang-format on 186c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 0 187c9157d92SDimitry Andric# else 188c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1 1894652422eSDimitry Andric# endif 190fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY \ 191fe013be4SDimitry Andric __attribute__((availability(macos, strict, introduced = 10.15))) \ 192fe013be4SDimitry Andric __attribute__((availability(ios, strict, introduced = 13.0))) \ 193fe013be4SDimitry Andric __attribute__((availability(tvos, strict, introduced = 13.0))) \ 194fe013be4SDimitry Andric __attribute__((availability(watchos, strict, introduced = 6.0))) 195c9157d92SDimitry Andric// clang-format off 196fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH \ 197fe013be4SDimitry Andric _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \ 198fe013be4SDimitry Andric _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \ 199fe013be4SDimitry Andric _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \ 200fe013be4SDimitry Andric _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))") 201fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP \ 202fe013be4SDimitry Andric _Pragma("clang attribute pop") \ 203fe013be4SDimitry Andric _Pragma("clang attribute pop") \ 204fe013be4SDimitry Andric _Pragma("clang attribute pop") \ 205fe013be4SDimitry Andric _Pragma("clang attribute pop") 206c9157d92SDimitry Andric// clang-format on 2074652422eSDimitry Andric 208fe013be4SDimitry Andric// std::to_chars(floating-point) 209c9157d92SDimitry Andric// clang-format off 210fe013be4SDimitry Andric# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130300) || \ 211fe013be4SDimitry Andric (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160300) || \ 212fe013be4SDimitry Andric (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160300) || \ 213fe013be4SDimitry Andric (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90300) 214c9157d92SDimitry Andric// clang-format on 215c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 0 216c9157d92SDimitry Andric# else 217c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 1 218fe013be4SDimitry Andric# endif 2190eae32dcSDimitry Andric# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \ 220fe013be4SDimitry Andric __attribute__((availability(macos, strict, introduced = 13.3))) \ 221fe013be4SDimitry Andric __attribute__((availability(ios, strict, introduced = 16.3))) \ 222fe013be4SDimitry Andric __attribute__((availability(tvos, strict, introduced = 16.3))) \ 223fe013be4SDimitry Andric __attribute__((availability(watchos, strict, introduced = 9.3))) 2240eae32dcSDimitry Andric 225fe013be4SDimitry Andric// c++20 synchronization library 226c9157d92SDimitry Andric// clang-format off 227fe013be4SDimitry Andric# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \ 228fe013be4SDimitry Andric (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \ 229fe013be4SDimitry Andric (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \ 230fe013be4SDimitry Andric (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000) 231c9157d92SDimitry Andric// clang-format on 232c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_SYNC 0 233c9157d92SDimitry Andric# else 234c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_SYNC 1 235fe013be4SDimitry Andric# endif 236e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_SYNC \ 23781ad6265SDimitry Andric __attribute__((availability(macos, strict, introduced = 11.0))) \ 238fe6060f1SDimitry Andric __attribute__((availability(ios, strict, introduced = 14.0))) \ 239fe6060f1SDimitry Andric __attribute__((availability(tvos, strict, introduced = 14.0))) \ 240fe6060f1SDimitry Andric __attribute__((availability(watchos, strict, introduced = 7.0))) 241fe013be4SDimitry Andric 242fe013be4SDimitry Andric// __libcpp_verbose_abort 243c9157d92SDimitry Andric// TODO: Update once this is released 244c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT 0 245c9157d92SDimitry Andric 246e710425bSDimitry Andric# define _LIBCPP_AVAILABILITY_VERBOSE_ABORT __attribute__((unavailable)) 24781ad6265SDimitry Andric 248fe013be4SDimitry Andric// std::pmr 249c9157d92SDimitry Andric// clang-format off 250fe013be4SDimitry Andric# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \ 251fe013be4SDimitry Andric (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \ 252fe013be4SDimitry Andric (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \ 253fe013be4SDimitry Andric (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000) 254c9157d92SDimitry Andric// clang-format on 255c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_PMR 0 256c9157d92SDimitry Andric# else 257c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_PMR 1 258fe013be4SDimitry Andric# endif 259fe013be4SDimitry Andric// TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed 260fe013be4SDimitry Andric// Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support 261fe013be4SDimitry Andric// it and it'll be a load-time error, but we don't have a good alternative because the library won't compile if we 262fe013be4SDimitry Andric// use availability annotations until that bug has been fixed. 263fe013be4SDimitry Andric# if 0 264fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_PMR \ 265fe013be4SDimitry Andric __attribute__((availability(macos, strict, introduced = 14.0))) \ 266fe013be4SDimitry Andric __attribute__((availability(ios, strict, introduced = 17.0))) \ 267fe013be4SDimitry Andric __attribute__((availability(tvos, strict, introduced = 17.0))) \ 268fe013be4SDimitry Andric __attribute__((availability(watchos, strict, introduced = 10.0))) 269fe013be4SDimitry Andric# else 270fe013be4SDimitry Andric# define _LIBCPP_AVAILABILITY_PMR 271fe013be4SDimitry Andric# endif 27261cfbce3SDimitry Andric 273c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_TZDB 0 274c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_TZDB __attribute__((unavailable)) 275c9157d92SDimitry Andric 276a58f00eaSDimitry Andric// Warning: This availability macro works differently than the other macros. 277a58f00eaSDimitry Andric// The dylib part of print is not needed on Apple platforms. Therefore when 278a58f00eaSDimitry Andric// the macro is not available the code calling the dylib is commented out. 279a58f00eaSDimitry Andric// The macro _LIBCPP_AVAILABILITY_PRINT is not used. 280e710425bSDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_PRINT 0 281e710425bSDimitry Andric# define _LIBCPP_AVAILABILITY_PRINT __attribute__((unavailable)) 282e710425bSDimitry Andric 283c9157d92SDimitry Andric// clang-format off 284c9157d92SDimitry Andric# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120000) || \ 285c9157d92SDimitry Andric (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150000) || \ 286c9157d92SDimitry Andric (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150000) || \ 287c9157d92SDimitry Andric (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80000) 288c9157d92SDimitry Andric// clang-format on 289c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0 290c9157d92SDimitry Andric# else 291c9157d92SDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 1 292c9157d92SDimitry Andric# endif 293e8d8bef9SDimitry Andric#else 294e8d8bef9SDimitry Andric 295e8d8bef9SDimitry Andric// ...New vendors can add availability markup here... 296e8d8bef9SDimitry Andric 297e710425bSDimitry Andric# error \ 298e710425bSDimitry Andric "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!" 299e8d8bef9SDimitry Andric 300e8d8bef9SDimitry Andric#endif 301e8d8bef9SDimitry Andric 302fe013be4SDimitry Andric// Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS. 303e8d8bef9SDimitry Andric// Those are defined in terms of the availability attributes above, and 304e8d8bef9SDimitry Andric// should not be vendor-specific. 305fe013be4SDimitry Andric#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) 306e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST 307e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS 308e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS 309e8d8bef9SDimitry Andric#else 310e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST 311e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 312e8d8bef9SDimitry Andric# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS 313e8d8bef9SDimitry Andric#endif 314e8d8bef9SDimitry Andric 315a58f00eaSDimitry Andric// Define availability attributes that depend on both 316a58f00eaSDimitry Andric// _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI. 317a58f00eaSDimitry Andric#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI) 318a58f00eaSDimitry Andric# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 319a58f00eaSDimitry Andric# undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION 320a58f00eaSDimitry Andric# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0 321a58f00eaSDimitry Andric# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION 322a58f00eaSDimitry Andric#endif 323a58f00eaSDimitry Andric 324e8d8bef9SDimitry Andric#endif // _LIBCPP___AVAILABILITY 325