summary refs log tree commit diff stats
path: root/util/bufferiszero.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2017-07-18 18:40:18 -1000
committerPeter Maydell <peter.maydell@linaro.org>2017-07-24 12:42:55 +0100
commit5dd8990841a9e331d9d4838a116291698208cbb6 (patch)
treee2d46bda2138d892ebb1ecc210696d88f739008a /util/bufferiszero.c
parentdf95f1a298a3e16c80293343143dcedbe7978f6c (diff)
downloadfocaccia-qemu-5dd8990841a9e331d9d4838a116291698208cbb6.tar.gz
focaccia-qemu-5dd8990841a9e331d9d4838a116291698208cbb6.zip
util: Introduce include/qemu/cpuid.h
Clang 3.9 passes the CONFIG_AVX2_OPT configure test.  However, the
supplied <cpuid.h> does not contain the bit_AVX2 define that we use
when detecting whether the routine can be enabled.

Introduce a qemu-specific header that uses the compiler's definition
of __cpuid et al, but supplies any missing bit_* definitions needed.
This avoids introducing any extra ifdefs to util/bufferiszero.c, and
allows quite a few to be removed from tcg/i386/tcg-target.inc.c.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20170719044018.18063-1-rth@twiddle.net
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util/bufferiszero.c')
-rw-r--r--util/bufferiszero.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/util/bufferiszero.c b/util/bufferiszero.c
index eb974b7849..2178d8ab9d 100644
--- a/util/bufferiszero.c
+++ b/util/bufferiszero.c
@@ -197,7 +197,7 @@ buffer_zero_avx2(const void *buf, size_t len)
 
 /* Make sure that these variables are appropriately initialized when
  * SSE2 is enabled on the compiler command-line, but the compiler is
- * too old to support <cpuid.h>.
+ * too old to support CONFIG_AVX2_OPT.
  */
 #ifdef CONFIG_AVX2_OPT
 # define INIT_CACHE 0
@@ -231,7 +231,8 @@ static void init_accel(unsigned cache)
 }
 
 #ifdef CONFIG_AVX2_OPT
-#include <cpuid.h>
+#include "qemu/cpuid.h"
+
 static void __attribute__((constructor)) init_cpuid_cache(void)
 {
     int max = __get_cpuid_max(0, NULL);
@@ -243,7 +244,6 @@ static void __attribute__((constructor)) init_cpuid_cache(void)
         if (d & bit_SSE2) {
             cache |= CACHE_SSE2;
         }
-#ifdef CONFIG_AVX2_OPT
         if (c & bit_SSE4_1) {
             cache |= CACHE_SSE4;
         }
@@ -257,7 +257,6 @@ static void __attribute__((constructor)) init_cpuid_cache(void)
                 cache |= CACHE_AVX2;
             }
         }
-#endif
     }
     cpuid_cache = cache;
     init_accel(cache);