include: Make headers more self-contained

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 <armbru@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20190812052359.30071-2-armbru@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
Markus Armbruster
2019-08-16 13:31:51 +02:00
parent f8f2eac4e5
commit ec150c7e09
106 changed files with 183 additions and 8 deletions
+2
View File
@@ -12,9 +12,11 @@
* Contributions after 2012-01-13 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*/
#ifndef QEMU_RAW_AIO_H
#define QEMU_RAW_AIO_H
#include "block/aio.h"
#include "qemu/coroutine.h"
#include "qemu/iov.h"
+2
View File
@@ -9,9 +9,11 @@
* This work is licensed under the terms of the GNU LGPL, version 2 or later.
* See the COPYING.LIB file in the top-level directory.
*/
#ifndef BLOCK_WRITE_THRESHOLD_H
#define BLOCK_WRITE_THRESHOLD_H
#include "block/block_int.h"
/*
* bdrv_write_threshold_set:
+1
View File
@@ -1,6 +1,7 @@
#ifndef QEMU_DISAS_H
#define QEMU_DISAS_H
#include "exec/hwaddr.h"
#ifdef NEED_CPU_H
#include "cpu.h"
+3
View File
@@ -16,9 +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 CPUTLB_H
#define CPUTLB_H
#include "exec/cpu-common.h"
#if !defined(CONFIG_USER_ONLY)
/* cputlb.c */
void tlb_protect_code(ram_addr_t ram_addr);
+1
View File
@@ -20,6 +20,7 @@
#ifndef EXEC_ALL_H
#define EXEC_ALL_H
#include "cpu.h"
#include "exec/tb-context.h"
#include "sysemu/cpus.h"
+2
View File
@@ -24,6 +24,8 @@
#ifndef IOPORT_H
#define IOPORT_H
#include "exec/memory.h"
#define MAX_IOPORTS (64 * 1024)
#define IOPORTS_MASK (MAX_IOPORTS - 1)
+2
View File
@@ -20,6 +20,8 @@
#ifndef MEMORY_INTERNAL_H
#define MEMORY_INTERNAL_H
#include "cpu.h"
#ifndef CONFIG_USER_ONLY
static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv)
{
+1
View File
@@ -20,6 +20,7 @@
#define RAM_ADDR_H
#ifndef CONFIG_USER_ONLY
#include "cpu.h"
#include "hw/xen/xen.h"
#include "sysemu/tcg.h"
#include "exec/ramlist.h"
+2
View File
@@ -10,6 +10,8 @@
#ifndef SOFTMMU_SEMI_H
#define SOFTMMU_SEMI_H
#include "cpu.h"
static inline uint64_t softmmu_tget64(CPUArchState *env, target_ulong addr)
{
uint64_t val;
+2
View File
@@ -20,6 +20,8 @@
#ifndef EXEC_TB_HASH_H
#define EXEC_TB_HASH_H
#include "exec/cpu-defs.h"
#include "exec/exec-all.h"
#include "qemu/xxhash.h"
#ifdef CONFIG_SOFTMMU
+2
View File
@@ -16,10 +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 THUNK_H
#define THUNK_H
#include "cpu.h"
#include "exec/user/abitypes.h"
/* types enums definitions */
+2
View File
@@ -82,6 +82,8 @@ this code that are retained.
#ifndef FPU_SOFTFLOAT_MACROS_H
#define FPU_SOFTFLOAT_MACROS_H
#include "fpu/softfloat.h"
/*----------------------------------------------------------------------------
| Shifts `a' right by the number of bits given in `count'. If any nonzero
| bits are shifted off, they are ``jammed'' into the least significant bit of
+3
View File
@@ -22,9 +22,12 @@
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HW_ACPI_PCI_H
#define HW_ACPI_PCI_H
#include "hw/acpi/bios-linker-loader.h"
typedef struct AcpiMcfgInfo {
uint64_t base;
uint32_t size;
+3
View File
@@ -6,9 +6,12 @@
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef HW_ACPI_TCO_H
#define HW_ACPI_TCO_H
#include "exec/memory.h"
#include "migration/vmstate.h"
/* As per ICH9 spec, the internal timer has an error of ~0.6s on every tick */
#define TCO_TICK_NSEC 600000000LL
+2
View File
@@ -25,6 +25,8 @@
#ifndef HW_STM32F2XX_ADC_H
#define HW_STM32F2XX_ADC_H
#include "hw/sysbus.h"
#define ADC_SR 0x00
#define ADC_CR1 0x04
#define ADC_CR2 0x08
+1
View File
@@ -11,6 +11,7 @@
#include "hw/ide/ahci.h"
#include "sysemu/sysemu.h"
#include "target/arm/cpu.h"
#define AW_A10_PIC_REG_BASE 0x01c20400
+1
View File
@@ -22,6 +22,7 @@
#include "hw/ssi/aspeed_smc.h"
#include "hw/watchdog/wdt_aspeed.h"
#include "hw/net/ftgmac100.h"
#include "target/arm/cpu.h"
#define ASPEED_SPIS_NUM 2
#define ASPEED_WDTS_NUM 3
+1
View File
@@ -13,6 +13,7 @@
#include "hw/arm/bcm2835_peripherals.h"
#include "hw/intc/bcm2836_control.h"
#include "target/arm/cpu.h"
#define TYPE_BCM283X "bcm283x"
#define BCM283X(obj) OBJECT_CHECK(BCM283XState, (obj), TYPE_BCM283X)
+1 -2
View File
@@ -19,13 +19,12 @@
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef EXYNOS4210_H
#define EXYNOS4210_H
#include "exec/memory.h"
#include "hw/sysbus.h"
#include "target/arm/cpu-qom.h"
#define EXYNOS4210_NCPUS 2
+1
View File
@@ -27,6 +27,7 @@
#include "hw/i2c/imx_i2c.h"
#include "hw/gpio/imx_gpio.h"
#include "exec/memory.h"
#include "target/arm/cpu.h"
#define TYPE_FSL_IMX25 "fsl,imx25"
#define FSL_IMX25(obj) OBJECT_CHECK(FslIMX25State, (obj), TYPE_FSL_IMX25)

Some files were not shown because too many files have changed in this diff Show More