base.h (6690B) - Raw
1 /*! @header 2 * This header defines macros used in the implementation of <simd/simd.h> 3 * types and functions. Even though they are exposed in a public header, 4 * the macros defined in this header are implementation details, and you 5 * should not use or rely on them. They may be changed or removed entirely 6 * in a future release. 7 * 8 * @copyright 2016-2017 Apple, Inc. All rights reserved. 9 * @unsorted */ 10 11 #ifndef SIMD_BASE 12 #define SIMD_BASE 13 14 /* Define __has_attribute and __has_include if they aren't available */ 15 # ifndef __has_attribute 16 # define __has_attribute(__x) 0 17 # endif 18 # ifndef __has_include 19 # define __has_include(__x) 0 20 # endif 21 # ifndef __has_feature 22 # define __has_feature(__x) 0 23 # endif 24 25 # if __has_attribute(__ext_vector_type__) && __has_attribute(__overloadable__) 26 # define SIMD_COMPILER_HAS_REQUIRED_FEATURES 1 27 # else 28 /* Your compiler is missing one or more features that are hard requirements 29 * for any <simd/simd.h> support. None of the types or functions defined by 30 * the simd headers will be available. */ 31 # define SIMD_COMPILER_HAS_REQUIRED_FEATURES 0 32 # endif 33 34 # if SIMD_COMPILER_HAS_REQUIRED_FEATURES 35 # define SIMD_CURRENT_LIBRARY_VERSION 6 36 # if __has_include(<TargetConditionals.h>) && __has_include(<Availability.h>) 37 # include <TargetConditionals.h> 38 # include <Availability.h> 39 /* A number of new features are added in newer releases; most of these are 40 * inline in the header, which makes them available even when targeting older 41 * OS versions. Those that make external calls, however, are only available 42 * when targeting the release in which they became available. Because of the 43 * way in which simd functions are overloaded, the usual weak-linking tricks 44 * do not work; these functions are simply unavailable when targeting older 45 * versions of the library. */ 46 # if TARGET_OS_RTKIT 47 # define SIMD_LIBRARY_VERSION SIMD_CURRENT_LIBRARY_VERSION 48 # elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_15_0 || \ 49 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_18_0 || \ 50 __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_11_0 || \ 51 __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_18_0 || \ 52 __XR_OS_VERSION_MIN_REQUIRED >= __XROS_2_0 || \ 53 __BRIDGE_OS_VERSION_MIN_REQUIRED >= __BRIDGEOS_9_0 || \ 54 __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_24_0 55 # define SIMD_LIBRARY_VERSION 6 56 # elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 || \ 57 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_16_0 || \ 58 __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_9_0 || \ 59 __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_16_0 || \ 60 __BRIDGE_OS_VERSION_MIN_REQUIRED >= __BRIDGEOS_7_0 || \ 61 __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_22_0 62 # define SIMD_LIBRARY_VERSION 5 63 # elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_0 || \ 64 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_15_0 || \ 65 __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_8_0 || \ 66 __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_15_0 || \ 67 __BRIDGE_OS_VERSION_MIN_REQUIRED >= __BRIDGEOS_6_0 || \ 68 __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_21_0 69 # define SIMD_LIBRARY_VERSION 4 70 # elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13 || \ 71 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_11_0 || \ 72 __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_4_0 || \ 73 __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_11_0 || \ 74 __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_19_0 75 # define SIMD_LIBRARY_VERSION 3 76 # elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12 || \ 77 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0 || \ 78 __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0 || \ 79 __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0 80 # define SIMD_LIBRARY_VERSION 2 81 # elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || \ 82 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 83 # define SIMD_LIBRARY_VERSION 1 84 # else 85 # define SIMD_LIBRARY_VERSION 0 86 # endif 87 # else /* !__has_include(<TargetContidionals.h>) && __has_include(<Availability.h>) */ 88 # define SIMD_LIBRARY_VERSION SIMD_CURRENT_LIBRARY_VERSION 89 # define __API_AVAILABLE(...) /* Nothing */ 90 # endif 91 92 /* The simd types interoperate with the native simd intrinsic types for each 93 * architecture; the headers that define those types and operations are 94 * automatically included with simd.h */ 95 # if defined __ARM_NEON 96 # include <arm_neon.h> 97 # elif defined __i386__ || defined __x86_64__ 98 # include <immintrin.h> 99 # endif 100 101 /* Define a number of function attributes used by the simd functions. */ 102 # if __has_attribute(__always_inline__) 103 # define SIMD_INLINE __attribute__((__always_inline__)) 104 # else 105 # define SIMD_INLINE inline 106 # endif 107 108 # if __has_attribute(__const__) 109 # define SIMD_CONST __attribute__((__const__)) 110 # else 111 # define SIMD_CONST /* nothing */ 112 # endif 113 114 # if __has_attribute(__nodebug__) 115 # define SIMD_NODEBUG __attribute__((__nodebug__)) 116 # else 117 # define SIMD_NODEBUG /* nothing */ 118 # endif 119 120 # if __has_attribute(__deprecated__) 121 # define SIMD_DEPRECATED(message) __attribute__((__deprecated__(message))) 122 # else 123 # define SIMD_DEPRECATED(message) /* nothing */ 124 # endif 125 126 #define SIMD_OVERLOAD __attribute__((__overloadable__)) 127 #define SIMD_CPPFUNC SIMD_INLINE SIMD_CONST SIMD_NODEBUG 128 #define SIMD_CFUNC SIMD_CPPFUNC SIMD_OVERLOAD 129 #define SIMD_NOINLINE SIMD_CONST SIMD_NODEBUG SIMD_OVERLOAD 130 #define SIMD_NONCONST SIMD_INLINE SIMD_NODEBUG SIMD_OVERLOAD 131 #define __SIMD_INLINE__ SIMD_CPPFUNC 132 #define __SIMD_ATTRIBUTES__ SIMD_CFUNC 133 #define __SIMD_OVERLOAD__ SIMD_OVERLOAD 134 135 # if __has_feature(cxx_constexpr) 136 # define SIMD_CONSTEXPR constexpr 137 # else 138 # define SIMD_CONSTEXPR /* nothing */ 139 # endif 140 141 # if __has_feature(cxx_noexcept) 142 # define SIMD_NOEXCEPT noexcept 143 # else 144 # define SIMD_NOEXCEPT /* nothing */ 145 # endif 146 147 #if defined __cplusplus 148 /*! @abstract A boolean scalar. */ 149 typedef bool simd_bool; 150 #else 151 /*! @abstract A boolean scalar. */ 152 typedef _Bool simd_bool; 153 #endif 154 /*! @abstract A boolean scalar. 155 * @discussion This type is deprecated; In C or Objective-C sources, use 156 * `_Bool` instead. In C++ sources, use `bool`. */ 157 typedef simd_bool __SIMD_BOOLEAN_TYPE__; 158 159 # endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ 160 #endif /* defined SIMD_BASE */