diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-02-27 17:38:46 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-02-27 17:38:46 +0000 |
commit | 8aea4ae127f92c07e3ce86b6d2afaa207a6cdce9 (patch) | |
tree | 0ccd30655248d59e068f3c55a3a01950541bfbe9 /src | |
parent | 5c27307219b5a5c1f73dcde9d0b2beed5810bd7d (diff) |
sna: Improve compatibility of cpuid.h detection
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_cpu.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/sna/sna_cpu.c b/src/sna/sna_cpu.c index 91104569..05d61274 100644 --- a/src/sna/sna_cpu.c +++ b/src/sna/sna_cpu.c @@ -31,7 +31,7 @@ #include "sna.h" -#if defined(__GNUC__) && (__GNUC__ >= 4) /* 4.4 */ +#if defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >=4) #include <cpuid.h> @@ -44,36 +44,36 @@ unsigned sna_cpu_detect(void) unsigned int eax, ebx, ecx, edx; unsigned features = 0; - __cpuid(1, eax, ebx, ecx, edx); + if (__get_cpuid(1, eax, ebx, ecx, edx)) { + if (eax & bit_SSE3) + features |= SSE3; - if (eax & bit_SSE3) - features |= SSE3; + if (eax & bit_SSSE3) + features |= SSSE3; - if (eax & bit_SSSE3) - features |= SSSE3; + if (eax & bit_SSE4_1) + features |= SSE4_1; - if (eax & bit_SSE4_1) - features |= SSE4_1; + if (eax & bit_SSE4_2) + features |= SSE4_2; - if (eax & bit_SSE4_2) - features |= SSE4_2; + if (eax & bit_AVX) + features |= AVX; - if (eax & bit_AVX) - features |= AVX; + if (edx & bit_MMX) + features |= MMX; - if (edx & bit_MMX) - features |= MMX; + if (edx & bit_SSE) + features |= SSE; - if (edx & bit_SSE) - features |= SSE; + if (edx & bit_SSE2) + features |= SSE2; + } - if (edx & bit_SSE2) - features |= SSE2; - - __cpuid(7, eax, ebx, ecx, edx); - - if (eax & bit_AVX2) - features |= AVX2; + if (__get_cpuid(7, eax, ebx, ecx, edx)) { + if (eax & bit_AVX2) + features |= AVX2; + } return features; } |