tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 20 Feb 2014 19:42:53 +0000 (19:42 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 21 Feb 2014 10:39:10 +0000 (10:39 +0000)
Win32 doesn't have a cpuid.h, and MacOSX may have one but without
the __cpuid() function we use, which means that commit 9d2eec20
broke the build for those platforms. Fix this by tightening up
our configure cpuid.h check to test that the functions we need
are present, and adding some missing #ifdef guards in
tcg/i386/tcg-target.c.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
configure
tcg/i386/tcg-target.c

index 4648117957465e554bd0005dc51d7e1750b97526..79eb54c3ef4919b7a540bb92601c3126054bdee6 100755 (executable)
--- a/configure
+++ b/configure
@@ -3564,7 +3564,18 @@ cpuid_h=no
 cat > $TMPC << EOF
 #include <cpuid.h>
 int main(void) {
-  return 0;
+    unsigned a, b, c, d;
+    int max = __get_cpuid_max(0, 0);
+
+    if (max >= 1) {
+        __cpuid(1, a, b, c, d);
+    }
+
+    if (max >= 7) {
+        __cpuid_count(7, 0, a, b, c, d);
+    }
+
+    return 0;
 }
 EOF
 if compile_prog "" "" ; then
index fef17174184fceca3d0af07fdf81a1ff539477fd..f832282d1ad17aa50d955395370a4880acf1482c 100644 (file)
@@ -115,7 +115,7 @@ static const int tcg_target_call_oarg_regs[] = {
    is available.  */
 #if TCG_TARGET_REG_BITS == 64
 # define have_cmov 1
-#elif defined(CONFIG_CPUID_H)
+#elif defined(CONFIG_CPUID_H) && defined(bit_CMOV)
 static bool have_cmov;
 #else
 # define have_cmov 0
@@ -2295,6 +2295,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
 
 static void tcg_target_init(TCGContext *s)
 {
+#ifdef CONFIG_CPUID_H
     unsigned a, b, c, d;
     int max = __get_cpuid_max(0, 0);
 
@@ -2323,6 +2324,7 @@ static void tcg_target_init(TCGContext *s)
         have_bmi2 = (b & bit_BMI2) != 0;
 #endif
     }
+#endif
 
     if (TCG_TARGET_REG_BITS == 64) {
         tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);