60 #if !defined(OPENSSL_NO_ASM) && (defined(OPENSSL_X86) || defined(OPENSSL_X86_64))
69 #include <immintrin.h>
84 __cpuid(
tmp, (
int)leaf);
89 #elif defined(__pic__) && defined(OPENSSL_32_BIT)
97 :
"=a"(*out_eax),
"=D"(*out_ebx),
"=c"(*out_ecx),
"=d"(*out_edx)
104 :
"=a"(*out_eax),
"=b"(*out_ebx),
"=c"(*out_ecx),
"=d"(*out_edx)
113 #if defined(_MSC_VER)
117 __asm__
volatile (
"xgetbv" :
"=a"(eax),
"=d"(edx) :
"c"(xcr));
118 return (((
uint64_t)edx) << 32) | eax;
125 const int invert =
in[0] ==
'~';
126 const int or =
in[0] ==
'|';
127 const int skip_first_byte = invert || or;
128 const int hex =
in[skip_first_byte] ==
'0' &&
in[skip_first_byte+1] ==
'x';
133 sscanf_result = sscanf(
in + invert + 2,
"%" PRIx64, &
v);
135 sscanf_result = sscanf(
in + invert,
"%" PRIu64, &
v);
138 if (!sscanf_result) {
144 out[1] &= ~(
v >> 32);
157 OPENSSL_cpuid(&eax, &ebx, &ecx, &edx, 0);
161 int is_intel = ebx == 0x756e6547 &&
164 int is_amd = ebx == 0x68747541 &&
168 uint32_t extended_features[2] = {0};
170 OPENSSL_cpuid(&eax, &ebx, &ecx, &edx, 7);
171 extended_features[0] = ebx;
172 extended_features[1] = ecx;
175 OPENSSL_cpuid(&eax, &ebx, &ecx, &edx, 1);
179 const uint32_t base_family = (eax >> 8) & 15;
180 const uint32_t base_model = (eax >> 4) & 15;
184 if (base_family == 0xf) {
185 const uint32_t ext_family = (eax >> 20) & 255;
186 family += ext_family;
187 const uint32_t ext_model = (eax >> 16) & 15;
188 model |= ext_model << 4;
191 if (family < 0x17 || (family == 0x17 && 0x70 <= model && model <= 0x7f)) {
216 if ((eax & 0x0fff0ff0) == 0x00050670 ||
217 (eax & 0x0fff0ff0) == 0x00080650 ) {
229 if (ecx & (1
u << 27)) {
231 xcr0 = OPENSSL_xgetbv(0);
234 if ((xcr0 & 6) != 6) {
243 extended_features[0] &=
244 ~((1
u << 5) | (1
u << 16) | (1
u << 21) | (1
u << 30) | (1
u << 31));
247 if ((xcr0 & 0xe6) != 0xe6) {
250 extended_features[0] &= ~(1
u << 16);
255 if ((ecx & (1
u << 26)) == 0) {
256 extended_features[0] &= ~(1
u << 19);
264 const char *env1, *env2;
265 env1 =
getenv(
"OPENSSL_ia32cap");
285 env2 = strchr(env1,
':');
291 #endif // !OPENSSL_NO_ASM && (OPENSSL_X86 || OPENSSL_X86_64)