diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-02-27 17:46:55 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-02-27 17:46:55 +0000 |
commit | f08ad3f8ef1ac3a38a92f793fa1cbc1d2d443095 (patch) | |
tree | a0469a2ed43a7f70d33583a74de24de5428f34eb /src/sna | |
parent | 8aea4ae127f92c07e3ce86b6d2afaa207a6cdce9 (diff) |
sna: Prettify GCC version detection in headers
And fixup a basic error in the process.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna')
-rw-r--r-- | src/sna/compiler.h | 6 | ||||
-rw-r--r-- | src/sna/sna_cpu.c | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/sna/compiler.h b/src/sna/compiler.h index d6af4427..985844df 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 05d61274..ce69a39c 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> |