aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/arm/allwinner-a10.c1
-rw-r--r--hw/arm/armv7m.c1
-rw-r--r--hw/arm/boot.c2
-rw-r--r--hw/arm/collie.c1
-rw-r--r--hw/arm/cubieboard.c1
-rw-r--r--hw/arm/digic.c1
-rw-r--r--hw/arm/digic_boards.c1
-rw-r--r--hw/arm/exynos4210.c1
-rw-r--r--hw/arm/exynos4_boards.c1
-rw-r--r--hw/arm/fsl-imx25.c1
-rw-r--r--hw/arm/fsl-imx31.c1
-rw-r--r--hw/arm/gumstix.c1
-rw-r--r--hw/arm/highbank.c1
-rw-r--r--hw/arm/imx25_pdk.c1
-rw-r--r--hw/arm/integratorcp.c1
-rw-r--r--hw/arm/kzm.c1
-rw-r--r--hw/arm/mainstone.c1
-rw-r--r--hw/arm/musicpal.c1
-rw-r--r--hw/arm/netduino2.c1
-rw-r--r--hw/arm/nseries.c1
-rw-r--r--hw/arm/omap1.c1
-rw-r--r--hw/arm/omap2.c1
-rw-r--r--hw/arm/omap_sx1.c1
-rw-r--r--hw/arm/palm.c1
-rw-r--r--hw/arm/pxa2xx.c1
-rw-r--r--hw/arm/pxa2xx_gpio.c1
-rw-r--r--hw/arm/pxa2xx_pic.c1
-rw-r--r--hw/arm/realview.c1
-rw-r--r--hw/arm/spitz.c1
-rw-r--r--hw/arm/stellaris.c1
-rw-r--r--hw/arm/stm32f205_soc.c1
-rw-r--r--hw/arm/strongarm.c1
-rw-r--r--hw/arm/sysbus-fdt.c1
-rw-r--r--hw/arm/tosa.c1
-rw-r--r--hw/arm/versatilepb.c1
-rw-r--r--hw/arm/vexpress.c1
-rw-r--r--hw/arm/virt-acpi-build.c1
-rw-r--r--hw/arm/virt.c1
-rw-r--r--hw/arm/xilinx_zynq.c1
-rw-r--r--hw/arm/xlnx-ep108.c1
-rw-r--r--hw/arm/xlnx-zynqmp.c1
-rw-r--r--hw/arm/z2.c1
-rwxr-xr-xscripts/clean-includes109
-rw-r--r--target-arm/arm-semi.c8
-rw-r--r--target-arm/cpu.c1
-rw-r--r--target-arm/cpu64.c1
-rw-r--r--target-arm/crypto_helper.c2
-rw-r--r--target-arm/gdbstub.c2
-rw-r--r--target-arm/gdbstub64.c2
-rw-r--r--target-arm/helper-a64.c1
-rw-r--r--target-arm/helper.c1
-rw-r--r--target-arm/iwmmxt_helper.c3
-rw-r--r--target-arm/kvm-stub.c1
-rw-r--r--target-arm/kvm.c3
-rw-r--r--target-arm/kvm32.c3
-rw-r--r--target-arm/kvm64.c4
-rw-r--r--target-arm/machine.c1
-rw-r--r--target-arm/neon_helper.c3
-rw-r--r--target-arm/op_helper.c1
-rw-r--r--target-arm/psci.c1
-rw-r--r--target-arm/translate-a64.c6
-rw-r--r--target-arm/translate.c6
62 files changed, 170 insertions, 32 deletions
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index b0ca81cea3..02c8caa191 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -15,6 +15,7 @@
* for more details.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/devices.h"
#include "hw/arm/allwinner-a10.h"
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index a80d2ad29c..f3973f721a 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -7,6 +7,7 @@
* This code is licensed under the GPL.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "hw/loader.h"
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 75f69bfe01..7742dd3cb6 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -7,7 +7,7 @@
* This code is licensed under the GPL.
*/
-#include "config.h"
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/arm/arm.h"
#include "hw/arm/linux-boot-if.h"
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
index 9991c0c4a0..8bb308a42e 100644
--- a/hw/arm/collie.c
+++ b/hw/arm/collie.c
@@ -8,6 +8,7 @@
* Contributions after 2012-01-13 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/sysbus.h"
#include "hw/boards.h"
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
index a71e43cf5f..2382c59158 100644
--- a/hw/arm/cubieboard.c
+++ b/hw/arm/cubieboard.c
@@ -15,6 +15,7 @@
* for more details.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/devices.h"
#include "hw/boards.h"
diff --git a/hw/arm/digic.c b/hw/arm/digic.c
index 90f8190c48..82087bacb8 100644
--- a/hw/arm/digic.c
+++ b/hw/arm/digic.c
@@ -20,6 +20,7 @@
*
*/
+#include "qemu/osdep.h"
#include "hw/arm/digic.h"
#define DIGIC4_TIMER_BASE(n) (0xc0210000 + (n) * 0x100)
diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
index dfaed257f5..e5308f47ab 100644
--- a/hw/arm/digic_boards.c
+++ b/hw/arm/digic_boards.c
@@ -23,6 +23,7 @@
*
*/
+#include "qemu/osdep.h"
#include "hw/boards.h"
#include "exec/address-spaces.h"
#include "qemu/error-report.h"
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 79b7c5ab3d..6a8f0b54ce 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -21,6 +21,7 @@
*
*/
+#include "qemu/osdep.h"
#include "hw/boards.h"
#include "sysemu/sysemu.h"
#include "hw/sysbus.h"
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index da82b27bad..42faa8c48d 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -21,6 +21,7 @@
*
*/
+#include "qemu/osdep.h"
#include "sysemu/sysemu.h"
#include "sysemu/qtest.h"
#include "hw/sysbus.h"
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 36818ee025..fb743bfbd0 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -22,6 +22,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "hw/arm/fsl-imx25.h"
#include "sysemu/sysemu.h"
#include "exec/address-spaces.h"
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index abdea0683a..f2c2ce56f6 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -19,6 +19,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "hw/arm/fsl-imx31.h"
#include "sysemu/sysemu.h"
#include "exec/address-spaces.h"
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index 32ad041b20..626d338373 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -34,6 +34,7 @@
* # qemu-system-arm -M verdex -pflash flash -monitor null -nographic -m 289
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
#include "net/net.h"
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index cb9926e50f..620b52631a 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -17,6 +17,7 @@
*
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "hw/devices.h"
diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c
index 039f0ebdb8..b167e19f5a 100644
--- a/hw/arm/imx25_pdk.c
+++ b/hw/arm/imx25_pdk.c
@@ -23,6 +23,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "hw/arm/fsl-imx25.h"
#include "hw/boards.h"
#include "qemu/error-report.h"
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 96dedce906..c6656a817c 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -7,6 +7,7 @@
* This code is licensed under the GPL
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/devices.h"
#include "hw/boards.h"
diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c
index f4b463aa1e..55fb36021c 100644
--- a/hw/arm/kzm.c
+++ b/hw/arm/kzm.c
@@ -13,6 +13,7 @@
* i.MX31 SoC
*/
+#include "qemu/osdep.h"
#include "hw/arm/fsl-imx31.h"
#include "hw/boards.h"
#include "qemu/error-report.h"
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index e434cb6ab0..98a892ff62 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -11,6 +11,7 @@
* Contributions after 2012-01-13 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
#include "hw/arm/arm.h"
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index b534bb9041..54548f38bb 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -9,6 +9,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "hw/devices.h"
diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c
index 3ab83a1acd..86065d360a 100644
--- a/hw/arm/netduino2.c
+++ b/hw/arm/netduino2.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "qemu/osdep.h"
#include "hw/boards.h"
#include "qemu/error-report.h"
#include "hw/arm/stm32f205_soc.h"
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index 57170aea8b..d9e61f7779 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -18,6 +18,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "qemu-common.h"
#include "sysemu/sysemu.h"
#include "hw/arm/omap.h"
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 6b1c076598..6f68130419 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -17,6 +17,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "hw/boards.h"
#include "hw/hw.h"
#include "hw/arm/arm.h"
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
index 98ee19f861..d11224e81e 100644
--- a/hw/arm/omap2.c
+++ b/hw/arm/omap2.c
@@ -18,6 +18,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "sysemu/block-backend.h"
#include "sysemu/blockdev.h"
#include "hw/boards.h"
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index 8eaf8f3315..68236a39b2 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -25,6 +25,7 @@
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "ui/console.h"
#include "hw/arm/omap.h"
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
index 82ec99d936..cae0a46561 100644
--- a/hw/arm/palm.c
+++ b/hw/arm/palm.c
@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "audio/audio.h"
#include "sysemu/sysemu.h"
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 79d22d91e5..db58781e01 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -7,6 +7,7 @@
* This code is licensed under the GPL.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/pxa.h"
#include "sysemu/sysemu.h"
diff --git a/hw/arm/pxa2xx_gpio.c b/hw/arm/pxa2xx_gpio.c
index c89c8045c3..67e7e70943 100644
--- a/hw/arm/pxa2xx_gpio.c
+++ b/hw/arm/pxa2xx_gpio.c
@@ -7,6 +7,7 @@
* This code is licensed under the GPL.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/sysbus.h"
#include "hw/arm/pxa.h"
diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c
index d41ac93416..8a39b1caca 100644
--- a/hw/arm/pxa2xx_pic.c
+++ b/hw/arm/pxa2xx_pic.c
@@ -8,6 +8,7 @@
* This code is licensed under the GPL.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
#include "hw/sysbus.h"
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 2d6952c393..90429fc456 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -7,6 +7,7 @@
* This code is licensed under the GPL.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "hw/arm/primecell.h"
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index 8d3cc0b6b2..317ade1202 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -10,6 +10,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
#include "hw/arm/arm.h"
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 0114e0a7f8..3eb7d3cb77 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -7,6 +7,7 @@
* This code is licensed under the GPL.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/ssi.h"
#include "hw/arm/arm.h"
diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 3f993406dd..79bfe6d10f 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "qemu/osdep.h"
#include "hw/arm/arm.h"
#include "exec/address-spaces.h"
#include "hw/arm/stm32f205_soc.h"
diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c
index 9624ecb586..d9f2f5b3aa 100644
--- a/hw/arm/strongarm.c
+++ b/hw/arm/strongarm.c
@@ -27,6 +27,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "qemu/osdep.h"
#include "hw/boards.h"
#include "hw/sysbus.h"
#include "strongarm.h"
diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c
index 9d28797c87..68a3de5cf8 100644
--- a/hw/arm/sysbus-fdt.c
+++ b/hw/arm/sysbus-fdt.c
@@ -21,6 +21,7 @@
*
*/
+#include "qemu/osdep.h"
#include "hw/arm/sysbus-fdt.h"
#include "qemu/error-report.h"
#include "sysemu/device_tree.h"
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index 02814d7aba..c387950fb0 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -11,6 +11,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
#include "hw/arm/arm.h"
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 70eefe9987..d061f0fd07 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -7,6 +7,7 @@
* This code is licensed under the GPL.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "hw/devices.h"
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index ea9a9840d0..3154aeaa95 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -21,6 +21,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "hw/arm/primecell.h"
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 0d5c635cc8..87fbe7c97d 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -26,6 +26,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "qemu-common.h"
#include "hw/arm/virt-acpi-build.h"
#include "qemu/bitmap.h"
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 92dcd02119..05f9087cca 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -28,6 +28,7 @@
* This is essentially the same approach kvmtool uses.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "hw/arm/primecell.h"
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 65e92e1824..40b476172a 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -15,6 +15,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "net/net.h"
diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c
index 9099025a79..c9414e6a25 100644
--- a/hw/arm/xlnx-ep108.c
+++ b/hw/arm/xlnx-ep108.c
@@ -15,6 +15,7 @@
* for more details.
*/
+#include "qemu/osdep.h"
#include "hw/arm/xlnx-zynqmp.h"
#include "hw/boards.h"
#include "qemu/error-report.h"
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index f26efd802a..57e926d524 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -15,6 +15,7 @@
* for more details.
*/
+#include "qemu/osdep.h"
#include "hw/arm/xlnx-zynqmp.h"
#include "hw/intc/arm_gic_common.h"
#include "exec/address-spaces.h"
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index b44eb76fcc..aecb24a8e9 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -11,6 +11,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
#include "hw/arm/arm.h"
diff --git a/scripts/clean-includes b/scripts/clean-includes
new file mode 100755
index 0000000000..1af1f824b8
--- /dev/null
+++ b/scripts/clean-includes
@@ -0,0 +1,109 @@
+#!/bin/sh -e
+#
+# Clean up QEMU #include lines by ensuring that qemu/osdep.h
+# is the first include listed.
+#
+# Copyright (c) 2015 Linaro Limited
+#
+# Authors:
+# Peter Maydell <peter.maydell@linaro.org>
+#
+# This work is licensed under the terms of the GNU GPL, version 2
+# or (at your option) any later version. See the COPYING file in
+# the top-level directory.
+
+# Usage:
+# clean-includes [--git subjectprefix] file ...
+#
+# If the --git subjectprefix option is given, then after making
+# the changes to the files this script will create a git commit
+# with the subject line "subjectprefix: Clean up includes"
+# and a boilerplate commit message.
+
+# This script requires Coccinelle to be installed.
+
+
+# The following one-liner may be handy for finding files to run this on.
+# However some caution is required regarding files that might be part
+# of the guest agent or standalone tests.
+
+# for i in `git ls-tree --name-only HEAD` ; do test -f $i && \
+# grep -E '^# *include' $i | head -1 | grep 'osdep.h' ; test $? != 0 && \
+# echo $i ; done
+
+
+GIT=no
+
+if [ $# -ne 0 ] && [ "$1" = "--git" ]; then
+ if [ $# -eq 1 ]; then
+ echo "--git option requires an argument"
+ exit 1
+ fi
+ GITSUBJ="$2"
+ GIT=yes
+ shift
+ shift
+fi
+
+if [ $# -eq 0 ]; then
+ echo "Usage: clean-includes [--git subjectprefix] foo.c ..."
+ echo "(modifies the files in place)"
+ exit 1
+fi
+
+# Annoyingly coccinelle won't read a scriptfile unless its
+# name ends '.cocci', so write it out to a tempfile with the
+# right kind of name.
+COCCIFILE="$(mktemp --suffix=.cocci)"
+
+trap 'rm -f -- "$COCCIFILE"' INT TERM HUP EXIT
+
+cat >"$COCCIFILE" <<EOT
+@@
+@@
+
+(
++ #include "qemu/osdep.h"
+ #include "..."
+|
++ #include "qemu/osdep.h"
+ #include <...>
+)
+EOT
+
+
+for f in "$@"; do
+ # First, use coccinelle to add qemu/osdep.h before the first existing include
+ # (this will add two lines if the file uses both "..." and <...> #includes,
+ # but we will remove the extras in the next step)
+ spatch --in-place --no-show-diff --cocci-file "$COCCIFILE" "$f"
+
+ # Now remove any duplicate osdep.h includes
+ perl -n -i -e 'print if !/#include "qemu\/osdep.h"/ || !$n++;' "$f"
+
+ # Remove includes that osdep.h already provides
+ perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ ||
+ ! (grep { $_ eq $1 } qw (
+ "config-host.h" "qemu/compiler.h" "config.h"
+ <stdarg.h> <stddef.h> <stdbool.h> <stdint.h> <sys/types.h>
+ <stdlib.h> <stdio.h> <string.h> <strings.h> <inttypes.h>
+ <limits.h> <unistd.h> <time.h> <ctype.h> <errno.h> <fcntl.h>
+ <sys/stat.h> <sys/time.h> <assert.h> <signal.h>
+ "glib-compat.h" "qapi/error.h"
+ ))' "$f"
+
+done
+
+if [ "$GIT" = "yes" ]; then
+ git add -- "$@"
+ git commit --signoff -F - <<EOF
+$GITSUBJ: Clean up includes
+
+Clean up includes so that osdep.h is included first and headers
+which it implies are not included manually.
+
+This commit was created with scripts/clean-includes.
+
+EOF
+
+fi
diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c
index d7cff3db23..76c33b97e7 100644
--- a/target-arm/arm-semi.c
+++ b/target-arm/arm-semi.c
@@ -18,13 +18,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
+#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/semihost.h"
diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 450ef78a3d..3f5f8e8cb5 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -18,6 +18,7 @@
* <http://www.gnu.org/licenses/gpl-2.0.html>
*/
+#include "qemu/osdep.h"
#include "cpu.h"
#include "internals.h"
#include "qemu-common.h"
diff --git a/target-arm/cpu64.c b/target-arm/cpu64.c
index 63c8b1cfa9..5f8a177475 100644
--- a/target-arm/cpu64.c
+++ b/target-arm/cpu64.c
@@ -18,6 +18,7 @@
* <http://www.gnu.org/licenses/gpl-2.0.html>
*/
+#include "qemu/osdep.h"
#include "cpu.h"
#include "qemu-common.h"
#if !defined(CONFIG_USER_ONLY)
diff --git a/target-arm/crypto_helper.c b/target-arm/crypto_helper.c
index 5d22838065..3b6df3f41a 100644
--- a/target-arm/crypto_helper.c
+++ b/target-arm/crypto_helper.c
@@ -9,7 +9,7 @@
* version 2 of the License, or (at your option) any later version.
*/
-#include <stdlib.h>
+#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
diff --git a/target-arm/gdbstub.c b/target-arm/gdbstub.c
index 1c3439654f..08b91a4861 100644
--- a/target-arm/gdbstub.c
+++ b/target-arm/gdbstub.c
@@ -17,7 +17,7 @@
* 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/>.
*/
-#include "config.h"
+#include "qemu/osdep.h"
#include "qemu-common.h"
#include "exec/gdbstub.h"
diff --git a/target-arm/gdbstub64.c b/target-arm/gdbstub64.c
index 8f3b8d1778..634c6bc6f2 100644
--- a/target-arm/gdbstub64.c
+++ b/target-arm/gdbstub64.c
@@ -16,7 +16,7 @@
* 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/>.
*/
-#include "config.h"
+#include "qemu/osdep.h"
#include "qemu-common.h"
#include "exec/gdbstub.h"
diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
index fc3ccdf2a7..01f3958b90 100644
--- a/target-arm/helper-a64.c
+++ b/target-arm/helper-a64.c
@@ -17,6 +17,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/gdbstub.h"
#include "exec/helper-proto.h"
diff --git a/target-arm/helper.c b/target-arm/helper.c
index faeaaa806a..f956b67ded 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
#include "cpu.h"
#include "internals.h"
#include "exec/gdbstub.h"
diff --git a/target-arm/iwmmxt_helper.c b/target-arm/iwmmxt_helper.c
index a5069144d1..7d87e1a0a8 100644
--- a/target-arm/iwmmxt_helper.c
+++ b/target-arm/iwmmxt_helper.c
@@ -19,8 +19,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-#include <stdio.h>
+#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
diff --git a/target-arm/kvm-stub.c b/target-arm/kvm-stub.c
index db2edc2c4c..38bf433876 100644
--- a/target-arm/kvm-stub.c
+++ b/target-arm/kvm-stub.c
@@ -9,6 +9,7 @@
* See the COPYING file in the top-level directory.
*
*/
+#include "qemu/osdep.h"
#include "qemu-common.h"
#include "kvm_arm.h"
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index eca3a0037d..969ab0bab5 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -8,8 +8,7 @@
*
*/
-#include <stdio.h>
-#include <sys/types.h>
+#include "qemu/osdep.h"
#include <sys/ioctl.h>
#include <sys/mman.h>
diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
index ff83ce6757..ea01932a65 100644
--- a/target-arm/kvm32.c
+++ b/target-arm/kvm32.c
@@ -8,8 +8,7 @@
*
*/
-#include <stdio.h>
-#include <sys/types.h>
+#include "qemu/osdep.h"
#include <sys/ioctl.h>
#include <sys/mman.h>
diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
index bb9531f33c..0f1b4d6a00 100644
--- a/target-arm/kvm64.c
+++ b/target-arm/kvm64.c
@@ -9,8 +9,7 @@
*
*/
-#include <stdio.h>
-#include <sys/types.h>
+#include "qemu/osdep.h"
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/ptrace.h>
@@ -18,7 +17,6 @@
#include <linux/elf.h>
#include <linux/kvm.h>
-#include "config-host.h"
#include "qemu-common.h"
#include "qemu/timer.h"
#include "qemu/error-report.h"
diff --git a/target-arm/machine.c b/target-arm/machine.c
index b1e1418a6e..ed1925ae3e 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/boards.h"
#include "qemu/error-report.h"
diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 47d13e908c..1f1844f5b2 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -6,8 +6,7 @@
*
* This code is licensed under the GNU GPL v2.
*/
-#include <stdlib.h>
-#include <stdio.h>
+#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index 951fc5ae51..7b6b3fd97c 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -16,6 +16,7 @@
* 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/>.
*/
+#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/helper-proto.h"
#include "internals.h"
diff --git a/target-arm/psci.c b/target-arm/psci.c
index 20e4cb6f9c..c55487f872 100644
--- a/target-arm/psci.c
+++ b/target-arm/psci.c
@@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "qemu/osdep.h"
#include <cpu.h>
#include <cpu-qom.h>
#include <exec/helper-proto.h>
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
index 14e8131b05..80f6c2058c 100644
--- a/target-arm/translate-a64.c
+++ b/target-arm/translate-a64.c
@@ -16,11 +16,7 @@
* 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/>.
*/
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
+#include "qemu/osdep.h"
#include "cpu.h"
#include "tcg-op.h"
diff --git a/target-arm/translate.c b/target-arm/translate.c
index d485e7d9c3..cff511b9c6 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -18,11 +18,7 @@
* 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/>.
*/
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
+#include "qemu/osdep.h"
#include "cpu.h"
#include "internals.h"