1 /*
2  * Copyright (c) 2008-2017 Apple Inc. All rights reserved.
3  *
4  * @APPLE_APACHE_LICENSE_HEADER_START@
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * @APPLE_APACHE_LICENSE_HEADER_END@
19  */
20 
21 #ifndef __OS_AVAILABILITY__
22 #define __OS_AVAILABILITY__
23 
24 /*
25  * API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated
26  * in an upcoming release. This soft deprecation is an intermediate step before formal
27  * deprecation to notify developers about the API before compiler warnings are generated.
28  * You can find all places in your code that use soft deprecated API by redefining the
29  * value of this macro to your current minimum deployment target, for example:
30  * (macOS)
31  *   clang -DAPI_TO_BE_DEPRECATED=10.12 <other compiler flags>
32  * (iOS)
33  *   clang -DAPI_TO_BE_DEPRECATED=11.0 <other compiler flags>
34  */
35 
36 #ifndef API_TO_BE_DEPRECATED
37 #define API_TO_BE_DEPRECATED 100000
38 #endif
39 
40 #include <AvailabilityInternal.h>
41 
42 
43 
44 #if defined(__has_feature) && defined(__has_attribute)
45  #if __has_attribute(availability)
46 
47     /*
48      * API Introductions
49      *
50      * Use to specify the release that a particular API became available.
51      *
52      * Platform names:
53      *   macos, ios, tvos, watchos
54      *
55      * Examples:
56      *    API_AVAILABLE(macos(10.10))
57      *    API_AVAILABLE(macos(10.9), ios(10.0))
58      *    API_AVAILABLE(macos(10.4), ios(8.0), watchos(2.0), tvos(10.0))
59      */
60 
61     #define API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE7, __API_AVAILABLE6, __API_AVAILABLE5, __API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1, 0)(__VA_ARGS__)
62 
63     #define API_AVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_AVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_AVAILABLE_BEGIN7,__API_AVAILABLE_BEGIN6, __API_AVAILABLE_BEGIN5, __API_AVAILABLE_BEGIN4, __API_AVAILABLE_BEGIN3, __API_AVAILABLE_BEGIN2, __API_AVAILABLE_BEGIN1, 0)(__VA_ARGS__)
64     #define API_AVAILABLE_END _Pragma("clang attribute pop")
65 
66     /*
67      * API Deprecations
68      *
69      * Use to specify the release that a particular API became unavailable.
70      *
71      * Platform names:
72      *   macos, ios, tvos, watchos
73      *
74      * Examples:
75      *
76      *    API_DEPRECATED("No longer supported", macos(10.4, 10.8))
77      *    API_DEPRECATED("No longer supported", macos(10.4, 10.8), ios(2.0, 3.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
78      *
79      *    API_DEPRECATED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4), ios(9.0, 10.0))
80      *    API_DEPRECATED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6), watchos(2.0, 3.0))
81      */
82 
83     #define API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG8,__API_DEPRECATED_MSG7, __API_DEPRECATED_MSG6,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1, 0)(__VA_ARGS__)
84     #define API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP8,__API_DEPRECATED_REP7, __API_DEPRECATED_REP6,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1, 0)(__VA_ARGS__)
85 
86     #define API_DEPRECATED_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_BEGIN_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_BEGIN_MSG8,__API_DEPRECATED_BEGIN_MSG7, __API_DEPRECATED_BEGIN_MSG6, __API_DEPRECATED_BEGIN_MSG5, __API_DEPRECATED_BEGIN_MSG4, __API_DEPRECATED_BEGIN_MSG3, __API_DEPRECATED_BEGIN_MSG2, __API_DEPRECATED_BEGIN_MSG1, 0)(__VA_ARGS__)
87     #define API_DEPRECATED_END _Pragma("clang attribute pop")
88 
89     #define API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_BEGIN_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_BEGIN_REP8,__API_DEPRECATED_BEGIN_REP7, __API_DEPRECATED_BEGIN_REP6, __API_DEPRECATED_BEGIN_REP5, __API_DEPRECATED_BEGIN_REP4, __API_DEPRECATED_BEGIN_REP3, __API_DEPRECATED_BEGIN_REP2, __API_DEPRECATED_BEGIN_REP1, 0)(__VA_ARGS__)
90     #define API_DEPRECATED_WITH_REPLACEMENT_END _Pragma("clang attribute pop")
91 
92 
93     /*
94      * API Unavailability
95      * Use to specify that an API is unavailable for a particular platform.
96      *
97      * Example:
98      *    API_UNAVAILABLE(macos)
99      *    API_UNAVAILABLE(watchos, tvos)
100      */
101 
102     #define API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE7,__API_UNAVAILABLE6, __API_UNAVAILABLE5, __API_UNAVAILABLE4,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1, 0)(__VA_ARGS__)
103 
104     #define API_UNAVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_UNAVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE_BEGIN7,__API_UNAVAILABLE_BEGIN6, __API_UNAVAILABLE_BEGIN5, __API_UNAVAILABLE_BEGIN4, __API_UNAVAILABLE_BEGIN3, __API_UNAVAILABLE_BEGIN2, __API_UNAVAILABLE_BEGIN1, 0)(__VA_ARGS__)
105     #define API_UNAVAILABLE_END _Pragma("clang attribute pop")
106  #else
107 
108     /*
109      * Evaluate to nothing for compilers that don't support availability.
110      */
111 
112      #define API_AVAILABLE(...)
113      #define API_AVAILABLE_BEGIN(...)
114      #define API_AVAILABLE_END
115      #define API_DEPRECATED(...)
116      #define API_DEPRECATED_WITH_REPLACEMENT(...)
117      #define API_DEPRECATED_BEGIN(...)
118      #define API_DEPRECATED_END
119      #define API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...)
120      #define API_DEPRECATED_WITH_REPLACEMENT_END
121      #define API_UNAVAILABLE(...)
122      #define API_UNAVAILABLE_BEGIN(...)
123      #define API_UNAVAILABLE_END
124  #endif /* __has_attribute(availability) */
125 #else
126 
127     /*
128      * Evaluate to nothing for compilers that don't support clang language extensions.
129      */
130 
131     #define API_AVAILABLE(...)
132     #define API_AVAILABLE_BEGIN(...)
133     #define API_AVAILABLE_END
134     #define API_DEPRECATED(...)
135     #define API_DEPRECATED_WITH_REPLACEMENT(...)
136     #define API_DEPRECATED_BEGIN(...)
137     #define API_DEPRECATED_END
138     #define API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...)
139     #define API_DEPRECATED_WITH_REPLACEMENT_END
140     #define API_UNAVAILABLE(...)
141     #define API_UNAVAILABLE_BEGIN(...)
142     #define API_UNAVAILABLE_END
143 #endif /* #if defined(__has_feature) && defined(__has_attribute) */
144 
145 #if __has_include(<AvailabilityProhibitedInternal.h>)
146   #include <AvailabilityProhibitedInternal.h>
147 #endif
148 
149 /*
150  * If SPI decorations have not been defined elsewhere, disable them.
151  */
152 
153 #ifndef SPI_AVAILABLE
154   #define SPI_AVAILABLE(...)
155 #endif
156 
157 #ifndef SPI_DEPRECATED
158   #define SPI_DEPRECATED(...)
159 #endif
160 
161 #ifndef SPI_DEPRECATED_WITH_REPLACEMENT
162   #define SPI_DEPRECATED_WITH_REPLACEMENT(...)
163 #endif
164 
165 #endif /* __OS_AVAILABILITY__ */