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
10#ifndef _LIBCPP___CONFIGURATION_AVAILABILITY_H
11#define _LIBCPP___CONFIGURATION_AVAILABILITY_H
12
13#include <__configuration/compiler.h>
14#include <__configuration/language.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20// Libc++ is shipped by various vendors. In particular, it is used as a system
21// library on macOS, iOS and other Apple platforms. In order for users to be
22// able to compile a binary that is intended to be deployed to an older version
23// of a platform, Clang provides availability attributes [1]. These attributes
24// can be placed on declarations and are used to describe the life cycle of a
25// symbol in the library.
26//
27// The main goal is to ensure a compile-time error if a symbol that hasn't been
28// introduced in a previously released library is used in a program that targets
29// that previously released library. Normally, this would be a load-time error
30// when one tries to launch the program against the older library.
31//
32// For example, the filesystem library was introduced in the dylib in LLVM 9.
33// On Apple platforms, this corresponds to macOS 10.15. If a user compiles on
34// a macOS 10.15 host but targets macOS 10.13 with their program, the compiler
35// would normally not complain (because the required declarations are in the
36// headers), but the dynamic loader would fail to find the symbols when actually
37// trying to launch the program on macOS 10.13. To turn this into a compile-time
38// issue instead, declarations are annotated with when they were introduced, and
39// the compiler can produce a diagnostic if the program references something that
40// isn't available on the deployment target.
41//
42// This mechanism is general in nature, and any vendor can add their markup to
43// the library (see below). Whenever a new feature is added that requires support
44// in the shared library, two macros are added below to allow marking the feature
45// as unavailable:
46// 1. A macro named `_LIBCPP_AVAILABILITY_HAS_<feature>` which must be defined
47// to `_LIBCPP_INTRODUCED_IN_<version>` for the appropriate LLVM version.
48// 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must be defined to
49// `_LIBCPP_INTRODUCED_IN_<version>_MARKUP` for the appropriate LLVM version.
50//
51// When vendors decide to ship the feature as part of their shared library, they
52// can update the `_LIBCPP_INTRODUCED_IN_<version>` macro (and the markup counterpart)
53// based on the platform version they shipped that version of LLVM in. The library
54// will then use this markup to provide an optimal user experience on these platforms.
55//
56// Furthermore, many features in the standard library have corresponding
57// feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_<feature>` macros
58// are checked by the corresponding feature-test macros generated by
59// generate_feature_test_macro_components.py to ensure that the library
60// doesn't announce a feature as being implemented if it is unavailable on
61// the deployment target.
62//
63// Note that this mechanism is disabled by default in the "upstream" libc++.
64// Availability annotations are only meaningful when shipping libc++ inside
65// a platform (i.e. as a system library), and so vendors that want them should
66// turn those annotations on at CMake configuration time.
67//
68// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
69
70// Availability markup is disabled when building the library, or when a non-Clang
71// compiler is used because only Clang supports the necessary attributes.
72//
73// We also allow users to force-disable availability markup via the `_LIBCPP_DISABLE_AVAILABILITY`
74// macro because that is the only way to work around a Clang bug related to availability
75// attributes: https://github.com/llvm/llvm-project/issues/134151.
76// Once that bug has been fixed, we should remove the macro.
77#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || \
78 !defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_DISABLE_AVAILABILITY)
79# undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
80# define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0
81#endif
82
83// When availability annotations are disabled, we take for granted that features introduced
84// in all versions of the library are available.
85#if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
86
87# define _LIBCPP_INTRODUCED_IN_LLVM_21 1
88# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE /* nothing */
89
90# define _LIBCPP_INTRODUCED_IN_LLVM_20 1
91# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE /* nothing */
92
93# define _LIBCPP_INTRODUCED_IN_LLVM_19 1
94# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE /* nothing */
95
96# define _LIBCPP_INTRODUCED_IN_LLVM_18 1
97# define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE /* nothing */
98
99# define _LIBCPP_INTRODUCED_IN_LLVM_16 1
100# define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE /* nothing */
101
102# define _LIBCPP_INTRODUCED_IN_LLVM_15 1
103# define _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE /* nothing */
104
105# define _LIBCPP_INTRODUCED_IN_LLVM_14 1
106# define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE /* nothing */
107
108# define _LIBCPP_INTRODUCED_IN_LLVM_12 1
109# define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */
110
111# define _LIBCPP_INTRODUCED_IN_LLVM_11 1
112# define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE /* nothing */
113
114# define _LIBCPP_INTRODUCED_IN_LLVM_9 1
115# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE /* nothing */
116# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */
117# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */
118
119#elif defined(__APPLE__)
120
121// clang-format off
122
123// LLVM 21
124// TODO: Fill this in
125# define _LIBCPP_INTRODUCED_IN_LLVM_21 0
126# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE __attribute__((unavailable))
127
128// LLVM 20
129// TODO: Fill this in
130# define _LIBCPP_INTRODUCED_IN_LLVM_20 0
131# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE __attribute__((unavailable))
132
133// LLVM 19
134// TODO: Fill this in
135# define _LIBCPP_INTRODUCED_IN_LLVM_19 0
136# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable))
137
138// LLVM 18
139# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150000) || \
140 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 180000) || \
141 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 180000) || \
142 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 110000) || \
143 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 90000) || \
144 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 240000)
145# define _LIBCPP_INTRODUCED_IN_LLVM_18 0
146# else
147# define _LIBCPP_INTRODUCED_IN_LLVM_18 1
148# endif
149# define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE \
150 __attribute__((availability(macos, strict, introduced = 15.0))) \
151 __attribute__((availability(ios, strict, introduced = 18.0))) \
152 __attribute__((availability(tvos, strict, introduced = 18.0))) \
153 __attribute__((availability(watchos, strict, introduced = 11.0))) \
154 __attribute__((availability(bridgeos, strict, introduced = 9.0))) \
155 __attribute__((availability(driverkit, strict, introduced = 24.0)))
156
157// LLVM 16
158# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \
159 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \
160 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \
161 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000) || \
162 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 80000) || \
163 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 230000)
164# define _LIBCPP_INTRODUCED_IN_LLVM_16 0
165# else
166# define _LIBCPP_INTRODUCED_IN_LLVM_16 1
167# endif
168# define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE \
169 __attribute__((availability(macos, strict, introduced = 14.0))) \
170 __attribute__((availability(ios, strict, introduced = 17.0))) \
171 __attribute__((availability(tvos, strict, introduced = 17.0))) \
172 __attribute__((availability(watchos, strict, introduced = 10.0))) \
173 __attribute__((availability(bridgeos, strict, introduced = 8.0))) \
174 __attribute__((availability(driverkit, strict, introduced = 23.0)))
175
176// LLVM 15
177# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130300) || \
178 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160300) || \
179 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160300) || \
180 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90300) || \
181 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 70500) || \
182 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 220400)
183# define _LIBCPP_INTRODUCED_IN_LLVM_15 0
184# else
185# define _LIBCPP_INTRODUCED_IN_LLVM_15 1
186# endif
187# define _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE \
188 __attribute__((availability(macos, strict, introduced = 13.3))) \
189 __attribute__((availability(ios, strict, introduced = 16.3))) \
190 __attribute__((availability(tvos, strict, introduced = 16.3))) \
191 __attribute__((availability(watchos, strict, introduced = 9.3))) \
192 __attribute__((availability(bridgeos, strict, introduced = 7.5))) \
193 __attribute__((availability(driverkit, strict, introduced = 22.4)))
194
195// LLVM 14
196# define _LIBCPP_INTRODUCED_IN_LLVM_14 _LIBCPP_INTRODUCED_IN_LLVM_15
197# define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE
198
199// LLVM 12
200# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120300) || \
201 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150300) || \
202 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150300) || \
203 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80300) || \
204 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 60000) || \
205 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 210300)
206# define _LIBCPP_INTRODUCED_IN_LLVM_12 0
207# else
208# define _LIBCPP_INTRODUCED_IN_LLVM_12 1
209# endif
210# define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE \
211 __attribute__((availability(macos, strict, introduced = 12.3))) \
212 __attribute__((availability(ios, strict, introduced = 15.3))) \
213 __attribute__((availability(tvos, strict, introduced = 15.3))) \
214 __attribute__((availability(watchos, strict, introduced = 8.3))) \
215 __attribute__((availability(bridgeos, strict, introduced = 6.0))) \
216 __attribute__((availability(driverkit, strict, introduced = 21.3)))
217
218// LLVM 11
219# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \
220 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \
221 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \
222 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000)
223# define _LIBCPP_INTRODUCED_IN_LLVM_11 0
224# else
225# define _LIBCPP_INTRODUCED_IN_LLVM_11 1
226# endif
227# define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE \
228 __attribute__((availability(macos, strict, introduced = 11.0))) \
229 __attribute__((availability(ios, strict, introduced = 14.0))) \
230 __attribute__((availability(tvos, strict, introduced = 14.0))) \
231 __attribute__((availability(watchos, strict, introduced = 7.0)))
232
233// LLVM 9
234# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
235 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
236 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \
237 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000)
238# define _LIBCPP_INTRODUCED_IN_LLVM_9 0
239# else
240# define _LIBCPP_INTRODUCED_IN_LLVM_9 1
241# endif
242# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE \
243 __attribute__((availability(macos, strict, introduced = 10.15))) \
244 __attribute__((availability(ios, strict, introduced = 13.0))) \
245 __attribute__((availability(tvos, strict, introduced = 13.0))) \
246 __attribute__((availability(watchos, strict, introduced = 6.0)))
247# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH \
248 _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \
249 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
250 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
251 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
252# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP \
253 _Pragma("clang attribute pop") \
254 _Pragma("clang attribute pop") \
255 _Pragma("clang attribute pop") \
256 _Pragma("clang attribute pop")
257
258// clang-format on
259
260#else
261
262// ...New vendors can add availability markup here...
263
264# error \
265 "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!"
266
267#endif
268
269// These macros control the availability of all parts of <filesystem> that
270// depend on something in the dylib.
271#define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9
272#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE
273#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH
274#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP
275
276// This controls the availability of the C++20 synchronization library,
277// which requires shared library support for various operations
278// (see libcxx/src/atomic.cpp). This includes <barier>, <latch>,
279// <semaphore>, and notification functions on std::atomic.
280#define _LIBCPP_AVAILABILITY_HAS_SYNC _LIBCPP_INTRODUCED_IN_LLVM_11
281#define _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE
282
283// Enable additional explicit instantiations of iostreams components. This
284// reduces the number of weak definitions generated in programs that use
285// iostreams by providing a single strong definition in the shared library.
286//
287// TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation,
288// or once libc++ doesn't use the attribute anymore.
289// TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed.
290#if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32)
291# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 _LIBCPP_INTRODUCED_IN_LLVM_12
292#else
293# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0
294#endif
295
296// This controls the availability of floating-point std::to_chars functions.
297// These overloads were added later than the integer overloads.
298#define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14
299#define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE
300
301// This controls whether the library claims to provide a default verbose
302// termination function, and consequently whether the headers will try
303// to use it when the mechanism isn't overriden at compile-time.
304#define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15
305#define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE
306
307// This controls the availability of the C++17 std::pmr library,
308// which is implemented in large part in the built library.
309//
310// TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed
311// Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support
312// 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
313// use availability annotations until that bug has been fixed.
314#define _LIBCPP_AVAILABILITY_HAS_PMR _LIBCPP_INTRODUCED_IN_LLVM_16
315#define _LIBCPP_AVAILABILITY_PMR
316
317// These macros controls the availability of __cxa_init_primary_exception
318// in the built library, which std::make_exception_ptr might use
319// (see libcxx/include/__exception/exception_ptr.h).
320#define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18
321#define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
322
323// This controls the availability of C++23 <print>, which
324// has a dependency on the built library (it needs access to
325// the underlying buffer types of std::cout, std::cerr, and std::clog.
326#define _LIBCPP_AVAILABILITY_HAS_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18
327#define _LIBCPP_AVAILABILITY_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
328
329// This controls the availability of the C++20 time zone database.
330// The parser code is built in the library.
331#define _LIBCPP_AVAILABILITY_HAS_TZDB _LIBCPP_INTRODUCED_IN_LLVM_19
332#define _LIBCPP_AVAILABILITY_TZDB _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
333
334// These macros determine whether we assume that std::bad_function_call and
335// std::bad_expected_access provide a key function in the dylib. This allows
336// centralizing their vtable and typeinfo instead of having all TUs provide
337// a weak definition that then gets deduplicated.
338#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19
339#define _LIBCPP_AVAILABILITY_BAD_FUNCTION_CALL_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
340#define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19
341#define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
342
343// This controls the availability of floating-point std::from_chars functions.
344// These overloads were added later than the integer overloads.
345#define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20
346#define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE
347
348// This controls whether `std::__hash_memory` is available in the dylib, which
349// is used for some `std::hash` specializations.
350#define _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY _LIBCPP_INTRODUCED_IN_LLVM_21
351// No attribute, since we've had hash in the headers before
352
353// This controls whether we provide a message for `bad_function_call::what()` that specific to `std::bad_function_call`.
354// See https://wg21.link/LWG2233. This requires `std::bad_function_call::what()` to be available in the dylib.
355#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21
356// No attribute, since we've had bad_function_call::what() in the headers before
357
358// Define availability attributes that depend on both
359// _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI.
360#if !_LIBCPP_HAS_EXCEPTIONS || !_LIBCPP_HAS_RTTI
361# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
362# undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
363# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
364# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
365#endif
366
367#endif // _LIBCPP___CONFIGURATION_AVAILABILITY_H
368