aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2013-01-21 17:58:28 +0000
committerPeter Maydell <peter.maydell@linaro.org>2013-01-21 17:58:28 +0000
commitd8fa754c70674815c5f089d43cdaa25a2dbba1f6 (patch)
treeb4bcb8d8f159d49e579b1a33737d5a9a24e302f3
parent8b17ed4caa7e015324a4ecbe3c863e32458d840a (diff)
include/qemu/cpuid.h: Add new wrapper around system cpuid.h
Unfortunately some versions of gcc's cpuid.h header do not have guards against multiple inclusion. So that we can sanely use this header from more than one place in QEMU, add our own wrapper around it which does have guards. Since we have the wrapper anyway, make it check whether CONFIG_CPUID_H is set, so the including file doesn't have to. (Users still need to guard the actual uses of __get_cpuid() and friends with ifdefs, though.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--include/qemu/cpuid.h37
-rw-r--r--tcg/i386/tcg-target.c2
2 files changed, 38 insertions, 1 deletions
diff --git a/include/qemu/cpuid.h b/include/qemu/cpuid.h
new file mode 100644
index 0000000000..b5c42254c4
--- /dev/null
+++ b/include/qemu/cpuid.h
@@ -0,0 +1,37 @@
+/*
+ * Wrapper for the gcc cpuid.h header.
+ *
+ * Copyright (c) 2013 Linaro Limited
+ *
+ * Authors:
+ * Peter Maydell <peter.maydell@linaro.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This header serves two purposes:
+ * (1) some versions of gcc's cpuid.h have no multiple inclusion
+ * guards; this header is guaranteed to have them.
+ * (2) it saves the including file having to wrap its #include
+ * in the CONFIG_CPUID_H ifdef.
+ */
+
+#ifndef QEMU_CPUID_H
+#define QEMU_CPUID_H
+
+#ifdef CONFIG_CPUID_H
+#include <cpuid.h>
+#endif
+
+#endif
diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index 7aec3043e3..dc45b2edb0 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -103,7 +103,7 @@ static const int tcg_target_call_oarg_regs[] = {
#if TCG_TARGET_REG_BITS == 64
# define have_cmov 1
#elif defined(CONFIG_CPUID_H)
-#include <cpuid.h>
+#include <qemu/cpuid.h>
static bool have_cmov;
#else
# define have_cmov 0