]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/corecrypto/cc_config.h
5 * Created by Michael Brouwer on 10/18/10.
6 * Copyright 2010,2011 Apple Inc. All rights reserved.
10 #ifndef _CORECRYPTO_CC_CONFIG_H_
11 #define _CORECRYPTO_CC_CONFIG_H_
13 /* A word about configuration macros:
15 Conditional configuration macros specific to corecrypto should be named CORECRYPTO_xxx
16 or CCxx_yyy and be defined to be either 0 or 1 in this file. You can add an
17 #ifndef #error construct at the end of this file to make sure it's always defined.
19 They should always be tested using the #if directive, never the #ifdef directive.
21 No other conditional macros shall ever be used (except in this file)
23 Configuration Macros that are defined outside of corecrypto (eg: KERNEL, DEBUG, ...)
24 shall only be used in this file to define CCxxx macros.
26 External macros should be assumed to be either undefined, defined with no value,
27 or defined as true or false. We shall strive to build with -Wundef whenever possible,
28 so the following construct should be used to test external macros in this file:
30 #if defined(DEBUG) && (DEBUG)
31 #define CORECRYPTO_DEBUG 1
33 #define CORECRYPTO_DEBUG 0
37 It is acceptable to define a conditional CC_xxxx macro in an implementation file,
38 to be used only in this file.
40 The current code is not guaranteed to follow those rules, but should be fixed to.
42 Corecrypto requires GNU and C99 compatibility.
43 Typically enabled by passing --gnu --c99 to the compiler (eg. armcc)
47 #if defined(DEBUG) && (DEBUG)
48 /* CC_DEBUG is already used in CommonCrypto */
49 #define CORECRYPTO_DEBUG 1
51 #define CORECRYPTO_DEBUG 0
54 #if defined(KERNEL) && (KERNEL)
60 #if defined(USE_L4) && (USE_L4)
66 #if defined(MAVERICK) && (MAVERICK)
72 #if defined(IBOOT) && (IBOOT)
82 #if defined(ENDIAN_LITTLE) || (defined(__arm__) && !defined(__BIG_ENDIAN))
83 #define __LITTLE_ENDIAN__
84 #elif !defined(ENDIAN_BIG) && !defined(__BIG_ENDIAN)
85 #error Baseband endianess not defined.
87 #define AESOPT_ENDIAN_NO_FILE
90 #define CCN_UNIT_SIZE 4 // 32 bits
91 #define aligned(x) aligned((x)>8?8:(x)) // Alignment on 8 bytes max
92 #define SAFE_IO // AES support for unaligned Input/Output
94 // -- External function
95 #define assert ASSERT // sanity
98 // Ignore irrelevant warnings after verification
99 // #1254-D: arithmetic on pointer to void or function type
100 // #186-D: pointless comparison of unsigned integer with zero
101 // #546-D: transfer of control bypasses initialization of
102 #if defined(__GNUC__)
103 // warning: pointer of type 'void *' used in arithmetic
104 #pragma GCC diagnostic ignored "-Wpointer-arith"
105 #endif // arm or gnuc
109 #if !defined(CCN_UNIT_SIZE)
110 #if defined(__arm64__) || defined(__x86_64__)
111 #define CCN_UNIT_SIZE 8
112 #elif defined(__arm__) || defined(__i386__)
113 #define CCN_UNIT_SIZE 4
115 #define CCN_UNIT_SIZE 2
117 #endif /* !defined(CCN_UNIT_SIZE) */
119 #if defined(__x86_64__) || defined(__i386__)
124 /* No dynamic linking allowed in L4, e.g. avoid nonlazy symbols */
125 /* For corecrypto kext, CC_STATIC should be 0 */
130 /* L4 do not have bzero, neither does hexagon of ARMCC even with gnu compatibility mode */
131 #if CC_USE_L4 || defined(__CC_ARM) || defined(__hexagon__)
132 #define CC_HAS_BZERO 0
134 #define CC_HAS_BZERO 1
137 #if defined(__CC_ARM) || defined(__hexagon__)
138 // ARMASM.exe does not to like the file syntax of the asm implementation
140 #define CCN_ADD_ASM 0
141 #define CCN_SUB_ASM 0
142 #define CCN_MUL_ASM 0
143 #define CCN_ADDMUL1_ASM 0
144 #define CCN_MUL1_ASM 0
145 #define CCN_CMP_ASM 0
146 #define CCN_ADD1_ASM 0
147 #define CCN_SUB1_ASM 0
149 #define CCN_SET_ASM 0
151 #define CCAES_INTEL 0
152 #define CCN_USE_BUILTIN_CLZ 0
153 #define CCSHA1_VNG_INTEL 0
154 #define CCSHA2_VNG_INTEL 0
156 #elif defined(__x86_64__) || defined(__i386__)
158 /* These assembly routines only work for a single CCN_UNIT_SIZE. */
159 #if (defined(__x86_64__) && CCN_UNIT_SIZE == 8) || (defined(__i386__) && CCN_UNIT_SIZE == 4)
160 #define CCN_ADD_ASM 1
161 #define CCN_SUB_ASM 1
162 #define CCN_MUL_ASM 1
164 #define CCN_ADD_ASM 0
165 #define CCN_SUB_ASM 0
166 #define CCN_MUL_ASM 0
169 #define CCN_ADDMUL1_ASM 0
170 #define CCN_MUL1_ASM 0
171 #define CCN_CMP_ASM 0
172 #define CCN_ADD1_ASM 0
173 #define CCN_SUB1_ASM 0
175 #define CCN_SET_ASM 0
177 #define CCAES_INTEL 1
179 #define CCN_USE_BUILTIN_CLZ 0
180 #define CCSHA1_VNG_INTEL 1
181 #define CCSHA2_VNG_INTEL 1
182 #define CCSHA1_VNG_ARMV7NEON 0
183 #define CCSHA2_VNG_ARMV7NEON 0
187 #define CCN_ADD_ASM 0
188 #define CCN_SUB_ASM 0
189 #define CCN_MUL_ASM 0
190 #define CCN_ADDMUL1_ASM 0
191 #define CCN_MUL1_ASM 0
192 #define CCN_CMP_ASM 0
193 #define CCN_ADD1_ASM 0
194 #define CCN_SUB1_ASM 0
196 #define CCN_SET_ASM 0
198 #define CCAES_INTEL 0
200 #define CCN_USE_BUILTIN_CLZ 0
201 #define CCSHA1_VNG_INTEL 0
202 #define CCSHA2_VNG_INTEL 0
203 #define CCSHA1_VNG_ARMV7NEON 0
204 #define CCSHA2_VNG_ARMV7NEON 0
206 #endif /* !defined(__i386__) */
208 #define CCN_N_INLINE 0
209 #define CCN_CMP_INLINE 0
211 #define CC_INLINE static inline
214 #define CC_NORETURN __attribute__((__noreturn__))
215 #define CC_NOTHROW __attribute__((__nothrow__))
217 #if defined(__CC_ARM) || defined(__hexagon__)
218 #define CC_NONNULL_TU(N)
220 #define CC_NONNULL_TU(N) __attribute__((__nonnull__ N))
222 #define CC_NONNULL(N) __attribute__((__nonnull__ N))
223 #define CC_NONNULL1 __attribute__((__nonnull__(1)))
224 #define CC_NONNULL2 __attribute__((__nonnull__(2)))
225 #define CC_NONNULL3 __attribute__((__nonnull__(3)))
226 #define CC_NONNULL4 __attribute__((__nonnull__(4)))
227 #define CC_NONNULL5 __attribute__((__nonnull__(5)))
228 #define CC_NONNULL6 __attribute__((__nonnull__(6)))
229 #define CC_NONNULL7 __attribute__((__nonnull__(7)))
230 #define CC_NONNULL_ALL __attribute__((__nonnull__))
231 #define CC_SENTINEL __attribute__((__sentinel__))
232 #define CC_CONST __attribute__((__const__))
233 #define CC_PURE __attribute__((__pure__))
234 #define CC_WARN_RESULT __attribute__((__warn_unused_result__))
235 #define CC_MALLOC __attribute__((__malloc__))
236 #define CC_UNUSED __attribute__((unused))
237 #else /* !__GNUC__ */
241 #define CC_NONNULL_TU(N)
243 #define CC_NONNULL(N)
263 #define CC_NONNULL_ALL
271 #define CC_WARN_RESULT
274 #endif /* !__GNUC__ */
276 #endif /* _CORECRYPTO_CC_CONFIG_H_ */