From ec150c7e09071bcf51bfaa8071fe23efb6df69f7 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 12 Aug 2019 07:23:31 +0200 Subject: include: Make headers more self-contained MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Back in 2016, we discussed[1] rules for headers, and these were generally liked: 1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h. 2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header. 3. Cyclic inclusion is forbidden. This patch gets include/ closer to obeying 2. It's actually extracted from my "[RFC] Baby steps towards saner headers" series[2], which demonstrates a possible path towards checking 2 automatically. It passes the RFC test there. [1] Message-ID: <87h9g8j57d.fsf@blackfin.pond.sub.org> https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html [2] Message-Id: <20190711122827.18970-1-armbru@redhat.com> https://lists.nongnu.org/archive/html/qemu-devel/2019-07/msg02715.html Signed-off-by: Markus Armbruster Reviewed-by: Alistair Francis Message-Id: <20190812052359.30071-2-armbru@redhat.com> Tested-by: Philippe Mathieu-Daudé --- include/hw/misc/macio/cuda.h | 2 ++ include/hw/misc/macio/gpio.h | 3 +++ include/hw/misc/macio/macio.h | 2 ++ include/hw/misc/macio/pmu.h | 3 +++ include/hw/misc/mips_cmgcr.h | 2 ++ include/hw/misc/mips_cpc.h | 2 ++ include/hw/misc/pvpanic.h | 3 +++ 7 files changed, 17 insertions(+) (limited to 'include/hw/misc') diff --git a/include/hw/misc/macio/cuda.h b/include/hw/misc/macio/cuda.h index 7dad469..5768075 100644 --- a/include/hw/misc/macio/cuda.h +++ b/include/hw/misc/macio/cuda.h @@ -26,6 +26,8 @@ #ifndef CUDA_H #define CUDA_H +#include "hw/misc/mos6522.h" + /* CUDA commands (2nd byte) */ #define CUDA_WARM_START 0x0 #define CUDA_AUTOPOLL 0x1 diff --git a/include/hw/misc/macio/gpio.h b/include/hw/misc/macio/gpio.h index 2838ae5..24a4364 100644 --- a/include/hw/misc/macio/gpio.h +++ b/include/hw/misc/macio/gpio.h @@ -26,6 +26,9 @@ #ifndef MACIO_GPIO_H #define MACIO_GPIO_H +#include "hw/ppc/openpic.h" +#include "hw/sysbus.h" + #define TYPE_MACIO_GPIO "macio-gpio" #define MACIO_GPIO(obj) OBJECT_CHECK(MacIOGPIOState, (obj), TYPE_MACIO_GPIO) diff --git a/include/hw/misc/macio/macio.h b/include/hw/misc/macio/macio.h index 970058b..070a694 100644 --- a/include/hw/misc/macio/macio.h +++ b/include/hw/misc/macio/macio.h @@ -27,10 +27,12 @@ #define MACIO_H #include "hw/char/escc.h" +#include "hw/ide/internal.h" #include "hw/intc/heathrow_pic.h" #include "hw/misc/macio/cuda.h" #include "hw/misc/macio/gpio.h" #include "hw/misc/macio/pmu.h" +#include "hw/ppc/mac.h" #include "hw/ppc/mac_dbdma.h" #include "hw/ppc/openpic.h" diff --git a/include/hw/misc/macio/pmu.h b/include/hw/misc/macio/pmu.h index d10895b..7ef83de 100644 --- a/include/hw/misc/macio/pmu.h +++ b/include/hw/misc/macio/pmu.h @@ -10,6 +10,9 @@ #ifndef PMU_H #define PMU_H +#include "hw/misc/mos6522.h" +#include "hw/misc/macio/gpio.h" + /* * PMU commands */ diff --git a/include/hw/misc/mips_cmgcr.h b/include/hw/misc/mips_cmgcr.h index c9dfcb4..3e6e223 100644 --- a/include/hw/misc/mips_cmgcr.h +++ b/include/hw/misc/mips_cmgcr.h @@ -10,6 +10,8 @@ #ifndef MIPS_CMGCR_H #define MIPS_CMGCR_H +#include "hw/sysbus.h" + #define TYPE_MIPS_GCR "mips-gcr" #define MIPS_GCR(obj) OBJECT_CHECK(MIPSGCRState, (obj), TYPE_MIPS_GCR) diff --git a/include/hw/misc/mips_cpc.h b/include/hw/misc/mips_cpc.h index 72c834e..3f67057 100644 --- a/include/hw/misc/mips_cpc.h +++ b/include/hw/misc/mips_cpc.h @@ -20,6 +20,8 @@ #ifndef MIPS_CPC_H #define MIPS_CPC_H +#include "hw/sysbus.h" + #define CPC_ADDRSPACE_SZ 0x6000 /* CPC blocks offsets relative to base address */ diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index 1ee071a..ae0c818 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -11,9 +11,12 @@ * See the COPYING file in the top-level directory. * */ + #ifndef HW_MISC_PVPANIC_H #define HW_MISC_PVPANIC_H +#include "qom/object.h" + #define TYPE_PVPANIC "pvpanic" #define PVPANIC_IOPORT_PROP "ioport" -- cgit v1.1 From 5a720b1ed55a80672fdacf340fda0224f17146f3 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 12 Aug 2019 07:23:40 +0200 Subject: ide: Include hw/ide/internal a bit less outside hw/ide/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to hw/ide/internal's file comment, only files in hw/ide/ are supposed to include it. Drag reality slightly closer to supposition. Three includes outside hw/ide remain: hw/arm/sbsa-ref.c, include/hw/ide/pci.h, and include/hw/misc/macio/macio.h. Turns out board code needs ide-internal.h to wire up IDE stuff. More cleanup is needed. Left for another day. Cc: John Snow Signed-off-by: Markus Armbruster Reviewed-by: John Snow Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190812052359.30071-11-armbru@redhat.com> --- include/hw/misc/mos6522.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/hw/misc') diff --git a/include/hw/misc/mos6522.h b/include/hw/misc/mos6522.h index 03d9f0c..493c907 100644 --- a/include/hw/misc/mos6522.h +++ b/include/hw/misc/mos6522.h @@ -29,7 +29,6 @@ #include "exec/memory.h" #include "hw/sysbus.h" -#include "hw/ide/internal.h" #include "hw/input/adb.h" /* Bits in ACR */ -- cgit v1.1 From 64552b6be4758d3a774f7787b294543ccebd5358 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 12 Aug 2019 07:23:42 +0200 Subject: Include hw/irq.h a lot less MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In my "build everything" tree, changing hw/irq.h triggers a recompile of some 5400 out of 6600 objects (not counting tests and objects that don't depend on qemu/osdep.h). hw/hw.h supposedly includes it for convenience. Several other headers include it just to get qemu_irq and.or qemu_irq_handler. Move the qemu_irq and qemu_irq_handler typedefs from hw/irq.h to qemu/typedefs.h, and then include hw/irq.h only where it's still needed. Touching it now recompiles only some 500 objects. Signed-off-by: Markus Armbruster Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190812052359.30071-13-armbru@redhat.com> --- include/hw/misc/cbus.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/hw/misc') diff --git a/include/hw/misc/cbus.h b/include/hw/misc/cbus.h index c899943..5334984 100644 --- a/include/hw/misc/cbus.h +++ b/include/hw/misc/cbus.h @@ -13,7 +13,6 @@ #ifndef HW_MISC_CBUS_H #define HW_MISC_CBUS_H -#include "hw/irq.h" typedef struct { qemu_irq clk; -- cgit v1.1 From d4842052100a3b44167e34ebdce0e7b3bf7512cf Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 12 Aug 2019 07:23:46 +0200 Subject: Include exec/memory.h slightly less MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop unnecessary inclusions from headers. Downgrade a few more to exec/hwaddr.h. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190812052359.30071-17-armbru@redhat.com> --- include/hw/misc/auxbus.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/hw/misc') diff --git a/include/hw/misc/auxbus.h b/include/hw/misc/auxbus.h index c15b444..ee0ca3d 100644 --- a/include/hw/misc/auxbus.h +++ b/include/hw/misc/auxbus.h @@ -25,6 +25,7 @@ #ifndef HW_MISC_AUXBUS_H #define HW_MISC_AUXBUS_H +#include "exec/memory.h" #include "hw/qdev.h" typedef struct AUXBus AUXBus; -- cgit v1.1 From 650d103d3ea959212f826acb9d3fe80cf30e347b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 12 Aug 2019 07:23:48 +0200 Subject: Include hw/hw.h exactly where needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In my "build everything" tree, changing hw/hw.h triggers a recompile of some 2600 out of 6600 objects (not counting tests and objects that don't depend on qemu/osdep.h). The previous commits have left only the declaration of hw_error() in hw/hw.h. This permits dropping most of its inclusions. Touching it now recompiles less than 200 objects. Signed-off-by: Markus Armbruster Reviewed-by: Alistair Francis Message-Id: <20190812052359.30071-19-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- include/hw/misc/stm32f2xx_syscfg.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/hw/misc') diff --git a/include/hw/misc/stm32f2xx_syscfg.h b/include/hw/misc/stm32f2xx_syscfg.h index 69e6a30..84e06fd 100644 --- a/include/hw/misc/stm32f2xx_syscfg.h +++ b/include/hw/misc/stm32f2xx_syscfg.h @@ -26,7 +26,6 @@ #define HW_STM32F2XX_SYSCFG_H #include "hw/sysbus.h" -#include "hw/hw.h" #define SYSCFG_MEMRMP 0x00 #define SYSCFG_PMC 0x04 -- cgit v1.1 From a27bd6c779badb8d76e4430d810ef710a1b98f4e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 12 Aug 2019 07:23:51 +0200 Subject: Include hw/qdev-properties.h less MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In my "build everything" tree, changing hw/qdev-properties.h triggers a recompile of some 2700 out of 6600 objects (not counting tests and objects that don't depend on qemu/osdep.h). Many places including hw/qdev-properties.h (directly or via hw/qdev.h) actually need only hw/qdev-core.h. Include hw/qdev-core.h there instead. hw/qdev.h is actually pointless: all it does is include hw/qdev-core.h and hw/qdev-properties.h, which in turn includes hw/qdev-core.h. Replace the remaining uses of hw/qdev.h by hw/qdev-properties.h. While there, delete a few superfluous inclusions of hw/qdev-core.h. Touching hw/qdev-properties.h now recompiles some 1200 objects. Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Signed-off-by: Markus Armbruster Reviewed-by: Eduardo Habkost Message-Id: <20190812052359.30071-22-armbru@redhat.com> --- include/hw/misc/auxbus.h | 2 +- include/hw/misc/unimp.h | 1 + include/hw/misc/vmcoreinfo.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include/hw/misc') diff --git a/include/hw/misc/auxbus.h b/include/hw/misc/auxbus.h index ee0ca3d..a539a98 100644 --- a/include/hw/misc/auxbus.h +++ b/include/hw/misc/auxbus.h @@ -26,7 +26,7 @@ #define HW_MISC_AUXBUS_H #include "exec/memory.h" -#include "hw/qdev.h" +#include "hw/qdev-core.h" typedef struct AUXBus AUXBus; typedef struct AUXSlave AUXSlave; diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h index 2a291ca..44d87be 100644 --- a/include/hw/misc/unimp.h +++ b/include/hw/misc/unimp.h @@ -8,6 +8,7 @@ #ifndef HW_MISC_UNIMP_H #define HW_MISC_UNIMP_H +#include "hw/qdev-properties.h" #include "hw/sysbus.h" #define TYPE_UNIMPLEMENTED_DEVICE "unimplemented-device" diff --git a/include/hw/misc/vmcoreinfo.h b/include/hw/misc/vmcoreinfo.h index 0d11578..d4f3d3a 100644 --- a/include/hw/misc/vmcoreinfo.h +++ b/include/hw/misc/vmcoreinfo.h @@ -12,7 +12,7 @@ #ifndef VMCOREINFO_H #define VMCOREINFO_H -#include "hw/qdev.h" +#include "hw/qdev-core.h" #include "standard-headers/linux/qemu_fw_cfg.h" #define VMCOREINFO_DEVICE "vmcoreinfo" -- cgit v1.1