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