xf86-video-intel: 2 commits - src/sna/compiler.h src/sna/sna_cpu.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Feb 27 09:48:08 PST 2013


 src/sna/compiler.h |    6 ++++--
 src/sna/sna_cpu.c  |   46 +++++++++++++++++++++++-----------------------
 2 files changed, 27 insertions(+), 25 deletions(-)

New commits:
commit f08ad3f8ef1ac3a38a92f793fa1cbc1d2d443095
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Feb 27 17:46:55 2013 +0000

    sna: Prettify GCC version detection in headers
    
    And fixup a basic error in the process.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/compiler.h b/src/sna/compiler.h
index d6af442..985844d 100644
--- a/src/sna/compiler.h
+++ b/src/sna/compiler.h
@@ -52,12 +52,14 @@
 #define flatten
 #endif
 
-#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 5)
+#define HAS_GCC(major, minor) defined(__GNUC__) && (__GNUC__ > (major) || __GNUC__ == (major) && __GNUC_MINOR__ >= (minor))
+
+#if HAS_GCC(4, 5)
 #define sse2 __attribute__((target("sse2,fpmath=sse")))
 #define sse4_2 __attribute__((target("sse4.2,sse2,fpmath=sse")))
 #endif
 
-#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 7)
+#if HAS_GCC(4, 7)
 #define avx2 __attribute__((target("avx2,sse4.2,sse2,fpmath=sse")))
 #endif
 
diff --git a/src/sna/sna_cpu.c b/src/sna/sna_cpu.c
index 05d6127..ce69a39 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) || (__GNUC__ == 4 && __GNUC_MINOR__ >=4)
+#if HAS_GCC(4, 4)
 
 #include <cpuid.h>
 
commit 8aea4ae127f92c07e3ce86b6d2afaa207a6cdce9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Feb 27 17:38:46 2013 +0000

    sna: Improve compatibility of cpuid.h detection
    
    Reported-by: Sedat Dilek <sedat.dilek at gmail.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_cpu.c b/src/sna/sna_cpu.c
index 9110456..05d6127 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;
 }


More information about the xorg-commit mailing list