1 /*! 2 * @header 3 * Umbrella header for Image4 trust evaluation API. 4 */ 5 #ifndef __IMAGE4_API_H 6 #define __IMAGE4_API_H 7 8 /*! 9 * @const IMAGE4_API_VERSION 10 * The API version of the library. This version will be changed in accordance 11 * with new API introductions so that callers may submit code to the build that 12 * adopts those new APIs before the APIs land by using the following pattern: 13 * 14 * #if IMAGE4_API_VERSION >= 20221230 15 * image4_new_api(); 16 * #endif 17 * 18 * In this example, the library maintainer and API adopter agree on an API 19 * version of 20221230 ahead of time for the introduction of 20 * image4_new_api(). When a libdarwin with that API version is submitted, the 21 * project is rebuilt, and the new API becomes active. 22 * 23 * Breaking API changes will be both covered under this mechanism as well as 24 * individual preprocessor macros in this header that declare new behavior as 25 * required. 26 */ 27 #define IMAGE4_API_VERSION (20231216u) 28 29 #if __has_include(<os/base.h>) 30 #include <os/base.h> 31 #else 32 #include <image4/shim/base.h> 33 #endif 34 35 #if __has_include(<sys/types.h>) 36 #include <sys/types.h> 37 38 #if !defined(_ERRNO_T) 39 typedef int errno_t; 40 #endif // !defined(_ERRNO_T) 41 #else 42 #include <image4/shim/types.h> 43 #endif 44 45 #if __has_include(<TargetConditionals.h>) 46 #include <TargetConditionals.h> 47 #endif 48 49 #if __has_include(<os/availability.h>) 50 #include <os/availability.h> 51 #endif 52 53 #if __has_include(<sys/cdefs.h>) 54 #include <sys/cdefs.h> 55 #endif 56 57 #if !defined(__BEGIN_DECLS) 58 #if defined(__cplusplus) 59 #define __BEGIN_DECLS extern "C" { 60 #define __END_DECLS } 61 #else 62 #define __BEGIN_DECLS 63 #define __END_DECLS 64 #endif 65 #endif 66 67 #if !defined(__static_size) 68 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && __GNUC__ 69 #define __static_size static 70 #define __static_size_const static const 71 #else 72 #define __static_size 73 #define __static_size_const 74 #endif 75 #endif // !defined(__static_size) 76 77 /*! 78 * @brief 79 * Pass -DIMAGE4_STRIP_AVAILABILITY=1 if the build environment is picking up a 80 * definition of API_AVAILABLE from somewhere, e.g. an old shim header or from 81 * inappropriately-injected header search paths. 82 */ 83 #if !defined(API_AVAILABLE) || IMAGE4_STRIP_AVAILABILITY 84 #undef API_AVAILABLE 85 #define API_AVAILABLE(...) 86 #endif 87 88 #if XNU_KERNEL_PRIVATE 89 #if !defined(__IMAGE4_XNU_INDIRECT) 90 #error "Please include <libkern/image4/dlxk.h> instead of this header" 91 #endif 92 #endif 93 94 /*! 95 * @const IMAGE4_API_AVAILABLE_SPRING_2024 96 * APIs which first became available in the Spring 2024 set of releases. 97 */ 98 #define IMAGE4_API_AVAILABLE_SPRING_2024 \ 99 API_AVAILABLE( \ 100 macos(14.3), \ 101 ios(17.4), \ 102 tvos(17.4), \ 103 watchos(10.4), \ 104 bridgeos(8.3)) 105 106 /*! 107 * @const IMAGE4_XNU_AVAILABLE_DIRECT 108 * API symbol which is available to xnu via the dlxk mechanism. 109 */ 110 #if XNU_KERNEL_PRIVATE || IMAGE4_DLXK_AVAILABILITY 111 #define IMAGE4_XNU_AVAILABLE_DIRECT(_s) typedef typeof(&_s) _ ## _s ## _dlxk_t 112 #else 113 #define IMAGE4_XNU_AVAILABLE_DIRECT(_s) 114 #endif 115 116 /*! 117 * @const IMAGE4_XNU_AVAILABLE_INDIRECT 118 * API symbol which is accessed through a macro and is available to xnu via the 119 * dlxk mechanism. 120 */ 121 #if XNU_KERNEL_PRIVATE || IMAGE4_DLXK_AVAILABILITY 122 #define IMAGE4_XNU_AVAILABLE_INDIRECT(_s) typedef typeof(&_s) _s ## _dlxk_t 123 #else 124 #define IMAGE4_XNU_AVAILABLE_INDIRECT(_s) 125 #endif 126 127 #endif // __IMAGE4_API_H 128