1 // 2 // Copyright 2019 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // apple_platform_utils.h: Common utilities for Apple platforms. 8 9 #ifndef COMMON_APPLE_PLATFORM_UTILS_H_ 10 #define COMMON_APPLE_PLATFORM_UTILS_H_ 11 12 #include "common/platform.h" 13 14 // These are macros for substitution of Apple specific directive @available: 15 16 // TARGET_OS_MACCATALYST only available in MacSDK 10.15 17 18 #if TARGET_OS_MACCATALYST 19 // ANGLE_APPLE_AVAILABLE_XCI: check if either of the 3 platforms (OSX/Catalyst/iOS) min verions is 20 // available: 21 # define ANGLE_APPLE_AVAILABLE_XCI(macVer, macCatalystVer, iOSVer) \ 22 @available(macOS macVer, macCatalyst macCatalystVer, iOS iOSVer, *) 23 // ANGLE_APPLE_AVAILABLE_XC: check if either of the 2 platforms (OSX/Catalyst) min verions is 24 // available: 25 # define ANGLE_APPLE_AVAILABLE_XC(macVer, macCatalystVer) \ 26 @available(macOS macVer, macCatalyst macCatalystVer, *) 27 // ANGLE_APPLE_AVAILABLE_CI: check if either of the 2 platforms (Catalyst/iOS) min verions is 28 // available: 29 # define ANGLE_APPLE_AVAILABLE_CI(macCatalystVer, iOSVer) \ 30 @available(macCatalyst macCatalystVer, iOS iOSVer, *) 31 #else 32 # define ANGLE_APPLE_AVAILABLE_XCI(macVer, macCatalystVer, iOSVer) \ 33 ANGLE_APPLE_AVAILABLE_XI(macVer, iOSVer) 34 35 # define ANGLE_APPLE_AVAILABLE_XC(macVer, macCatalystVer) @available(macOS macVer, *) 36 # define ANGLE_APPLE_AVAILABLE_CI(macCatalystVer, iOSVer) @available(iOS iOSVer, tvOS iOSVer, *) 37 #endif 38 39 // ANGLE_APPLE_AVAILABLE_XI: check if either of the 2 platforms (OSX/iOS) min verions is available: 40 #define ANGLE_APPLE_AVAILABLE_XI(macVer, iOSVer) \ 41 @available(macOS macVer, iOS iOSVer, tvOS iOSVer, *) 42 43 // ANGLE_APPLE_AVAILABLE_I: check if a particular iOS version is available 44 #define ANGLE_APPLE_AVAILABLE_I(iOSVer) @available(iOS iOSVer, tvOS iOSVer, *) 45 46 #if TARGET_OS_IPHONE 47 # if !defined(__IPHONE_11_0) 48 # define __IPHONE_11_0 110000 49 # endif 50 # if !defined(ANGLE_IOS_DEPLOY_TARGET) 51 # define ANGLE_IOS_DEPLOY_TARGET __IPHONE_11_0 52 # endif 53 # if !defined(__IPHONE_OS_VERSION_MAX_ALLOWED) 54 # define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_11_0 55 # endif 56 # if !defined(__TV_OS_VERSION_MAX_ALLOWED) 57 # define __TV_OS_VERSION_MAX_ALLOWED __IPHONE_11_0 58 # endif 59 #endif 60 61 #if !defined(TARGET_OS_MACCATALYST) 62 # define TARGET_OS_MACCATALYST 0 63 #endif 64 65 #if defined(__ARM_ARCH) 66 # define ANGLE_APPLE_IS_ARM (__ARM_ARCH != 0) 67 #else 68 # define ANGLE_APPLE_IS_ARM 0 69 #endif 70 71 #define ANGLE_APPLE_OBJC_SCOPE @autoreleasepool 72 73 #if !__has_feature(objc_arc) 74 # define ANGLE_APPLE_AUTORELEASE autorelease 75 # define ANGLE_APPLE_RETAIN retain 76 # define ANGLE_APPLE_RELEASE release 77 #else 78 # define ANGLE_APPLE_AUTORELEASE self 79 # define ANGLE_APPLE_RETAIN self 80 # define ANGLE_APPLE_RELEASE self 81 #endif 82 83 #define ANGLE_APPLE_UNUSED __attribute__((unused)) 84 85 #if __has_warning("-Wdeprecated-declarations") 86 # define ANGLE_APPLE_ALLOW_DEPRECATED_BEGIN \ 87 _Pragma("GCC diagnostic push") \ 88 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 89 #else 90 # define ANGLE_APPLE_ALLOW_DEPRECATED_BEGIN 91 #endif 92 93 #if __has_warning("-Wdeprecated-declarations") 94 # define ANGLE_APPLE_ALLOW_DEPRECATED_END _Pragma("GCC diagnostic pop") 95 #else 96 # define ANGLE_APPLE_ALLOW_DEPRECATED_END 97 #endif 98 99 namespace angle 100 { 101 bool IsMetalRendererAvailable(); 102 } 103 104 #endif 105