1 // Copyright (c) 2009-2011 Apple Inc. All rights reserved. 2 3 #ifndef __XPC_BASE_H__ 4 #define __XPC_BASE_H__ 5 6 #include <sys/cdefs.h> 7 8 __BEGIN_DECLS 9 10 #if !defined(__has_include) 11 #define __has_include(x) 0 12 #endif // !defined(__has_include) 13 14 #if !defined(__has_attribute) 15 #define __has_attribute(x) 0 16 #endif // !defined(__has_attribute) 17 18 #if __has_include(<xpc/availability.h>) 19 #include <xpc/availability.h> 20 #else // __has_include(<xpc/availability.h>) 21 #include <Availability.h> 22 #define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING(version) 23 #endif // __has_include(<xpc/availability.h>) 24 25 #if XPC_SERVICE_MAIN_IN_LIBXPC 26 #define XPC_HOSTING_OLD_MAIN 1 27 #else // XPC_SERVICE_MAIN_IN_LIBXPC 28 #define XPC_HOSTING_OLD_MAIN 0 29 #endif // XPC_SERVICE_MAIN_IN_LIBXPC 30 31 #ifndef __XPC_INDIRECT__ 32 #error "Please #include <xpc/xpc.h> instead of this file directly." 33 #endif // __XPC_INDIRECT__ 34 35 #pragma mark Attribute Shims 36 #ifdef __GNUC__ 37 #define XPC_CONSTRUCTOR __attribute__((constructor)) 38 #define XPC_NORETURN __attribute__((__noreturn__)) 39 #define XPC_NOTHROW __attribute__((__nothrow__)) 40 #define XPC_NONNULL1 __attribute__((__nonnull__(1))) 41 #define XPC_NONNULL2 __attribute__((__nonnull__(2))) 42 #define XPC_NONNULL3 __attribute__((__nonnull__(3))) 43 #define XPC_NONNULL4 __attribute__((__nonnull__(4))) 44 #define XPC_NONNULL5 __attribute__((__nonnull__(5))) 45 #define XPC_NONNULL6 __attribute__((__nonnull__(6))) 46 #define XPC_NONNULL7 __attribute__((__nonnull__(7))) 47 #define XPC_NONNULL8 __attribute__((__nonnull__(8))) 48 #define XPC_NONNULL9 __attribute__((__nonnull__(9))) 49 #define XPC_NONNULL10 __attribute__((__nonnull__(10))) 50 #define XPC_NONNULL11 __attribute__((__nonnull__(11))) 51 #define XPC_NONNULL_ALL __attribute__((__nonnull__)) 52 #define XPC_SENTINEL __attribute__((__sentinel__)) 53 #define XPC_PURE __attribute__((__pure__)) 54 #define XPC_WARN_RESULT __attribute__((__warn_unused_result__)) 55 #define XPC_MALLOC __attribute__((__malloc__)) 56 #define XPC_UNUSED __attribute__((__unused__)) 57 #define XPC_USED __attribute__((__used__)) 58 #define XPC_PACKED __attribute__((__packed__)) 59 #define XPC_PRINTF(m, n) __attribute__((format(printf, m, n))) 60 #define XPC_INLINE static __inline__ __attribute__((__always_inline__)) 61 #define XPC_NOINLINE __attribute__((noinline)) 62 #define XPC_NOIMPL __attribute__((unavailable)) 63 64 #if __has_extension(attribute_unavailable_with_message) 65 #define XPC_UNAVAILABLE(m) __attribute__((unavailable(m))) 66 #else // __has_extension(attribute_unavailable_with_message) 67 #define XPC_UNAVAILABLE(m) XPC_NOIMPL 68 #endif // __has_extension(attribute_unavailable_with_message) 69 70 #define XPC_EXPORT extern __attribute__((visibility("default"))) 71 #define XPC_NOEXPORT __attribute__((visibility("hidden"))) 72 #define XPC_WEAKIMPORT extern __attribute__((weak_import)) 73 #define XPC_DEBUGGER_EXCL XPC_NOEXPORT XPC_USED 74 #define XPC_TRANSPARENT_UNION __attribute__((transparent_union)) 75 #if __clang__ 76 #define XPC_DEPRECATED(m) __attribute__((deprecated(m))) 77 #else // __clang__ 78 #define XPC_DEPRECATED(m) __attribute__((deprecated)) 79 #endif // __clang 80 81 #if __has_feature(objc_arc) 82 #define XPC_GIVES_REFERENCE __strong 83 #define XPC_UNRETAINED __unsafe_unretained 84 #define XPC_BRIDGE(xo) ((__bridge void *)(xo)) 85 #define XPC_BRIDGEREF_BEGIN(xo) ((__bridge_retained void *)(xo)) 86 #define XPC_BRIDGEREF_BEGIN_WITH_REF(xo) ((__bridge void *)(xo)) 87 #define XPC_BRIDGEREF_MIDDLE(xo) ((__bridge id)(xo)) 88 #define XPC_BRIDGEREF_END(xo) ((__bridge_transfer id)(xo)) 89 #else // __has_feature(objc_arc) 90 #define XPC_GIVES_REFERENCE 91 #define XPC_UNRETAINED 92 #define XPC_BRIDGE(xo) 93 #define XPC_BRIDGEREF_BEGIN(xo) (xo) 94 #define XPC_BRIDGEREF_BEGIN_WITH_REF(xo) (xo) 95 #define XPC_BRIDGEREF_MIDDLE(xo) (xo) 96 #define XPC_BRIDGEREF_END(xo) (xo) 97 #endif // __has_feature(objc_arc) 98 99 #define _xpc_unreachable() __builtin_unreachable() 100 #else // __GNUC__ 101 /*! @parseOnly */ 102 #define XPC_CONSTRUCTOR 103 /*! @parseOnly */ 104 #define XPC_NORETURN 105 /*! @parseOnly */ 106 #define XPC_NOTHROW 107 /*! @parseOnly */ 108 #define XPC_NONNULL1 109 /*! @parseOnly */ 110 #define XPC_NONNULL2 111 /*! @parseOnly */ 112 #define XPC_NONNULL3 113 /*! @parseOnly */ 114 #define XPC_NONNULL4 115 /*! @parseOnly */ 116 #define XPC_NONNULL5 117 /*! @parseOnly */ 118 #define XPC_NONNULL6 119 /*! @parseOnly */ 120 #define XPC_NONNULL7 121 /*! @parseOnly */ 122 #define XPC_NONNULL8 123 /*! @parseOnly */ 124 #define XPC_NONNULL9 125 /*! @parseOnly */ 126 #define XPC_NONNULL10 127 /*! @parseOnly */ 128 #define XPC_NONNULL11 129 /*! @parseOnly */ 130 #define XPC_NONNULL(n) 131 /*! @parseOnly */ 132 #define XPC_NONNULL_ALL 133 /*! @parseOnly */ 134 #define XPC_SENTINEL 135 /*! @parseOnly */ 136 #define XPC_PURE 137 /*! @parseOnly */ 138 #define XPC_WARN_RESULT 139 /*! @parseOnly */ 140 #define XPC_MALLOC 141 /*! @parseOnly */ 142 #define XPC_UNUSED 143 /*! @parseOnly */ 144 #define XPC_PACKED 145 /*! @parseOnly */ 146 #define XPC_PRINTF(m, n) 147 /*! @parseOnly */ 148 #define XPC_INLINE static inline 149 /*! @parseOnly */ 150 #define XPC_NOINLINE 151 /*! @parseOnly */ 152 #define XPC_NOIMPL 153 /*! @parseOnly */ 154 #define XPC_EXPORT extern 155 /*! @parseOnly */ 156 #define XPC_WEAKIMPORT 157 /*! @parseOnly */ 158 #define XPC_DEPRECATED 159 /*! @parseOnly */ 160 #define XPC_UNAVAILABLE(m) 161 #endif // __GNUC__ 162 163 __END_DECLS 164 165 #endif // __XPC_BASE_H__ 166