|
8 | 8 | #include "swift/Runtime/Casting.h"
|
9 | 9 | #include "Runtime/Threading/ThreadLocal.h"
|
10 | 10 |
|
| 11 | +#include <Availability.h> |
| 12 | +#include <TargetConditionals.h> |
| 13 | + |
11 | 14 | #include <atomic>
|
12 | 15 | #include <new>
|
13 | 16 |
|
@@ -150,17 +153,38 @@ void swift::restoreTaskVoucher(AsyncTask *task) {
|
150 | 153 | static swift_once_t voucherDisableCheckOnce;
|
151 | 154 | static bool vouchersDisabled;
|
152 | 155 |
|
| 156 | +namespace { |
| 157 | + struct _SwiftNSOperatingSystemVersion{ |
| 158 | + intptr_t majorVersion; |
| 159 | + intptr_t minorVersion; |
| 160 | + intptr_t patchVersion; |
| 161 | + }; |
| 162 | +} |
| 163 | + |
| 164 | +extern "C" |
| 165 | +_SwiftNSOperatingSystemVersion |
| 166 | +_swift_stdlib_operatingSystemVersion() __attribute__((const)); |
| 167 | + |
153 | 168 | static void _initializeVouchersDisabled(void *ctxt) {
|
154 |
| - if (__builtin_available(macOS 12.1, iOS 15.2, tvOS 15.2, watchOS 8.3, *)) { |
155 |
| - // Concurrency library in the OS in new enough that it has voucher support. |
156 |
| - vouchersDisabled = false; |
157 |
| - } else if (__builtin_available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)) { |
158 |
| - // Concurrency library in the OS falls in the range that has no voucher support. |
159 |
| - vouchersDisabled = true; |
160 |
| - } else { |
161 |
| - // Concurrency library is back-deployed on this OS, and has voucher support. |
162 |
| - vouchersDisabled = false; |
163 |
| - } |
| 169 | + auto osVersion = _swift_stdlib_operatingSystemVersion(); |
| 170 | + #if TARGET_OS_WATCH |
| 171 | + vouchersDisabled = ( |
| 172 | + osVersion.majorVersion == 8 && |
| 173 | + osVersion.minorVersion >= 0 && osVersion.minorVersion < 3 |
| 174 | + ); |
| 175 | + #elif TARGET_OS_IPHONE |
| 176 | + vouchersDisabled = ( |
| 177 | + osVersion.majorVersion == 15 && |
| 178 | + osVersion.minorVersion >= 0 && osVersion.minorVersion < 2 |
| 179 | + ); |
| 180 | + #elif TARGET_OS_OSX |
| 181 | + vouchersDisabled = ( |
| 182 | + osVersion.majorVersion == 12 && |
| 183 | + osVersion.minorVersion >= 0 && osVersion.minorVersion < 1 |
| 184 | + ); |
| 185 | + #else |
| 186 | + vouchersDisabled = false; |
| 187 | + #endif |
164 | 188 | }
|
165 | 189 |
|
166 | 190 | bool VoucherManager::vouchersAreDisabled() {
|
|
0 commit comments