From: Paolo Bonzini <pbonzini@redhat.com>
To: Xuebing Wang <xbing6@gmail.com>, qemu-devel@nongnu.org
Cc: afaerber@suse.de, stefanha@redhat.com
Subject: Re: [Qemu-devel] [Discussion 05/10] NEED_CPU_H: remove unnecessary inclusion of "cpu.h" in root
Date: Tue, 04 Mar 2014 11:24:54 +0100 [thread overview]
Message-ID: <5315A9F6.5060101@redhat.com> (raw)
In-Reply-To: <1393901250-3922-6-git-send-email-xbing6@gmail.com>
Il 04/03/2014 03:47, Xuebing Wang ha scritto:
> Enforce the strict associativity between NEED_CPU_H and "inclusion of cpu.h",
> for every appearance of '#include "cpu.h"', there must have the check of
> NEED_CPU_H, and conversely.
As mentioned earlier, the #ifndef is unnecessary. It is already
provided by include/exec/cpu-defs.h
> This patch only checks file in qemu root directory by:
> grep -nw "cpu.h" *.[ch] .
>
> Note: remove unnecessary inclusion of "cpu-all.h" too. "cpu-all.h" is
> architecture-specific, should ONLY be included from target-xxx/*
> - 'git grep -nw "cpu-all.h"' confirms this
Should be a separate patch. I agree with removing unnecessary #includes
in general, but please check that the include is _really_ removed and
not just included indirectly now.
Paolo
> Signed-off-by: Xuebing Wang <xbing6@gmail.com>
> ---
> arch_init.c | 1 -
> cpu-exec.c | 7 ++++++-
> cputlb.c | 6 +++++-
> disas.c | 7 ++++++-
> dump.c | 2 --
> exec.c | 2 --
> gdbstub.c | 8 +++++++-
> kvm-stub.c | 1 -
> memory_mapping.c | 6 +++---
> monitor.c | 1 -
> translate-all.c | 7 ++++++-
> user-exec.c | 7 ++++++-
> 12 files changed, 39 insertions(+), 16 deletions(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index fe17279..76e8630 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -47,7 +47,6 @@
> #include "qemu/config-file.h"
> #include "qmp-commands.h"
> #include "trace.h"
> -#include "exec/cpu-all.h"
> #include "exec/ram_addr.h"
> #include "hw/acpi/acpi.h"
> #include "qemu/host-utils.h"
> diff --git a/cpu-exec.c b/cpu-exec.c
> index 1b0f617..858825f 100644
> --- a/cpu-exec.c
> +++ b/cpu-exec.c
> @@ -16,8 +16,13 @@
> * You should have received a copy of the GNU Lesser General Public
> * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> */
> +
> +#ifndef NEED_CPU_H
> +#error target-xxx/cpu.h must be included because target-specific are required
> +#endif
> +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */
> +
> #include "config.h"
> -#include "cpu.h"
> #include "disas/disas.h"
> #include "tcg.h"
> #include "qemu/atomic.h"
> diff --git a/cputlb.c b/cputlb.c
> index 0fbaa39..3c6cb16 100644
> --- a/cputlb.c
> +++ b/cputlb.c
> @@ -17,8 +17,12 @@
> * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> */
>
> +#ifndef NEED_CPU_H
> +#error target-xxx/cpu.h must be included because target-specific are required
> +#endif
> +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */
> +
> #include "config.h"
> -#include "cpu.h"
> #include "exec/exec-all.h"
> #include "exec/memory.h"
> #include "exec/address-spaces.h"
> diff --git a/disas.c b/disas.c
> index 79e6944..8dc51c8 100644
> --- a/disas.c
> +++ b/disas.c
> @@ -1,10 +1,15 @@
> /* General "disassemble this chunk" code. Used for debugging. */
> +
> +#ifndef NEED_CPU_H
> +#error target-xxx/cpu.h must be included because target-specific are required
> +#endif
> +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */
> +
> #include "config.h"
> #include "disas/bfd.h"
> #include "elf.h"
> #include <errno.h>
>
> -#include "cpu.h"
> #include "disas/disas.h"
>
> typedef struct CPUDebug {
> diff --git a/dump.c b/dump.c
> index 80a9116..d75c2ea 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -13,8 +13,6 @@
>
> #include "qemu-common.h"
> #include "elf.h"
> -#include "cpu.h"
> -#include "exec/cpu-all.h"
> #include "exec/hwaddr.h"
> #include "monitor/monitor.h"
> #include "sysemu/kvm.h"
> diff --git a/exec.c b/exec.c
> index b69fd29..3df2ffc 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -25,7 +25,6 @@
> #endif
>
> #include "qemu-common.h"
> -#include "cpu.h"
> #include "tcg.h"
> #include "hw/hw.h"
> #include "hw/qdev.h"
> @@ -44,7 +43,6 @@
> #include "sysemu/xen-mapcache.h"
> #include "trace.h"
> #endif
> -#include "exec/cpu-all.h"
>
> #include "exec/cputlb.h"
> #include "translate-all.h"
> diff --git a/gdbstub.c b/gdbstub.c
> index e8ab0b2..a96add1 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -16,6 +16,13 @@
> * You should have received a copy of the GNU Lesser General Public
> * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> */
> +
> +#ifndef NEED_CPU_H
> +#error target-xxx/cpu.h must be included because target-specific are required
> +#endif
> +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */
> +/* TODO: to remove using CPUArchState to make thie file arch-independent. */
> +
> #include "config.h"
> #include "qemu-common.h"
> #ifdef CONFIG_USER_ONLY
> @@ -37,7 +44,6 @@
>
> #define MAX_PACKET_LENGTH 4096
>
> -#include "cpu.h"
> #include "qemu/sockets.h"
> #include "sysemu/kvm.h"
>
> diff --git a/kvm-stub.c b/kvm-stub.c
> index e979f76..581350a 100644
> --- a/kvm-stub.c
> +++ b/kvm-stub.c
> @@ -12,7 +12,6 @@
>
> #include "qemu-common.h"
> #include "hw/hw.h"
> -#include "cpu.h"
> #include "sysemu/kvm.h"
>
> #ifndef CONFIG_USER_ONLY
> diff --git a/memory_mapping.c b/memory_mapping.c
> index 87a6ed5..b17eea1 100644
> --- a/memory_mapping.c
> +++ b/memory_mapping.c
> @@ -13,11 +13,11 @@
>
> #include <glib.h>
>
> -#include "cpu.h"
> -#include "exec/cpu-all.h"
> -#include "sysemu/memory_mapping.h"
> +#include "qemu-common.h"
> +#include "exec/cpu-common.h" /* for ram_addr_t */
> #include "exec/memory.h"
> #include "exec/address-spaces.h"
> +#include "sysemu/memory_mapping.h"
>
> //#define DEBUG_GUEST_PHYS_REGION_ADD
>
> diff --git a/monitor.c b/monitor.c
> index aebcbd8..1a8dd24 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -58,7 +58,6 @@
> #include "qapi/qmp/json-parser.h"
> #include <qom/object_interfaces.h>
> #include "qemu/osdep.h"
> -#include "cpu.h"
> #include "trace.h"
> #include "trace/control.h"
> #ifdef CONFIG_TRACE_SIMPLE
> diff --git a/translate-all.c b/translate-all.c
> index 1ac0246..be220fb 100644
> --- a/translate-all.c
> +++ b/translate-all.c
> @@ -16,6 +16,12 @@
> * You should have received a copy of the GNU Lesser General Public
> * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> */
> +
> +#ifndef NEED_CPU_H
> +#error target-xxx/cpu.h must be included because target-specific are required
> +#endif
> +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */
> +
> #ifdef _WIN32
> #include <windows.h>
> #else
> @@ -32,7 +38,6 @@
>
> #include "qemu-common.h"
> #define NO_CPU_IO_DEFS
> -#include "cpu.h"
> #include "disas/disas.h"
> #include "tcg.h"
> #if defined(CONFIG_USER_ONLY)
> diff --git a/user-exec.c b/user-exec.c
> index 82bfa66..c4c1e3f 100644
> --- a/user-exec.c
> +++ b/user-exec.c
> @@ -16,8 +16,13 @@
> * You should have received a copy of the GNU Lesser General Public
> * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> */
> +
> +#ifndef NEED_CPU_H
> +#error target-xxx/cpu.h must be included because target-specific are required
> +#endif
> +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */
> +
> #include "config.h"
> -#include "cpu.h"
> #include "disas/disas.h"
> #include "tcg.h"
> #include "qemu/bitops.h"
>
next prev parent reply other threads:[~2014-03-04 10:25 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-04 2:47 [Qemu-devel] [Discussion 00/10] about API hierarchy Xuebing Wang
2014-03-04 2:47 ` [Qemu-devel] [Discussion 01/10] docs: add docs/api-hierarchy.txt Xuebing Wang
2014-03-04 9:42 ` Stefan Hajnoczi
2014-03-04 9:58 ` Xuebing wang
2014-03-04 11:57 ` Stefan Hajnoczi
2014-03-04 2:47 ` [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h Xuebing Wang
2014-03-04 10:19 ` Paolo Bonzini
2014-03-04 11:54 ` Xuebing wang
2014-03-04 12:02 ` Xuebing wang
2014-03-04 12:09 ` Paolo Bonzini
2014-03-04 12:09 ` Xuebing wang
2014-03-04 12:34 ` Peter Maydell
2014-03-04 12:40 ` Xuebing wang
2014-03-04 12:19 ` Xuebing wang
2014-03-04 12:23 ` Paolo Bonzini
2014-03-04 12:26 ` Xuebing wang
2014-03-04 12:29 ` Paolo Bonzini
2014-03-04 2:47 ` [Qemu-devel] [Discussion 03/10] NEED_CPU_H: remove unnecessary use of NEED_CPU_H Xuebing Wang
2014-03-04 10:20 ` Paolo Bonzini
2014-03-04 2:47 ` [Qemu-devel] [Discussion 04/10] memory_mapping: make this architecture-independent Xuebing Wang
2014-03-04 10:22 ` Paolo Bonzini
2014-03-04 11:05 ` Peter Maydell
2014-03-04 2:47 ` [Qemu-devel] [Discussion 05/10] NEED_CPU_H: remove unnecessary inclusion of "cpu.h" in root Xuebing Wang
2014-03-04 10:24 ` Paolo Bonzini [this message]
2014-03-04 2:47 ` [Qemu-devel] [Discussion 06/10] memory: move contents in include/exec/address-spaces.h => memory.h Xuebing Wang
2014-03-04 10:26 ` Paolo Bonzini
2014-03-04 2:47 ` [Qemu-devel] [Discussion 07/10] memory: remove file include/exec/address-spaces.h Xuebing Wang
2014-03-04 2:47 ` [Qemu-devel] [Discussion 08/10] exec: move TranslationBlock API from exec-all.h => translate.h Xuebing Wang
2014-03-04 10:27 ` Paolo Bonzini
2014-03-04 2:47 ` [Qemu-devel] [Discussion 09/10] exec: remove the unnecessary include of "exec-all.h" Xuebing Wang
2014-03-04 10:27 ` Paolo Bonzini
2014-03-04 11:11 ` Peter Maydell
2014-03-04 11:16 ` Peter Maydell
2014-03-04 2:47 ` [Qemu-devel] [Discussion 10/10] translate: remove file translate-all.h Xuebing Wang
2014-03-04 10:29 ` Paolo Bonzini
2014-03-04 3:45 ` [Qemu-devel] [Discussion 00/10] about API hierarchy Andreas Färber
2014-03-04 5:37 ` Xuebing wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5315A9F6.5060101@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=xbing6@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.