fix avx2 feature detection, fixes #395

cpuid needed to get called with EAX = 7 to get the "extended features"
(not with EAX = 1 for the "features").
This commit is contained in:
Thomas Waldmann 2016-05-17 01:19:58 +02:00
parent 263101cfaf
commit b9c266181b

View File

@ -168,7 +168,9 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
#if defined(HAVE_AVX2INTRIN_H) || \
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
if (cpu_features->has_avx) {
cpu_features->has_avx2 = ((cpu_info[1] & CPUID_EBX_AVX2) != 0x0);
unsigned int cpu_info7[4];
_cpuid(cpu_info7, 0x00000007);
cpu_features->has_avx2 = ((cpu_info7[1] & CPUID_EBX_AVX2) != 0x0);
}
#endif