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:
parent
c4b09c3603
commit
8a49c4b833
1 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue