__availability 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___AVAILABILITY
  10. #define _LIBCPP___AVAILABILITY
  11. #include <__config>
  12. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  13. # pragma GCC system_header
  14. #endif
  15. // Libc++ is shipped by various vendors. In particular, it is used as a system
  16. // library on macOS, iOS and other Apple platforms. In order for users to be
  17. // able to compile a binary that is intended to be deployed to an older version
  18. // of a platform, Clang provides availability attributes [1]. These attributes
  19. // can be placed on declarations and are used to describe the life cycle of a
  20. // symbol in the library.
  21. //
  22. // The main goal is to ensure a compile-time error if a symbol that hasn't been
  23. // introduced in a previously released library is used in a program that targets
  24. // that previously released library. Normally, this would be a load-time error
  25. // when one tries to launch the program against the older library.
  26. //
  27. // For example, the filesystem library was introduced in the dylib in macOS 10.15.
  28. // If a user compiles on a macOS 10.15 host but targets macOS 10.13 with their
  29. // program, the compiler would normally not complain (because the required
  30. // declarations are in the headers), but the dynamic loader would fail to find
  31. // the symbols when actually trying to launch the program on macOS 10.13. To
  32. // turn this into a compile-time issue instead, declarations are annotated with
  33. // when they were introduced, and the compiler can produce a diagnostic if the
  34. // program references something that isn't available on the deployment target.
  35. //
  36. // This mechanism is general in nature, and any vendor can add their markup to
  37. // the library (see below). Whenever a new feature is added that requires support
  38. // in the shared library, two macros are added below to allow marking the feature
  39. // as unavailable:
  40. // 1. A macro named `_LIBCPP_AVAILABILITY_HAS_NO_<feature>` which must be defined
  41. // exactly when compiling for a target that doesn't support the feature.
  42. // 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must always be defined
  43. // and must expand to the proper availability attribute for the platform.
  44. //
  45. // When vendors decide to ship the feature as part of their shared library, they
  46. // can update these macros appropriately for their platform, and the library will
  47. // use those to provide an optimal user experience.
  48. //
  49. // Furthermore, many features in the standard library have corresponding
  50. // feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_NO_<feature>` macros
  51. // are checked by the corresponding feature-test macros generated by
  52. // generate_feature_test_macro_components.py to ensure that the library
  53. // doesn't announce a feature as being implemented if it is unavailable on
  54. // the deployment target.
  55. //
  56. // Note that this mechanism is disabled by default in the "upstream" libc++.
  57. // Availability annotations are only meaningful when shipping libc++ inside
  58. // a platform (i.e. as a system library), and so vendors that want them should
  59. // turn those annotations on at CMake configuration time.
  60. //
  61. // [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
  62. // For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
  63. // for a while.
  64. #if defined(_LIBCPP_DISABLE_AVAILABILITY)
  65. # if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
  66. # define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
  67. # endif
  68. #endif
  69. // Availability markup is disabled when building the library, or when the compiler
  70. // doesn't support the proper attributes.
  71. #if defined(_LIBCPP_BUILDING_LIBRARY) || \
  72. defined(_LIBCXXABI_BUILDING_LIBRARY) || \
  73. !__has_feature(attribute_availability_with_strict) || \
  74. !__has_feature(attribute_availability_in_templates) || \
  75. !__has_extension(pragma_clang_attribute_external_declaration)
  76. # if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
  77. # define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
  78. # endif
  79. #endif
  80. #if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
  81. // This controls the availability of std::shared_mutex and std::shared_timed_mutex,
  82. // which were added to the dylib later.
  83. // # define _LIBCPP_AVAILABILITY_HAS_NO_SHARED_MUTEX
  84. # define _LIBCPP_AVAILABILITY_SHARED_MUTEX
  85. // These macros control the availability of std::bad_optional_access and
  86. // other exception types. These were put in the shared library to prevent
  87. // code bloat from every user program defining the vtable for these exception
  88. // types.
  89. //
  90. // Note that when exceptions are disabled, the methods that normally throw
  91. // these exceptions can be used even on older deployment targets, but those
  92. // methods will abort instead of throwing.
  93. // # define _LIBCPP_AVAILABILITY_HAS_NO_BAD_OPTIONAL_ACCESS
  94. # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
  95. // # define _LIBCPP_AVAILABILITY_HAS_NO_BAD_VARIANT_ACCESS
  96. # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
  97. // # define _LIBCPP_AVAILABILITY_HAS_NO_BAD_ANY_CAST
  98. # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
  99. // This controls the availability of std::uncaught_exceptions().
  100. // # define _LIBCPP_AVAILABILITY_HAS_NO_UNCAUGHT_EXCEPTIONS
  101. # define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
  102. // This controls the availability of the sized version of ::operator delete,
  103. // ::operator delete[], and their align_val_t variants, which were all added
  104. // in C++17, and hence not present in early dylibs.
  105. // # define _LIBCPP_AVAILABILITY_HAS_NO_SIZED_NEW_DELETE
  106. # define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
  107. // This controls the availability of the std::future_error exception.
  108. //
  109. // Note that when exceptions are disabled, the methods that normally throw
  110. // std::future_error can be used even on older deployment targets, but those
  111. // methods will abort instead of throwing.
  112. // # define _LIBCPP_AVAILABILITY_HAS_NO_FUTURE_ERROR
  113. # define _LIBCPP_AVAILABILITY_FUTURE_ERROR
  114. // This controls the availability of std::type_info's vtable.
  115. // I can't imagine how using std::type_info can work at all if
  116. // this isn't supported.
  117. // # define _LIBCPP_AVAILABILITY_HAS_NO_TYPEINFO_VTABLE
  118. # define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
  119. // This controls the availability of std::locale::category members
  120. // (e.g. std::locale::collate), which are defined in the dylib.
  121. // # define _LIBCPP_AVAILABILITY_HAS_NO_LOCALE_CATEGORY
  122. # define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
  123. // This controls the availability of atomic operations on std::shared_ptr
  124. // (e.g. `std::atomic_store(std::shared_ptr)`), which require a shared
  125. // lock table located in the dylib.
  126. // # define _LIBCPP_AVAILABILITY_HAS_NO_ATOMIC_SHARED_PTR
  127. # define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
  128. // These macros control the availability of all parts of <filesystem> that
  129. // depend on something in the dylib.
  130. // # define _LIBCPP_AVAILABILITY_HAS_NO_FILESYSTEM_LIBRARY
  131. # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
  132. # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH
  133. # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
  134. // This controls the availability of floating-point std::to_chars functions.
  135. // These overloads were added later than the integer overloads.
  136. // # define _LIBCPP_AVAILABILITY_HAS_NO_TO_CHARS_FLOATING_POINT
  137. # define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT
  138. // This controls the availability of the C++20 synchronization library,
  139. // which requires shared library support for various operations
  140. // (see libcxx/src/atomic.cpp). This includes <barier>, <latch>,
  141. // <semaphore>, and notification functions on std::atomic.
  142. // # define _LIBCPP_AVAILABILITY_HAS_NO_SYNC
  143. # define _LIBCPP_AVAILABILITY_SYNC
  144. // This controls whether the library claims to provide a default verbose
  145. // termination function, and consequently whether the headers will try
  146. // to use it when the mechanism isn't overriden at compile-time.
  147. // # define _LIBCPP_AVAILABILITY_HAS_NO_VERBOSE_ABORT
  148. # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT
  149. // This controls the availability of the C++17 std::pmr library,
  150. // which is implemented in large part in the built library.
  151. // # define _LIBCPP_AVAILABILITY_HAS_NO_PMR
  152. # define _LIBCPP_AVAILABILITY_PMR
  153. // This controls the availability of the C++20 time zone database.
  154. // The parser code is built in the library.
  155. // # define _LIBCPP_AVAILABILITY_HAS_NO_TZDB
  156. # define _LIBCPP_AVAILABILITY_TZDB
  157. #elif defined(__APPLE__)
  158. // shared_mutex and shared_timed_mutex
  159. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200) || \
  160. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 100000) || \
  161. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 100000) || \
  162. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 30000)
  163. # define _LIBCPP_AVAILABILITY_HAS_NO_SHARED_MUTEX
  164. # endif
  165. # define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
  166. __attribute__((availability(macos,strict,introduced=10.12))) \
  167. __attribute__((availability(ios,strict,introduced=10.0))) \
  168. __attribute__((availability(tvos,strict,introduced=10.0))) \
  169. __attribute__((availability(watchos,strict,introduced=3.0)))
  170. // bad_optional_access, bad_variant_access and bad_any_cast
  171. // Note: bad_optional_access & friends were not introduced in the matching
  172. // macOS and iOS versions, so the version mismatch between macOS and others
  173. // is intended.
  174. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300) || \
  175. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
  176. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 120000) || \
  177. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000)
  178. # define _LIBCPP_AVAILABILITY_HAS_NO_BAD_OPTIONAL_ACCESS
  179. # define _LIBCPP_AVAILABILITY_HAS_NO_BAD_VARIANT_ACCESS
  180. # define _LIBCPP_AVAILABILITY_HAS_NO_BAD_ANY_CAST
  181. # endif
  182. # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
  183. __attribute__((availability(macos,strict,introduced=10.13))) \
  184. __attribute__((availability(ios,strict,introduced=12.0))) \
  185. __attribute__((availability(tvos,strict,introduced=12.0))) \
  186. __attribute__((availability(watchos,strict,introduced=5.0)))
  187. # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
  188. _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
  189. # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
  190. _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
  191. // uncaught_exceptions
  192. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200) || \
  193. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 100000) || \
  194. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 100000) || \
  195. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 30000)
  196. # define _LIBCPP_AVAILABILITY_HAS_NO_UNCAUGHT_EXCEPTIONS
  197. # endif
  198. # define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
  199. __attribute__((availability(macos,strict,introduced=10.12))) \
  200. __attribute__((availability(ios,strict,introduced=10.0))) \
  201. __attribute__((availability(tvos,strict,introduced=10.0))) \
  202. __attribute__((availability(watchos,strict,introduced=3.0)))
  203. // sized operator new and sized operator delete
  204. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200) || \
  205. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 100000) || \
  206. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 100000) || \
  207. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 30000)
  208. # define _LIBCPP_AVAILABILITY_HAS_NO_SIZED_NEW_DELETE
  209. # endif
  210. # define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
  211. __attribute__((availability(macos,strict,introduced=10.12))) \
  212. __attribute__((availability(ios,strict,introduced=10.0))) \
  213. __attribute__((availability(tvos,strict,introduced=10.0))) \
  214. __attribute__((availability(watchos,strict,introduced=3.0)))
  215. // future_error
  216. # if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 60000)
  217. # define _LIBCPP_AVAILABILITY_HAS_NO_FUTURE_ERROR
  218. # endif
  219. # define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
  220. __attribute__((availability(ios,strict,introduced=6.0)))
  221. // type_info's vtable
  222. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 100900) || \
  223. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000)
  224. # define _LIBCPP_AVAILABILITY_HAS_NO_TYPEINFO_VTABLE
  225. # endif
  226. # define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
  227. __attribute__((availability(macos,strict,introduced=10.9))) \
  228. __attribute__((availability(ios,strict,introduced=7.0)))
  229. // locale::category
  230. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 100900) || \
  231. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000)
  232. # define _LIBCPP_AVAILABILITY_HAS_NO_LOCALE_CATEGORY
  233. # endif
  234. # define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
  235. __attribute__((availability(macos,strict,introduced=10.9))) \
  236. __attribute__((availability(ios,strict,introduced=7.0)))
  237. // atomic operations on shared_ptr
  238. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 100900) || \
  239. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000)
  240. # define _LIBCPP_AVAILABILITY_HAS_NO_ATOMIC_SHARED_PTR
  241. # endif
  242. # define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
  243. __attribute__((availability(macos,strict,introduced=10.9))) \
  244. __attribute__((availability(ios,strict,introduced=7.0)))
  245. // <filesystem>
  246. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
  247. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
  248. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \
  249. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000)
  250. # define _LIBCPP_AVAILABILITY_HAS_NO_FILESYSTEM_LIBRARY
  251. # endif
  252. # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY \
  253. __attribute__((availability(macos,strict,introduced=10.15))) \
  254. __attribute__((availability(ios,strict,introduced=13.0))) \
  255. __attribute__((availability(tvos,strict,introduced=13.0))) \
  256. __attribute__((availability(watchos,strict,introduced=6.0)))
  257. # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH \
  258. _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \
  259. _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
  260. _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
  261. _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
  262. # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP \
  263. _Pragma("clang attribute pop") \
  264. _Pragma("clang attribute pop") \
  265. _Pragma("clang attribute pop") \
  266. _Pragma("clang attribute pop")
  267. // std::to_chars(floating-point)
  268. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130300) || \
  269. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160300) || \
  270. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160300) || \
  271. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90300)
  272. # define _LIBCPP_AVAILABILITY_HAS_NO_TO_CHARS_FLOATING_POINT
  273. # endif
  274. # define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \
  275. __attribute__((availability(macos,strict,introduced=13.3))) \
  276. __attribute__((availability(ios,strict,introduced=16.3))) \
  277. __attribute__((availability(tvos,strict,introduced=16.3))) \
  278. __attribute__((availability(watchos,strict,introduced=9.3)))
  279. // c++20 synchronization library
  280. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \
  281. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \
  282. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \
  283. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000)
  284. # define _LIBCPP_AVAILABILITY_HAS_NO_SYNC
  285. # endif
  286. # define _LIBCPP_AVAILABILITY_SYNC \
  287. __attribute__((availability(macos,strict,introduced=11.0))) \
  288. __attribute__((availability(ios,strict,introduced=14.0))) \
  289. __attribute__((availability(tvos,strict,introduced=14.0))) \
  290. __attribute__((availability(watchos,strict,introduced=7.0)))
  291. // __libcpp_verbose_abort
  292. # if 1 // TODO: Update once this is released
  293. # define _LIBCPP_AVAILABILITY_HAS_NO_VERBOSE_ABORT
  294. # endif
  295. # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT \
  296. __attribute__((unavailable))
  297. // std::pmr
  298. # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \
  299. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \
  300. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \
  301. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000)
  302. # define _LIBCPP_AVAILABILITY_HAS_NO_PMR
  303. # endif
  304. // TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed
  305. // Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support
  306. // 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
  307. // use availability annotations until that bug has been fixed.
  308. # if 0
  309. # define _LIBCPP_AVAILABILITY_PMR \
  310. __attribute__((availability(macos, strict, introduced = 14.0))) \
  311. __attribute__((availability(ios, strict, introduced = 17.0))) \
  312. __attribute__((availability(tvos, strict, introduced = 17.0))) \
  313. __attribute__((availability(watchos, strict, introduced = 10.0)))
  314. # else
  315. # define _LIBCPP_AVAILABILITY_PMR
  316. # endif
  317. # define _LIBCPP_AVAILABILITY_HAS_NO_TZDB
  318. # define _LIBCPP_AVAILABILITY_TZDB __attribute__((unavailable))
  319. #else
  320. // ...New vendors can add availability markup here...
  321. # error "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!"
  322. #endif
  323. // Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS.
  324. // Those are defined in terms of the availability attributes above, and
  325. // should not be vendor-specific.
  326. #if defined(_LIBCPP_HAS_NO_EXCEPTIONS)
  327. # define _LIBCPP_AVAILABILITY_FUTURE
  328. # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
  329. # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
  330. # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
  331. #else
  332. # define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
  333. # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
  334. # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
  335. # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
  336. #endif
  337. #endif // _LIBCPP___AVAILABILITY