]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/corecrypto/cc_runtime_config.h
5 * Created on 09/18/2012
7 * Copyright (c) 2012,2014,2015 Apple Inc. All rights reserved.
11 #ifndef CORECRYPTO_CC_RUNTIME_CONFIG_H_
12 #define CORECRYPTO_CC_RUNTIME_CONFIG_H_
14 #include <corecrypto/cc_config.h>
16 /* Only intel systems have these runtime switches today. */
18 #if defined(__x86_64__) || defined(__i386__)
21 #include <i386/cpuid.h>
22 #define CC_HAS_RDRAND() ((cpuid_features() & CPUID_FEATURE_RDRAND) != 0)
23 #elif CC_XNU_KERNEL_AVAILABLE
24 #include <System/i386/cpu_capabilities.h>
26 extern int _cpu_capabilities
;
27 #define CC_HAS_RDRAND() (_cpu_capabilities & kHasRDRAND)
29 #define CC_HAS_RDRAND() 0
32 #if (CCSHA1_VNG_INTEL || CCSHA2_VNG_INTEL || CCAES_INTEL_ASM)
35 #include <i386/cpuid.h>
36 #define CC_HAS_AESNI() ((cpuid_features() & CPUID_FEATURE_AES) != 0)
37 #define CC_HAS_SupplementalSSE3() ((cpuid_features() & CPUID_FEATURE_SSSE3) != 0)
38 #define CC_HAS_AVX1() ((cpuid_features() & CPUID_FEATURE_AVX1_0) != 0)
39 #define CC_HAS_AVX2() ((cpuid_info()->cpuid_leaf7_features & CPUID_LEAF7_FEATURE_AVX2) != 0)
40 #define CC_HAS_AVX512_AND_IN_KERNEL() ((cpuid_info()->cpuid_leaf7_features & CPUID_LEAF7_FEATURE_AVX512F) !=0)
42 #elif CC_XNU_KERNEL_AVAILABLE
43 #include <System/i386/cpu_capabilities.h>
45 extern int _cpu_capabilities
;
46 #define CC_HAS_AESNI() (_cpu_capabilities & kHasAES)
47 #define CC_HAS_SupplementalSSE3() (_cpu_capabilities & kHasSupplementalSSE3)
48 #define CC_HAS_AVX1() (_cpu_capabilities & kHasAVX1_0)
49 #define CC_HAS_AVX2() (_cpu_capabilities & kHasAVX2_0)
50 #define CC_HAS_AVX512_AND_IN_KERNEL() 0
52 #define CC_HAS_AESNI() 0
53 #define CC_HAS_SupplementalSSE3() 0
54 #define CC_HAS_AVX1() 0
55 #define CC_HAS_AVX2() 0
56 #define CC_HAS_AVX512_AND_IN_KERNEL() 0
59 #endif // (CCSHA1_VNG_INTEL || CCSHA2_VNG_INTEL || CCAES_INTEL_ASM)
61 #endif // defined(__x86_64__) || defined(__i386__)
63 #endif /* CORECRYPTO_CC_RUNTIME_CONFIG_H_ */