3
0
Fork 0
mirror of https://github.com/JulianGro/overte.git synced 2025-04-18 09:18:42 +02:00

use cpuid.h on both GCC and Xcode

This commit is contained in:
Ken Cooke 2016-02-11 16:09:04 -08:00
parent c4b09c3603
commit 8a49c4b833

View file

@ -143,10 +143,23 @@ static bool cpuSupportsAVX() {
return result;
}
#elif defined(__GNUC__) && !defined(__clang__)
#elif defined(__GNUC__)
#include <cpuid.h>
static bool cpuSupportsAVX() {
return __builtin_cpu_supports("avx");
unsigned int eax, ebx, ecx, edx;
int mask = (1 << 27) | (1 << 28); // OSXSAVE and AVX
bool result = false;
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && ((ecx & mask) == mask) {
__asm__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0));
if (eax & 0x6) == 0x6) {
result = true;
}
}
return result;
}
#else