From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGXlc-0003I8-LS for qemu-devel@nongnu.org; Thu, 20 Feb 2014 12:50:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGXlb-0001X9-Jx for qemu-devel@nongnu.org; Thu, 20 Feb 2014 12:50:36 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:46094) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGXlb-0001Ws-Bk for qemu-devel@nongnu.org; Thu, 20 Feb 2014 12:50:35 -0500 From: Peter Maydell Date: Thu, 20 Feb 2014 17:50:31 +0000 Message-Id: <1392918631-14234-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Richard Henderson , patches@linaro.org 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 guerds in tcg/i386/tcg-target.c. Signed-off-by: Peter Maydell --- Tested with Linux x86/64 gcc build, Linux x86/64 clang build, W32 cross-build and MacOSX 10.8 build. If somebody would like to review this I'll apply it directly to unbreak things. Apologies for not catching it before I pushed the tcg pullreq; I had forgotten to add the 'build on w32' command to my script. configure | 8 +++++++- tcg/i386/tcg-target.c | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 4648117..a2af9db 100755 --- a/configure +++ b/configure @@ -3564,7 +3564,13 @@ cpuid_h=no cat > $TMPC << EOF #include 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); + } + return 0; } EOF if compile_prog "" "" ; then diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index fef1717..f832282 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -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); -- 1.8.5