qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/14] More #include cleanups
@ 2016-02-09 15:24 Peter Maydell
  2016-02-09 15:24 ` [Qemu-devel] [PATCH 01/14] cpu: Clean up includes Peter Maydell
                   ` (15 more replies)
  0 siblings, 16 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

This set of patches does a bunch more cleaning of includes.
Specifically it does everything necessary to be able to
remove osdep.h includes from header files including qemu-common.h

Most of these patches are small, except for the one which
deals with tests/ (that one has already been reviewed).
There are several patches which fix code generators to
generate correct #includes, and some which do manual changes
to C++ or other files that Coccinelle barfs on.

The "all:" patch is running clean-includes on the whole
tree to pick up some new files which have been added
recently (mostly via target-arm).

I've thrown in a couple of patches that have already appeared
on list, just to get the whole set into one series.

I have some pending patches which:
 * enhance clean-includes to handle header files
 * clean up header files
 * add a --all option to clean-includes to do a "run clean
   on whole tree"

but I'd like to get the "add missing includes to .c files"
parts into master before moving onto "remove includes from .h
files" part...

thanks
-- PMM

Eric Blake (1):
  qapi: Clean up includes in generated files

Peter Maydell (13):
  cpu: Clean up includes
  ui/cocoa.m: Include qemu/osdep.h
  disas/arm-a64.cc: Include osdep.h first
  hw/block/nand.c: Include osdep.h first
  target-cris: Remove unnecessary ifdef from mmu.c
  cris: Clean up includes
  libdecnumber: Clean up includes
  tests/i440fx-test: Don't define ARRAY_SIZE locally
  tests: Clean up includes
  scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h
  scripts/tracetool: Include qemu/osdep.h in generated .c files
  all: Clean up includes
  oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h

 disas/arm-a64.cc                         |  5 +++--
 hw/arm/bcm2835_peripherals.c             |  1 +
 hw/arm/bcm2836.c                         |  1 +
 hw/arm/raspi.c                           |  1 +
 hw/block/nand.c                          |  5 +++--
 hw/intc/bcm2835_ic.c                     |  1 +
 hw/intc/bcm2836_control.c                |  1 +
 hw/misc/bcm2835_mbox.c                   |  1 +
 hw/misc/bcm2835_property.c               |  1 +
 include/qemu/osdep.h                     | 11 +++++++++++
 libdecnumber/decContext.c                |  3 +--
 libdecnumber/decNumber.c                 |  5 +----
 libdecnumber/dpd/decimal128.c            |  3 +--
 libdecnumber/dpd/decimal32.c             |  3 +--
 libdecnumber/dpd/decimal64.c             |  3 +--
 qom/cpu.c                                |  1 +
 scripts/feature_to_c.sh                  |  2 +-
 scripts/qapi-commands.py                 |  1 +
 scripts/qapi-event.py                    |  1 +
 scripts/qapi-introspect.py               |  3 ++-
 scripts/qapi-types.py                    |  3 +--
 scripts/qapi-visit.py                    |  1 +
 scripts/tracetool/backend/simple.py      |  3 ++-
 scripts/tracetool/format/events_c.py     |  1 +
 scripts/tracetool/format/tcg_helper_c.py |  1 +
 stubs/blockdev-close-all-bdrv-states.c   |  1 +
 target-cris/mmu.c                        |  4 +---
 target-i386/cpu.c                        |  5 +----
 tests/ac97-test.c                        |  3 +--
 tests/bios-tables-test.c                 |  4 +---
 tests/boot-order-test.c                  |  2 +-
 tests/check-qdict.c                      |  1 +
 tests/check-qfloat.c                     |  1 +
 tests/check-qint.c                       |  1 +
 tests/check-qjson.c                      |  1 +
 tests/check-qlist.c                      |  1 +
 tests/check-qom-interface.c              |  1 +
 tests/check-qom-proplist.c               |  1 +
 tests/check-qstring.c                    |  1 +
 tests/crypto-tls-x509-helpers.c          |  4 +---
 tests/device-introspect-test.c           |  2 +-
 tests/display-vga-test.c                 |  3 +--
 tests/drive_del-test.c                   |  2 +-
 tests/ds1338-test.c                      |  1 +
 tests/e1000-test.c                       |  3 +--
 tests/eepro100-test.c                    |  3 +--
 tests/endianness-test.c                  |  5 +----
 tests/es1370-test.c                      |  3 +--
 tests/fdc-test.c                         |  4 +---
 tests/fw_cfg-test.c                      |  2 +-
 tests/hd-geo-test.c                      |  4 +---
 tests/i440fx-test.c                      |  8 +-------
 tests/i82801b11-test.c                   |  3 +--
 tests/intel-hda-test.c                   |  3 +--
 tests/io-channel-helpers.c               |  1 +
 tests/ioh3420-test.c                     |  3 +--
 tests/ipmi-bt-test.c                     |  5 +----
 tests/ipmi-kcs-test.c                    |  4 +---
 tests/ipoctal232-test.c                  |  3 +--
 tests/ivshmem-test.c                     |  6 +-----
 tests/libqos/fw_cfg.c                    |  1 +
 tests/libqos/i2c-imx.c                   |  3 +--
 tests/libqos/i2c-omap.c                  |  3 +--
 tests/libqos/i2c.c                       |  1 +
 tests/libqos/libqos-pc.c                 |  1 +
 tests/libqos/libqos.c                    |  6 +-----
 tests/libqos/malloc-generic.c            |  1 +
 tests/libqos/malloc-pc.c                 |  1 +
 tests/libqos/malloc.c                    |  3 +--
 tests/libqos/pci-pc.c                    |  1 +
 tests/libqos/pci.c                       |  1 +
 tests/libqos/usb.c                       |  3 +--
 tests/libqos/virtio-mmio.c               |  2 +-
 tests/libqos/virtio-pci.c                |  2 +-
 tests/libqos/virtio.c                    |  1 +
 tests/libqtest.c                         | 12 ++----------
 tests/m48t59-test.c                      |  5 +----
 tests/ne2000-test.c                      |  3 +--
 tests/nvme-test.c                        |  3 +--
 tests/pc-cpu-test.c                      |  3 +--
 tests/pcnet-test.c                       |  3 +--
 tests/pkix_asn1_tab.c                    |  1 +
 tests/pvpanic-test.c                     |  3 +--
 tests/q35-test.c                         |  3 +--
 tests/qemu-iotests/socket_scm_helper.c   |  8 +-------
 tests/qom-test.c                         |  3 +--
 tests/rcutorture.c                       |  5 +----
 tests/rtc-test.c                         |  5 +----
 tests/rtl8139-test.c                     |  3 +--
 tests/spapr-phb-test.c                   |  1 +
 tests/tco-test.c                         |  4 +---
 tests/test-aio.c                         |  1 +
 tests/test-base64.c                      |  1 +
 tests/test-bitops.c                      |  3 +--
 tests/test-blockjob-txn.c                |  2 +-
 tests/test-coroutine.c                   |  1 +
 tests/test-crypto-cipher.c               |  1 +
 tests/test-crypto-hash.c                 |  1 +
 tests/test-crypto-secret.c               |  1 +
 tests/test-crypto-tlscredsx509.c         |  4 +---
 tests/test-crypto-tlssession.c           |  4 +---
 tests/test-cutils.c                      |  3 +--
 tests/test-hbitmap.c                     |  4 +---
 tests/test-int128.c                      |  3 +--
 tests/test-io-channel-buffer.c           |  1 +
 tests/test-io-channel-command.c          |  1 +
 tests/test-io-channel-file.c             |  1 +
 tests/test-io-channel-socket.c           |  1 +
 tests/test-io-channel-tls.c              |  4 +---
 tests/test-io-task.c                     |  1 +
 tests/test-iov.c                         |  1 +
 tests/test-mul64.c                       |  3 +--
 tests/test-netfilter.c                   |  1 +
 tests/test-opts-visitor.c                |  1 +
 tests/test-qdev-global-props.c           |  2 +-
 tests/test-qemu-opts.c                   |  3 +--
 tests/test-qga.c                         |  9 +--------
 tests/test-qmp-commands.c                |  1 +
 tests/test-qmp-event.c                   |  2 +-
 tests/test-qmp-input-strict.c            |  2 +-
 tests/test-qmp-input-visitor.c           |  2 +-
 tests/test-qmp-output-visitor.c          |  1 +
 tests/test-rcu-list.c                    |  6 +-----
 tests/test-rfifolock.c                   |  1 +
 tests/test-string-input-visitor.c        |  2 +-
 tests/test-string-output-visitor.c       |  1 +
 tests/test-thread-pool.c                 |  1 +
 tests/test-throttle.c                    |  1 +
 tests/test-timed-average.c               |  2 +-
 tests/test-visitor-serialization.c       |  3 +--
 tests/test-vmstate.c                     |  1 +
 tests/test-write-threshold.c             |  2 +-
 tests/test-x86-cpuid.c                   |  1 +
 tests/test-xbzrle.c                      |  6 +-----
 tests/tmp105-test.c                      |  1 +
 tests/tpci200-test.c                     |  3 +--
 tests/vhost-user-bridge.c                | 12 +-----------
 tests/vhost-user-test.c                  |  1 +
 tests/virtio-balloon-test.c              |  3 +--
 tests/virtio-blk-test.c                  |  5 +----
 tests/virtio-console-test.c              |  3 +--
 tests/virtio-net-test.c                  |  3 +--
 tests/virtio-rng-test.c                  |  3 +--
 tests/virtio-scsi-test.c                 |  4 +---
 tests/virtio-serial-test.c               |  3 +--
 tests/vmxnet3-test.c                     |  3 +--
 tests/wdt_ib700-test.c                   |  3 +--
 ui/cocoa.m                               |  2 ++
 util/oslib-posix.c                       |  9 ---------
 149 files changed, 166 insertions(+), 241 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 01/14] cpu: Clean up includes
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
@ 2016-02-09 15:24 ` Peter Maydell
  2016-02-12 14:49   ` Andreas Färber
  2016-02-09 15:24 ` [Qemu-devel] [PATCH 02/14] ui/cocoa.m: Include qemu/osdep.h Peter Maydell
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 qom/cpu.c         | 1 +
 target-i386/cpu.c | 5 +----
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/qom/cpu.c b/qom/cpu.c
index 38dc713..651a335 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -18,6 +18,7 @@
  * <http://www.gnu.org/licenses/gpl-2.0.html>
  */
 
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qom/cpu.h"
 #include "sysemu/kvm.h"
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b255644..c045be0 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -16,10 +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 <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
+#include "qemu/osdep.h"
 
 #include "cpu.h"
 #include "sysemu/kvm.h"
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 02/14] ui/cocoa.m: Include qemu/osdep.h
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
  2016-02-09 15:24 ` [Qemu-devel] [PATCH 01/14] cpu: Clean up includes Peter Maydell
@ 2016-02-09 15:24 ` Peter Maydell
  2016-02-09 16:07   ` Eric Blake
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first Peter Maydell
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

Include "qemu/osdep.h". (This is a manual commit equivalent
to what the clean-includes script would do, because that
script can't handle ObjectiveC source files.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 ui/cocoa.m | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index d866f23..3ee5549 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -22,6 +22,8 @@
  * THE SOFTWARE.
  */
 
+#include "qemu/osdep.h"
+
 #import <Cocoa/Cocoa.h>
 #include <crt_externs.h>
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
  2016-02-09 15:24 ` [Qemu-devel] [PATCH 01/14] cpu: Clean up includes Peter Maydell
  2016-02-09 15:24 ` [Qemu-devel] [PATCH 02/14] ui/cocoa.m: Include qemu/osdep.h Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-18 15:49   ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 04/14] hw/block/nand.c: " Peter Maydell
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

Rearrange include directives so that we include osdep.h first.
This has to be done manually because clean-includes doesn't
handle C++.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 disas/arm-a64.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc
index d4d46d5..9280950 100644
--- a/disas/arm-a64.cc
+++ b/disas/arm-a64.cc
@@ -17,12 +17,13 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "vixl/a64/disasm-a64.h"
-
 extern "C" {
+#include "qemu/osdep.h"
 #include "disas/bfd.h"
 }
 
+#include "vixl/a64/disasm-a64.h"
+
 using namespace vixl;
 
 static Decoder *vixl_decoder = NULL;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 04/14] hw/block/nand.c: Include osdep.h first
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (2 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 05/14] target-cris: Remove unnecessary ifdef from mmu.c Peter Maydell
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

Include osdep.h as the first header in nand.c; this has to be
done manually because coccinelle gets confused by the way that
this C file includes itself.

We fix some odd spacing in #includes while we are in the area.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/block/nand.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/block/nand.c b/hw/block/nand.c
index 478e1a6..f51e13f 100644
--- a/hw/block/nand.c
+++ b/hw/block/nand.c
@@ -18,8 +18,9 @@
 
 #ifndef NAND_IO
 
-# include "hw/hw.h"
-# include "hw/block/flash.h"
+#include "qemu/osdep.h"
+#include "hw/hw.h"
+#include "hw/block/flash.h"
 #include "sysemu/block-backend.h"
 #include "hw/qdev.h"
 #include "qemu/error-report.h"
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 05/14] target-cris: Remove unnecessary ifdef from mmu.c
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (3 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 04/14] hw/block/nand.c: " Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 06/14] cris: Clean up includes Peter Maydell
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

mmu.c is only built for CONFIG_SOFTMMU targets, so there is
no need to redundantly surround the whole file contents with
an #ifndef CONFIG_USER_ONLY. The ifdef also confuses the
Coccinelle tool.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-cris/mmu.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/target-cris/mmu.c b/target-cris/mmu.c
index 1c95a41..4a9c595 100644
--- a/target-cris/mmu.c
+++ b/target-cris/mmu.c
@@ -18,8 +18,6 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef CONFIG_USER_ONLY
-
 #include "cpu.h"
 #include "mmu.h"
 
@@ -360,4 +358,3 @@ int cris_mmu_translate(struct cris_mmu_result *res,
 	env->pregs[PR_SRS] = old_srs;
 	return miss;
 }
-#endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 06/14] cris: Clean up includes
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (4 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 05/14] target-cris: Remove unnecessary ifdef from mmu.c Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 07/14] libdecnumber: " Peter Maydell
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-cris/mmu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target-cris/mmu.c b/target-cris/mmu.c
index 4a9c595..4278d2d 100644
--- a/target-cris/mmu.c
+++ b/target-cris/mmu.c
@@ -18,6 +18,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu/osdep.h"
 #include "cpu.h"
 #include "mmu.h"
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 07/14] libdecnumber: Clean up includes
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (5 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 06/14] cris: Clean up includes Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 08/14] tests/i440fx-test: Don't define ARRAY_SIZE locally Peter Maydell
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 libdecnumber/decContext.c     | 3 +--
 libdecnumber/decNumber.c      | 5 +----
 libdecnumber/dpd/decimal128.c | 3 +--
 libdecnumber/dpd/decimal32.c  | 3 +--
 libdecnumber/dpd/decimal64.c  | 3 +--
 5 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/libdecnumber/decContext.c b/libdecnumber/decContext.c
index 68e6f60..7d97a65 100644
--- a/libdecnumber/decContext.c
+++ b/libdecnumber/decContext.c
@@ -35,8 +35,7 @@
 /* context structures.						      */
 /* ------------------------------------------------------------------ */
 
-#include <string.h>	      /* for strcmp */
-#include <stdio.h>	      /* for printf if DECCHECK */
+#include "qemu/osdep.h"
 #include "libdecnumber/dconfig.h"
 #include "libdecnumber/decContext.h"
 #include "libdecnumber/decNumberLocal.h"
diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index ca1412f..c9e7807 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -166,10 +166,7 @@
 /*	**  -- raise to the power				      */
 /* ------------------------------------------------------------------ */
 
-#include <stdlib.h>		   /* for malloc, free, etc. */
-#include <stdio.h>		   /* for printf [if needed] */
-#include <string.h>		   /* for strcpy */
-#include <ctype.h>		   /* for lower */
+#include "qemu/osdep.h"
 #include "libdecnumber/dconfig.h"
 #include "libdecnumber/decNumber.h"
 #include "libdecnumber/decNumberLocal.h"
diff --git a/libdecnumber/dpd/decimal128.c b/libdecnumber/dpd/decimal128.c
index 7551b7c..ca4764e 100644
--- a/libdecnumber/dpd/decimal128.c
+++ b/libdecnumber/dpd/decimal128.c
@@ -39,8 +39,7 @@
 /*								      */
 /* Error handling is the same as decNumber (qv.).		      */
 /* ------------------------------------------------------------------ */
-#include <string.h>	      /* [for memset/memcpy] */
-#include <stdio.h>	      /* [for printf] */
+#include "qemu/osdep.h"
 
 #include "libdecnumber/dconfig.h"
 #define	 DECNUMDIGITS 34      /* make decNumbers with space for 34 */
diff --git a/libdecnumber/dpd/decimal32.c b/libdecnumber/dpd/decimal32.c
index 095ab75..53f2978 100644
--- a/libdecnumber/dpd/decimal32.c
+++ b/libdecnumber/dpd/decimal32.c
@@ -39,8 +39,7 @@
 /*								      */
 /* Error handling is the same as decNumber (qv.).		      */
 /* ------------------------------------------------------------------ */
-#include <string.h>	      /* [for memset/memcpy] */
-#include <stdio.h>	      /* [for printf] */
+#include "qemu/osdep.h"
 
 #include "libdecnumber/dconfig.h"
 #define	 DECNUMDIGITS  7      /* make decNumbers with space for 7 */
diff --git a/libdecnumber/dpd/decimal64.c b/libdecnumber/dpd/decimal64.c
index 8256084..4816176 100644
--- a/libdecnumber/dpd/decimal64.c
+++ b/libdecnumber/dpd/decimal64.c
@@ -39,8 +39,7 @@
 /*								      */
 /* Error handling is the same as decNumber (qv.).		      */
 /* ------------------------------------------------------------------ */
-#include <string.h>	      /* [for memset/memcpy] */
-#include <stdio.h>	      /* [for printf] */
+#include "qemu/osdep.h"
 
 #include "libdecnumber/dconfig.h"
 #define	 DECNUMDIGITS 16      /* make decNumbers with space for 16 */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 08/14] tests/i440fx-test: Don't define ARRAY_SIZE locally
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (6 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 07/14] libdecnumber: " Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 09/14] tests: Clean up includes Peter Maydell
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

Don't define ARRAY_SIZE locally; instead include osdep.h for it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 tests/i440fx-test.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
index 7fa1709..0665caf 100644
--- a/tests/i440fx-test.c
+++ b/tests/i440fx-test.c
@@ -12,6 +12,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include <string.h>
 #include <stdio.h>
@@ -27,8 +28,6 @@
 
 #define BROKEN 1
 
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
-
 typedef struct TestData
 {
     int num_cpus;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 09/14] tests: Clean up includes
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (7 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 08/14] tests/i440fx-test: Don't define ARRAY_SIZE locally Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 10/14] qapi: Clean up includes in generated files Peter Maydell
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Eric Blake <eblake@redhat.com>
---
This deals with every .c file in tests/ except those
in tests/tcg and tests/multiboot which I think are all
standalone programs targeting the guest.
---
 tests/ac97-test.c                      |  3 +--
 tests/bios-tables-test.c               |  4 +---
 tests/boot-order-test.c                |  2 +-
 tests/check-qdict.c                    |  1 +
 tests/check-qfloat.c                   |  1 +
 tests/check-qint.c                     |  1 +
 tests/check-qjson.c                    |  1 +
 tests/check-qlist.c                    |  1 +
 tests/check-qom-interface.c            |  1 +
 tests/check-qom-proplist.c             |  1 +
 tests/check-qstring.c                  |  1 +
 tests/crypto-tls-x509-helpers.c        |  4 +---
 tests/device-introspect-test.c         |  2 +-
 tests/display-vga-test.c               |  3 +--
 tests/drive_del-test.c                 |  2 +-
 tests/ds1338-test.c                    |  1 +
 tests/e1000-test.c                     |  3 +--
 tests/eepro100-test.c                  |  3 +--
 tests/endianness-test.c                |  5 +----
 tests/es1370-test.c                    |  3 +--
 tests/fdc-test.c                       |  4 +---
 tests/fw_cfg-test.c                    |  2 +-
 tests/hd-geo-test.c                    |  4 +---
 tests/i440fx-test.c                    |  5 -----
 tests/i82801b11-test.c                 |  3 +--
 tests/intel-hda-test.c                 |  3 +--
 tests/io-channel-helpers.c             |  1 +
 tests/ioh3420-test.c                   |  3 +--
 tests/ipmi-bt-test.c                   |  5 +----
 tests/ipmi-kcs-test.c                  |  4 +---
 tests/ipoctal232-test.c                |  3 +--
 tests/ivshmem-test.c                   |  6 +-----
 tests/libqos/fw_cfg.c                  |  1 +
 tests/libqos/i2c-imx.c                 |  3 +--
 tests/libqos/i2c-omap.c                |  3 +--
 tests/libqos/i2c.c                     |  1 +
 tests/libqos/libqos-pc.c               |  1 +
 tests/libqos/libqos.c                  |  6 +-----
 tests/libqos/malloc-generic.c          |  1 +
 tests/libqos/malloc-pc.c               |  1 +
 tests/libqos/malloc.c                  |  3 +--
 tests/libqos/pci-pc.c                  |  1 +
 tests/libqos/pci.c                     |  1 +
 tests/libqos/usb.c                     |  3 +--
 tests/libqos/virtio-mmio.c             |  2 +-
 tests/libqos/virtio-pci.c              |  2 +-
 tests/libqos/virtio.c                  |  1 +
 tests/libqtest.c                       | 12 ++----------
 tests/m48t59-test.c                    |  5 +----
 tests/ne2000-test.c                    |  3 +--
 tests/nvme-test.c                      |  3 +--
 tests/pc-cpu-test.c                    |  3 +--
 tests/pcnet-test.c                     |  3 +--
 tests/pkix_asn1_tab.c                  |  1 +
 tests/pvpanic-test.c                   |  3 +--
 tests/q35-test.c                       |  3 +--
 tests/qemu-iotests/socket_scm_helper.c |  8 +-------
 tests/qom-test.c                       |  3 +--
 tests/rcutorture.c                     |  5 +----
 tests/rtc-test.c                       |  5 +----
 tests/rtl8139-test.c                   |  3 +--
 tests/spapr-phb-test.c                 |  1 +
 tests/tco-test.c                       |  4 +---
 tests/test-aio.c                       |  1 +
 tests/test-base64.c                    |  1 +
 tests/test-bitops.c                    |  3 +--
 tests/test-blockjob-txn.c              |  2 +-
 tests/test-coroutine.c                 |  1 +
 tests/test-crypto-cipher.c             |  1 +
 tests/test-crypto-hash.c               |  1 +
 tests/test-crypto-secret.c             |  1 +
 tests/test-crypto-tlscredsx509.c       |  4 +---
 tests/test-crypto-tlssession.c         |  4 +---
 tests/test-cutils.c                    |  3 +--
 tests/test-hbitmap.c                   |  4 +---
 tests/test-int128.c                    |  3 +--
 tests/test-io-channel-buffer.c         |  1 +
 tests/test-io-channel-command.c        |  1 +
 tests/test-io-channel-file.c           |  1 +
 tests/test-io-channel-socket.c         |  1 +
 tests/test-io-channel-tls.c            |  4 +---
 tests/test-io-task.c                   |  1 +
 tests/test-iov.c                       |  1 +
 tests/test-mul64.c                     |  3 +--
 tests/test-netfilter.c                 |  1 +
 tests/test-opts-visitor.c              |  1 +
 tests/test-qdev-global-props.c         |  2 +-
 tests/test-qemu-opts.c                 |  3 +--
 tests/test-qga.c                       |  9 +--------
 tests/test-qmp-commands.c              |  1 +
 tests/test-qmp-event.c                 |  2 +-
 tests/test-qmp-input-strict.c          |  2 +-
 tests/test-qmp-input-visitor.c         |  2 +-
 tests/test-qmp-output-visitor.c        |  1 +
 tests/test-rcu-list.c                  |  6 +-----
 tests/test-rfifolock.c                 |  1 +
 tests/test-string-input-visitor.c      |  2 +-
 tests/test-string-output-visitor.c     |  1 +
 tests/test-thread-pool.c               |  1 +
 tests/test-throttle.c                  |  1 +
 tests/test-timed-average.c             |  2 +-
 tests/test-visitor-serialization.c     |  3 +--
 tests/test-vmstate.c                   |  1 +
 tests/test-write-threshold.c           |  2 +-
 tests/test-x86-cpuid.c                 |  1 +
 tests/test-xbzrle.c                    |  6 +-----
 tests/tmp105-test.c                    |  1 +
 tests/tpci200-test.c                   |  3 +--
 tests/vhost-user-bridge.c              | 12 +-----------
 tests/vhost-user-test.c                |  1 +
 tests/virtio-balloon-test.c            |  3 +--
 tests/virtio-blk-test.c                |  5 +----
 tests/virtio-console-test.c            |  3 +--
 tests/virtio-net-test.c                |  3 +--
 tests/virtio-rng-test.c                |  3 +--
 tests/virtio-scsi-test.c               |  4 +---
 tests/virtio-serial-test.c             |  3 +--
 tests/vmxnet3-test.c                   |  3 +--
 tests/wdt_ib700-test.c                 |  3 +--
 119 files changed, 119 insertions(+), 202 deletions(-)

diff --git a/tests/ac97-test.c b/tests/ac97-test.c
index af30ea1..75cab8f 100644
--- a/tests/ac97-test.c
+++ b/tests/ac97-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 75ec330..7155fec 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -10,13 +10,11 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include <string.h>
-#include <stdio.h>
+#include "qemu/osdep.h"
 #include <glib.h>
 #include <glib/gstdio.h>
 #include "qemu-common.h"
 #include "libqtest.h"
-#include "qemu/compiler.h"
 #include "hw/acpi/acpi-defs.h"
 #include "hw/smbios/smbios.h"
 #include "qemu/bitmap.h"
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 360a691..210964a 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -10,7 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include <string.h>
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "libqos/fw_cfg.h"
 #include "libqtest.h"
diff --git a/tests/check-qdict.c b/tests/check-qdict.c
index a136f2a..a43056c 100644
--- a/tests/check-qdict.c
+++ b/tests/check-qdict.c
@@ -9,6 +9,7 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  * See the COPYING.LIB file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qapi/qmp/qint.h"
diff --git a/tests/check-qfloat.c b/tests/check-qfloat.c
index 6404ac8..3102608 100644
--- a/tests/check-qfloat.c
+++ b/tests/check-qfloat.c
@@ -10,6 +10,7 @@
  * See the COPYING.LIB file in the top-level directory.
  *
  */
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qapi/qmp/qfloat.h"
diff --git a/tests/check-qint.c b/tests/check-qint.c
index 8686884..c86f7df 100644
--- a/tests/check-qint.c
+++ b/tests/check-qint.c
@@ -9,6 +9,7 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  * See the COPYING.LIB file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qapi/qmp/qint.h"
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 61e9bfb..99de6f5 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -10,6 +10,7 @@
  * See the COPYING.LIB file in the top-level directory.
  *
  */
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qapi/qmp/qstring.h"
diff --git a/tests/check-qlist.c b/tests/check-qlist.c
index b9c05d4..f231d5f 100644
--- a/tests/check-qlist.c
+++ b/tests/check-qlist.c
@@ -9,6 +9,7 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  * See the COPYING.LIB file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qapi/qmp/qint.h"
diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
index f06380e..09354de 100644
--- a/tests/check-qom-interface.c
+++ b/tests/check-qom-interface.c
@@ -9,6 +9,7 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  * See the COPYING.LIB file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qom/object.h"
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index 448d270..a2bb556 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -18,6 +18,7 @@
  * Author: Daniel P. Berrange <berrange@redhat.com>
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qom/object.h"
diff --git a/tests/check-qstring.c b/tests/check-qstring.c
index 95dc9e3..9877b42 100644
--- a/tests/check-qstring.c
+++ b/tests/check-qstring.c
@@ -9,6 +9,7 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  * See the COPYING.LIB file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qapi/qmp/qstring.h"
diff --git a/tests/crypto-tls-x509-helpers.c b/tests/crypto-tls-x509-helpers.c
index 47b4c7b..64073d3 100644
--- a/tests/crypto-tls-x509-helpers.c
+++ b/tests/crypto-tls-x509-helpers.c
@@ -18,10 +18,8 @@
  * Author: Daniel P. Berrange <berrange@redhat.com>
  */
 
-#include <stdlib.h>
-#include <fcntl.h>
+#include "qemu/osdep.h"
 
-#include "config-host.h"
 #include "crypto-tls-x509-helpers.h"
 #include "qemu/sockets.h"
 
diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c
index 11d5fea..4477926 100644
--- a/tests/device-introspect-test.c
+++ b/tests/device-introspect-test.c
@@ -17,8 +17,8 @@
  * bugs around here.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdarg.h>
 #include "qemu-common.h"
 #include "qapi/qmp/qstring.h"
 #include "libqtest.h"
diff --git a/tests/display-vga-test.c b/tests/display-vga-test.c
index 7694344..5706d33 100644
--- a/tests/display-vga-test.c
+++ b/tests/display-vga-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 static void pci_cirrus(void)
 {
diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c
index 3390946..fe03236 100644
--- a/tests/drive_del-test.c
+++ b/tests/drive_del-test.c
@@ -10,8 +10,8 @@
  * See the COPYING.LIB file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
 
 static void drive_add(void)
diff --git a/tests/ds1338-test.c b/tests/ds1338-test.c
index 7d513d8..2792415 100644
--- a/tests/ds1338-test.c
+++ b/tests/ds1338-test.c
@@ -17,6 +17,7 @@
  *  with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu/osdep.h"
 #include "libqtest.h"
 #include "libqos/i2c.h"
 
diff --git a/tests/e1000-test.c b/tests/e1000-test.c
index 7ca6d7e..a42b381 100644
--- a/tests/e1000-test.c
+++ b/tests/e1000-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void test_device(gconstpointer data)
diff --git a/tests/eepro100-test.c b/tests/eepro100-test.c
index 8bfaccd..e17eed0 100644
--- a/tests/eepro100-test.c
+++ b/tests/eepro100-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 static void test_device(gconstpointer data)
 {
diff --git a/tests/endianness-test.c b/tests/endianness-test.c
index 2054338..cc5bccd 100644
--- a/tests/endianness-test.c
+++ b/tests/endianness-test.c
@@ -11,11 +11,8 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
 
 #include "libqtest.h"
 #include "qemu/bswap.h"
diff --git a/tests/es1370-test.c b/tests/es1370-test.c
index cc23fb5..824dc31 100644
--- a/tests/es1370-test.c
+++ b/tests/es1370-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index dbabf50..53df1d0 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -22,9 +22,7 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
+#include "qemu/osdep.h"
 
 #include <glib.h>
 
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index b7d4007..398643a 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -10,7 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include <string.h>
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "libqtest.h"
diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c
index 13b763d..c8e669a 100644
--- a/tests/hd-geo-test.c
+++ b/tests/hd-geo-test.c
@@ -15,10 +15,8 @@
  * Improvements welcome.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
 #include "qemu-common.h"
 #include "libqtest.h"
 
diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
index 0665caf..05029e9 100644
--- a/tests/i440fx-test.c
+++ b/tests/i440fx-test.c
@@ -14,12 +14,7 @@
 
 #include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
 #include <sys/mman.h>
-#include <stdlib.h>
 
 #include "libqtest.h"
 #include "libqos/pci.h"
diff --git a/tests/i82801b11-test.c b/tests/i82801b11-test.c
index 78d9ce0..c3b5ebb 100644
--- a/tests/i82801b11-test.c
+++ b/tests/i82801b11-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
diff --git a/tests/intel-hda-test.c b/tests/intel-hda-test.c
index d89b407..1be6add 100644
--- a/tests/intel-hda-test.c
+++ b/tests/intel-hda-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 #define HDA_ID "hda0"
 #define CODEC_DEVICES " -device hda-output,bus=" HDA_ID ".0" \
diff --git a/tests/io-channel-helpers.c b/tests/io-channel-helpers.c
index 78d36dd..8440669 100644
--- a/tests/io-channel-helpers.c
+++ b/tests/io-channel-helpers.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include "io-channel-helpers.h"
 
 struct QIOChannelTest {
diff --git a/tests/ioh3420-test.c b/tests/ioh3420-test.c
index c991a5f..93eb2f7 100644
--- a/tests/ioh3420-test.c
+++ b/tests/ioh3420-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
diff --git a/tests/ipmi-bt-test.c b/tests/ipmi-bt-test.c
index 5b7eb73..812907f 100644
--- a/tests/ipmi-bt-test.c
+++ b/tests/ipmi-bt-test.c
@@ -22,10 +22,7 @@
  * THE SOFTWARE.
  */
 
-#include <sys/types.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
+#include "qemu/osdep.h"
 
 #include <sys/socket.h>
 #include <netinet/in.h>
diff --git a/tests/ipmi-kcs-test.c b/tests/ipmi-kcs-test.c
index 564c470..42c4b97 100644
--- a/tests/ipmi-kcs-test.c
+++ b/tests/ipmi-kcs-test.c
@@ -22,9 +22,7 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
+#include "qemu/osdep.h"
 
 #include <glib.h>
 
diff --git a/tests/ipoctal232-test.c b/tests/ipoctal232-test.c
index 3ac1714..846aaf5 100644
--- a/tests/ipoctal232-test.c
+++ b/tests/ipoctal232-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index 705fece..e184c67 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -8,17 +8,13 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include <errno.h>
-#include <fcntl.h>
+#include "qemu/osdep.h"
 #include <glib.h>
 #include <glib/gstdio.h>
-#include <string.h>
 #include <sys/mman.h>
-#include <unistd.h>
 #include "contrib/ivshmem-server/ivshmem-server.h"
 #include "libqos/pci-pc.h"
 #include "libqtest.h"
-#include "qemu/osdep.h"
 #include "qemu-common.h"
 
 #define TMPSHMSIZE (1 << 20)
diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
index ef00fed..76894d5 100644
--- a/tests/libqos/fw_cfg.c
+++ b/tests/libqos/fw_cfg.c
@@ -12,6 +12,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "libqos/fw_cfg.h"
 #include "libqtest.h"
diff --git a/tests/libqos/i2c-imx.c b/tests/libqos/i2c-imx.c
index b5cef66..51c3468 100644
--- a/tests/libqos/i2c-imx.c
+++ b/tests/libqos/i2c-imx.c
@@ -17,12 +17,11 @@
  *  with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu/osdep.h"
 #include "libqos/i2c.h"
 
 #include <glib.h>
-#include <string.h>
 
-#include "qemu/osdep.h"
 #include "libqtest.h"
 
 #include "hw/i2c/imx_i2c.h"
diff --git a/tests/libqos/i2c-omap.c b/tests/libqos/i2c-omap.c
index 3d4d45d..2028f2f 100644
--- a/tests/libqos/i2c-omap.c
+++ b/tests/libqos/i2c-omap.c
@@ -6,12 +6,11 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include "libqos/i2c.h"
 
 #include <glib.h>
-#include <string.h>
 
-#include "qemu/osdep.h"
 #include "qemu/bswap.h"
 #include "libqtest.h"
 
diff --git a/tests/libqos/i2c.c b/tests/libqos/i2c.c
index da7592f..23bc2a3 100644
--- a/tests/libqos/i2c.c
+++ b/tests/libqos/i2c.c
@@ -6,6 +6,7 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include "libqos/i2c.h"
 #include "libqtest.h"
 
diff --git a/tests/libqos/libqos-pc.c b/tests/libqos/libqos-pc.c
index 1403699..72b5e3b 100644
--- a/tests/libqos/libqos-pc.c
+++ b/tests/libqos/libqos-pc.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "libqos/libqos-pc.h"
 #include "libqos/malloc-pc.h"
 
diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index 2d1a802..79b0b29 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -1,9 +1,5 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <unistd.h>
-#include <fcntl.h>
 #include <sys/wait.h>
 
 #include "libqtest.h"
diff --git a/tests/libqos/malloc-generic.c b/tests/libqos/malloc-generic.c
index d30a2f4..6000df2 100644
--- a/tests/libqos/malloc-generic.c
+++ b/tests/libqos/malloc-generic.c
@@ -7,6 +7,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "libqos/malloc-generic.h"
 #include "libqos/malloc.h"
diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
index 6e253b6..74f76c5 100644
--- a/tests/libqos/malloc-pc.c
+++ b/tests/libqos/malloc-pc.c
@@ -10,6 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include "libqos/malloc-pc.h"
 #include "libqos/fw_cfg.h"
 
diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c
index 19d05ca..c0df52f 100644
--- a/tests/libqos/malloc.c
+++ b/tests/libqos/malloc.c
@@ -10,10 +10,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include "libqos/malloc.h"
 #include "qemu-common.h"
-#include <stdio.h>
-#include <inttypes.h>
 #include <glib.h>
 
 typedef QTAILQ_HEAD(MemList, MemBlock) MemList;
diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
index 6dba0db..08167c0 100644
--- a/tests/libqos/pci-pc.c
+++ b/tests/libqos/pci-pc.c
@@ -10,6 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include "libqtest.h"
 #include "libqos/pci-pc.h"
 
diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c
index 80b1a21..0e104e1 100644
--- a/tests/libqos/pci.c
+++ b/tests/libqos/pci.c
@@ -10,6 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include "libqos/pci.h"
 
 #include "hw/pci/pci_regs.h"
diff --git a/tests/libqos/usb.c b/tests/libqos/usb.c
index 41d89b8..87efb90 100644
--- a/tests/libqos/usb.c
+++ b/tests/libqos/usb.c
@@ -11,10 +11,9 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 #include "hw/usb/uhci-regs.h"
 #include "libqos/usb.h"
 
diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c
index b3e62e7..a4382f3 100644
--- a/tests/libqos/virtio-mmio.c
+++ b/tests/libqos/virtio-mmio.c
@@ -7,8 +7,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdio.h>
 #include "libqtest.h"
 #include "libqos/virtio.h"
 #include "libqos/virtio-mmio.h"
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index f9fb924..fde2ff0 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -7,8 +7,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdio.h>
 #include "libqtest.h"
 #include "libqos/virtio.h"
 #include "libqos/virtio-pci.h"
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 3205b88..613dece 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -7,6 +7,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "libqtest.h"
 #include "libqos/virtio.h"
diff --git a/tests/libqtest.c b/tests/libqtest.c
index fa314e1..b12a9e4 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -14,22 +14,14 @@
  * See the COPYING file in the top-level directory.
  *
  */
+#include "qemu/osdep.h"
 #include "libqtest.h"
 
 #include <glib.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <sys/un.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "qemu/compiler.h"
-#include "qemu/osdep.h"
+
 #include "qapi/qmp/json-parser.h"
 #include "qapi/qmp/json-streamer.h"
 #include "qapi/qmp/qjson.h"
diff --git a/tests/m48t59-test.c b/tests/m48t59-test.c
index 71b4f28..a751fd3 100644
--- a/tests/m48t59-test.c
+++ b/tests/m48t59-test.c
@@ -12,11 +12,8 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
 
 #include "libqtest.h"
 
diff --git a/tests/ne2000-test.c b/tests/ne2000-test.c
index 61a678a..3727875 100644
--- a/tests/ne2000-test.c
+++ b/tests/ne2000-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void pci_nop(void)
diff --git a/tests/nvme-test.c b/tests/nvme-test.c
index ff38b5e..ec06893 100644
--- a/tests/nvme-test.c
+++ b/tests/nvme-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
diff --git a/tests/pc-cpu-test.c b/tests/pc-cpu-test.c
index 3505c7c..6b34ca5 100644
--- a/tests/pc-cpu-test.c
+++ b/tests/pc-cpu-test.c
@@ -7,12 +7,11 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 
 #include "qemu-common.h"
 #include "libqtest.h"
-#include "qemu/osdep.h"
 #include "qapi/qmp/types.h"
 
 struct PCTestData {
diff --git a/tests/pcnet-test.c b/tests/pcnet-test.c
index 84af4f3..2ddf496 100644
--- a/tests/pcnet-test.c
+++ b/tests/pcnet-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void pci_nop(void)
diff --git a/tests/pkix_asn1_tab.c b/tests/pkix_asn1_tab.c
index 5b4e6b9..903bc02 100644
--- a/tests/pkix_asn1_tab.c
+++ b/tests/pkix_asn1_tab.c
@@ -3,6 +3,7 @@
  * and is under copyright of various GNUTLS contributors.
  */
 
+#include "qemu/osdep.h"
 #include <libtasn1.h>
 
 const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
diff --git a/tests/pvpanic-test.c b/tests/pvpanic-test.c
index a7ad6b3..d435833 100644
--- a/tests/pvpanic-test.c
+++ b/tests/pvpanic-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 static void test_panic(void)
 {
diff --git a/tests/q35-test.c b/tests/q35-test.c
index 812abe5..a105f10 100644
--- a/tests/q35-test.c
+++ b/tests/q35-test.c
@@ -9,12 +9,11 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
 #include "libqos/pci.h"
 #include "libqos/pci-pc.h"
-#include "qemu/osdep.h"
 #include "hw/pci-host/q35.h"
 
 static void smram_set_bit(QPCIDevice *pcidev, uint8_t mask, bool enabled)
diff --git a/tests/qemu-iotests/socket_scm_helper.c b/tests/qemu-iotests/socket_scm_helper.c
index 8195983..80cadf4 100644
--- a/tests/qemu-iotests/socket_scm_helper.c
+++ b/tests/qemu-iotests/socket_scm_helper.c
@@ -10,15 +10,9 @@
  * See the COPYING.LIB file in the top-level directory.
  */
 
-#include <stdio.h>
-#include <errno.h>
+#include "qemu/osdep.h"
 #include <sys/socket.h>
 #include <sys/un.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
 
 /* #define SOCKET_SCM_DEBUG */
 
diff --git a/tests/qom-test.c b/tests/qom-test.c
index 3e5e873..3c6cfca 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -7,12 +7,11 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 
 #include "qemu-common.h"
 #include "libqtest.h"
-#include "qemu/osdep.h"
 #include "qapi/qmp/types.h"
 
 static const char *blacklist_x86[] = {
diff --git a/tests/rcutorture.c b/tests/rcutorture.c
index d6b304d..244f0f2 100644
--- a/tests/rcutorture.c
+++ b/tests/rcutorture.c
@@ -60,13 +60,10 @@
  * Test variables.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
 #include "qemu/atomic.h"
 #include "qemu/rcu.h"
-#include "qemu/compiler.h"
 #include "qemu/thread.h"
 
 long long n_reads = 0LL;
diff --git a/tests/rtc-test.c b/tests/rtc-test.c
index 4243624..fa7029a 100644
--- a/tests/rtc-test.c
+++ b/tests/rtc-test.c
@@ -11,11 +11,8 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
 
 #include "libqtest.h"
 #include "hw/timer/mc146818rtc_regs.h"
diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c
index ba62851..54e5aa7 100644
--- a/tests/rtl8139-test.c
+++ b/tests/rtl8139-test.c
@@ -7,11 +7,10 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
 #include "libqos/pci-pc.h"
-#include "qemu/osdep.h"
 #include "qemu/timer.h"
 #include "qemu-common.h"
 
diff --git a/tests/spapr-phb-test.c b/tests/spapr-phb-test.c
index b629de4..f53911d 100644
--- a/tests/spapr-phb-test.c
+++ b/tests/spapr-phb-test.c
@@ -7,6 +7,7 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "libqtest.h"
diff --git a/tests/tco-test.c b/tests/tco-test.c
index 419f7cf..ac11175 100644
--- a/tests/tco-test.c
+++ b/tests/tco-test.c
@@ -6,10 +6,8 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
 
 #include "libqtest.h"
 #include "libqos/pci.h"
diff --git a/tests/test-aio.c b/tests/test-aio.c
index 6ccea98..a109bd0 100644
--- a/tests/test-aio.c
+++ b/tests/test-aio.c
@@ -10,6 +10,7 @@
  * See the COPYING.LIB file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "block/aio.h"
 #include "qemu/timer.h"
diff --git a/tests/test-base64.c b/tests/test-base64.c
index a0ca2d8..ae0c107 100644
--- a/tests/test-base64.c
+++ b/tests/test-base64.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qemu/base64.h"
diff --git a/tests/test-bitops.c b/tests/test-bitops.c
index 47b5d3e..5050950 100644
--- a/tests/test-bitops.c
+++ b/tests/test-bitops.c
@@ -6,9 +6,8 @@
  *
  */
 
-#include <glib.h>
-#include <stdint.h>
 #include "qemu/osdep.h"
+#include <glib.h>
 #include "qemu/bitops.h"
 
 typedef struct {
diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c
index 34747e9..c866da6 100644
--- a/tests/test-blockjob-txn.c
+++ b/tests/test-blockjob-txn.c
@@ -10,8 +10,8 @@
  * See the COPYING.LIB file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include "qapi/error.h"
 #include "qemu/main-loop.h"
 #include "block/blockjob.h"
 
diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c
index f5951cb..dd4ced9 100644
--- a/tests/test-coroutine.c
+++ b/tests/test-coroutine.c
@@ -11,6 +11,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "qemu/coroutine.h"
 #include "qemu/coroutine_int.h"
diff --git a/tests/test-crypto-cipher.c b/tests/test-crypto-cipher.c
index c687307..9f912ec 100644
--- a/tests/test-crypto-cipher.c
+++ b/tests/test-crypto-cipher.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "crypto/init.h"
diff --git a/tests/test-crypto-hash.c b/tests/test-crypto-hash.c
index 3ec31dd..735d6d7 100644
--- a/tests/test-crypto-hash.c
+++ b/tests/test-crypto-hash.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "crypto/init.h"
diff --git a/tests/test-crypto-secret.c b/tests/test-crypto-secret.c
index a49c8e3..2bbc4d9 100644
--- a/tests/test-crypto-secret.c
+++ b/tests/test-crypto-secret.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "crypto/init.h"
diff --git a/tests/test-crypto-tlscredsx509.c b/tests/test-crypto-tlscredsx509.c
index c70aa55..7ca387d 100644
--- a/tests/test-crypto-tlscredsx509.c
+++ b/tests/test-crypto-tlscredsx509.c
@@ -18,10 +18,8 @@
  * Author: Daniel P. Berrange <berrange@redhat.com>
  */
 
-#include <stdlib.h>
-#include <fcntl.h>
+#include "qemu/osdep.h"
 
-#include "config-host.h"
 #include "crypto-tls-x509-helpers.h"
 #include "crypto/tlscredsx509.h"
 
diff --git a/tests/test-crypto-tlssession.c b/tests/test-crypto-tlssession.c
index 4524128..036a86b 100644
--- a/tests/test-crypto-tlssession.c
+++ b/tests/test-crypto-tlssession.c
@@ -18,10 +18,8 @@
  * Author: Daniel P. Berrange <berrange@redhat.com>
  */
 
-#include <stdlib.h>
-#include <fcntl.h>
+#include "qemu/osdep.h"
 
-#include "config-host.h"
 #include "crypto-tls-x509-helpers.h"
 #include "crypto/tlscredsx509.h"
 #include "crypto/tlssession.h"
diff --git a/tests/test-cutils.c b/tests/test-cutils.c
index a3de6ab..398700d 100644
--- a/tests/test-cutils.c
+++ b/tests/test-cutils.c
@@ -25,9 +25,8 @@
  * THE SOFTWARE.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <errno.h>
-#include <string.h>
 
 #include "qemu-common.h"
 
diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c
index abcea0c..abe1427 100644
--- a/tests/test-hbitmap.c
+++ b/tests/test-hbitmap.c
@@ -9,10 +9,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
 #include "qemu/hbitmap.h"
 
 #define LOG_BITS_PER_LONG          (BITS_PER_LONG == 32 ? 5 : 6)
diff --git a/tests/test-int128.c b/tests/test-int128.c
index 0772ef7..cacf6be 100644
--- a/tests/test-int128.c
+++ b/tests/test-int128.c
@@ -6,10 +6,9 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdio.h>
 #include "qemu/int128.h"
-#include "qemu/osdep.h"
 
 /* clang doesn't support __noclone__ but it does have a mechanism for
  * telling us this. We assume that if we don't have __has_attribute()
diff --git a/tests/test-io-channel-buffer.c b/tests/test-io-channel-buffer.c
index 6637501..64722a2 100644
--- a/tests/test-io-channel-buffer.c
+++ b/tests/test-io-channel-buffer.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include "io/channel-buffer.h"
 #include "io-channel-helpers.h"
 
diff --git a/tests/test-io-channel-command.c b/tests/test-io-channel-command.c
index 03cac36..8855437 100644
--- a/tests/test-io-channel-command.c
+++ b/tests/test-io-channel-command.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include "io/channel-command.h"
 #include "io-channel-helpers.h"
 
diff --git a/tests/test-io-channel-file.c b/tests/test-io-channel-file.c
index f276a32..c5d3d3c 100644
--- a/tests/test-io-channel-file.c
+++ b/tests/test-io-channel-file.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include "io/channel-file.h"
 #include "io-channel-helpers.h"
 
diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c
index 1a36a3c..f0872b2 100644
--- a/tests/test-io-channel-socket.c
+++ b/tests/test-io-channel-socket.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include "io/channel-socket.h"
 #include "io-channel-helpers.h"
 #ifdef HAVE_IFADDRS_H
diff --git a/tests/test-io-channel-tls.c b/tests/test-io-channel-tls.c
index 3c11a50..3c361a7 100644
--- a/tests/test-io-channel-tls.c
+++ b/tests/test-io-channel-tls.c
@@ -21,10 +21,8 @@
  */
 
 
-#include <stdlib.h>
-#include <fcntl.h>
+#include "qemu/osdep.h"
 
-#include "config-host.h"
 #include "crypto-tls-x509-helpers.h"
 #include "io/channel-tls.h"
 #include "io/channel-socket.h"
diff --git a/tests/test-io-task.c b/tests/test-io-task.c
index 3344382..ae46c56 100644
--- a/tests/test-io-task.c
+++ b/tests/test-io-task.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "io/task.h"
diff --git a/tests/test-iov.c b/tests/test-iov.c
index 46e4ddd..3f25268 100644
--- a/tests/test-iov.c
+++ b/tests/test-iov.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "qemu-common.h"
 #include "qemu/iov.h"
diff --git a/tests/test-mul64.c b/tests/test-mul64.c
index a0a17f7..1282ec5 100644
--- a/tests/test-mul64.c
+++ b/tests/test-mul64.c
@@ -6,10 +6,9 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdint.h>
 #include "qemu/host-utils.h"
-#include "qemu/osdep.h"
 
 
 typedef struct {
diff --git a/tests/test-netfilter.c b/tests/test-netfilter.c
index 303deb7..7d105c3 100644
--- a/tests/test-netfilter.c
+++ b/tests/test-netfilter.c
@@ -8,6 +8,7 @@
  * later.  See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "libqtest.h"
 
diff --git a/tests/test-opts-visitor.c b/tests/test-opts-visitor.c
index 1c753d9..1094203 100644
--- a/tests/test-opts-visitor.c
+++ b/tests/test-opts-visitor.c
@@ -10,6 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qemu/config-file.h"     /* qemu_add_opts() */
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index 0be9835..13ace0b 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -22,8 +22,8 @@
  * THE SOFTWARE.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdint.h>
 
 #include "hw/qdev.h"
 #include "qom/object.h"
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index 0c1136d..848374e 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -7,12 +7,11 @@
  * See the COPYING.LIB file in the top-level directory.
  */
 
-#include "qapi/error.h"
+#include "qemu/osdep.h"
 #include "qapi/qmp/qstring.h"
 #include "qemu/config-file.h"
 
 #include <glib.h>
-#include <string.h>
 
 static QemuOptsList opts_list_01 = {
     .name = "opts_list_01",
diff --git a/tests/test-qga.c b/tests/test-qga.c
index e6a84d1..0973b48 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -1,18 +1,11 @@
+#include "qemu/osdep.h"
 #include <locale.h>
 #include <glib.h>
 #include <glib/gstdio.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-#include <unistd.h>
-#include <inttypes.h>
 
 #include "libqtest.h"
-#include "config-host.h"
 #include "qga/guest-agent-core.h"
 
 typedef struct {
diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index 9f35b80..f84f3eb 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "qemu-common.h"
 #include "qapi/qmp/types.h"
diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c
index 035c65c..a296fdb 100644
--- a/tests/test-qmp-event.c
+++ b/tests/test-qmp-event.c
@@ -11,8 +11,8 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdarg.h>
 
 #include "qemu-common.h"
 #include "test-qapi-types.h"
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c
index f1c2e3b..9d1e082 100644
--- a/tests/test-qmp-input-strict.c
+++ b/tests/test-qmp-input-strict.c
@@ -11,8 +11,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdarg.h>
 
 #include "qemu-common.h"
 #include "qapi/qmp-input-visitor.h"
diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c
index b4a5bee..df510fb 100644
--- a/tests/test-qmp-input-visitor.c
+++ b/tests/test-qmp-input-visitor.c
@@ -10,8 +10,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdarg.h>
 
 #include "qemu-common.h"
 #include "qapi/qmp-input-visitor.h"
diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c
index 3078442..7ef203f 100644
--- a/tests/test-qmp-output-visitor.c
+++ b/tests/test-qmp-output-visitor.c
@@ -10,6 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qemu-common.h"
diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c
index daa8bf4..79d3750 100644
--- a/tests/test-rcu-list.c
+++ b/tests/test-rcu-list.c
@@ -20,14 +20,10 @@
  * Copyright (c) 2013 Mike D. Day, IBM Corporation.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
 #include "qemu/atomic.h"
 #include "qemu/rcu.h"
-#include "qemu/compiler.h"
-#include "qemu/osdep.h"
 #include "qemu/thread.h"
 #include "qemu/rcu_queue.h"
 
diff --git a/tests/test-rfifolock.c b/tests/test-rfifolock.c
index 0572ebb..9a3cb24 100644
--- a/tests/test-rfifolock.c
+++ b/tests/test-rfifolock.c
@@ -10,6 +10,7 @@
  * See the COPYING.LIB file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "qemu-common.h"
 #include "qemu/rfifolock.h"
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
index 8e3433e..eea8ee9 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -10,8 +10,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdarg.h>
 
 #include "qemu-common.h"
 #include "qapi/string-input-visitor.h"
diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
index 7aecdfc..a0a41a3 100644
--- a/tests/test-string-output-visitor.c
+++ b/tests/test-string-output-visitor.c
@@ -10,6 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qemu-common.h"
diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c
index ccdee39..40600b4 100644
--- a/tests/test-thread-pool.c
+++ b/tests/test-thread-pool.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include <glib.h>
 #include "qemu-common.h"
 #include "block/aio.h"
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index a95039f..858f1aa 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -12,6 +12,7 @@
  * See the COPYING.LIB file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 #include <math.h>
 #include "block/aio.h"
diff --git a/tests/test-timed-average.c b/tests/test-timed-average.c
index a049799..1cc4ab3 100644
--- a/tests/test-timed-average.c
+++ b/tests/test-timed-average.c
@@ -10,8 +10,8 @@
  * See the COPYING.LIB file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <unistd.h>
 
 #include "qemu/timed-average.h"
 
diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c
index 9f67f9e..acc438b 100644
--- a/tests/test-visitor-serialization.c
+++ b/tests/test-visitor-serialization.c
@@ -11,9 +11,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdlib.h>
-#include <stdint.h>
 #include <float.h>
 
 #include "qemu-common.h"
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 4d13bd0..713d444 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "qemu-common.h"
diff --git a/tests/test-write-threshold.c b/tests/test-write-threshold.c
index faffa7b..fdbc802 100644
--- a/tests/test-write-threshold.c
+++ b/tests/test-write-threshold.c
@@ -6,8 +6,8 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <stdint.h>
 #include "block/block_int.h"
 #include "block/write-threshold.h"
 
diff --git a/tests/test-x86-cpuid.c b/tests/test-x86-cpuid.c
index 6cd20d4..8eb0bc6 100644
--- a/tests/test-x86-cpuid.c
+++ b/tests/test-x86-cpuid.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "hw/i386/topology.h"
diff --git a/tests/test-xbzrle.c b/tests/test-xbzrle.c
index 1cd8cb7..abd309d 100644
--- a/tests/test-xbzrle.c
+++ b/tests/test-xbzrle.c
@@ -10,11 +10,7 @@
  * See the COPYING file in the top-level directory.
  *
  */
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "include/migration/migration.h"
 
diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index 99db538..235cae0 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -7,6 +7,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "libqtest.h"
diff --git a/tests/tpci200-test.c b/tests/tpci200-test.c
index 9ae0127..cb2b00c 100644
--- a/tests/tpci200-test.c
+++ b/tests/tpci200-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
index 9fb09f1..9a1ad5a 100644
--- a/tests/vhost-user-bridge.c
+++ b/tests/vhost-user-bridge.c
@@ -29,23 +29,13 @@
 
 #define _FILE_OFFSET_BITS 64
 
-#include <stddef.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
+#include "qemu/osdep.h"
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/unistd.h>
 #include <sys/mman.h>
 #include <sys/eventfd.h>
 #include <arpa/inet.h>
-#include <ctype.h>
 #include <netdb.h>
 
 #include <linux/vhost.h>
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 95f35af..2e31219 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -8,6 +8,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
 
 #include "libqtest.h"
diff --git a/tests/virtio-balloon-test.c b/tests/virtio-balloon-test.c
index becebb5..b010ce9 100644
--- a/tests/virtio-balloon-test.c
+++ b/tests/virtio-balloon-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void pci_nop(void)
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 4078321..3a66630 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -8,11 +8,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
 #include "libqtest.h"
 #include "libqos/virtio.h"
 #include "libqos/virtio-pci.h"
diff --git a/tests/virtio-console-test.c b/tests/virtio-console-test.c
index 6be96e8..0b9c2a5 100644
--- a/tests/virtio-console-test.c
+++ b/tests/virtio-console-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void console_pci_nop(void)
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 982d77a..04cfcd5 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -7,12 +7,11 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
 #include "qemu-common.h"
 #include "qemu/sockets.h"
-#include "qemu/osdep.h"
 #include "qemu/iov.h"
 #include "libqos/pci-pc.h"
 #include "libqos/virtio.h"
diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c
index 41c1cdb..771dbd7 100644
--- a/tests/virtio-rng-test.c
+++ b/tests/virtio-rng-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 #include "libqos/pci.h"
 
 #define PCI_SLOT_HP             0x06
diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c
index 66d8491..d78747a 100644
--- a/tests/virtio-scsi-test.c
+++ b/tests/virtio-scsi-test.c
@@ -8,11 +8,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
-#include <stdio.h>
 #include "block/scsi.h"
 #include "libqos/virtio.h"
 #include "libqos/virtio-pci.h"
diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c
index bf030a6..480d4ab 100644
--- a/tests/virtio-serial-test.c
+++ b/tests/virtio-serial-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void pci_nop(void)
diff --git a/tests/vmxnet3-test.c b/tests/vmxnet3-test.c
index a2ebed3..6ef0e2f 100644
--- a/tests/vmxnet3-test.c
+++ b/tests/vmxnet3-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c
index 82ca597..efe3370 100644
--- a/tests/wdt_ib700-test.c
+++ b/tests/wdt_ib700-test.c
@@ -7,10 +7,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include <glib.h>
-#include <string.h>
 #include "libqtest.h"
-#include "qemu/osdep.h"
 #include "qemu/timer.h"
 
 static void qmp_check_no_event(void)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 10/14] qapi: Clean up includes in generated files
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (8 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 09/14] tests: Clean up includes Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 11/14] scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h Peter Maydell
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

From: Eric Blake <eblake@redhat.com>

As a followup to commit cbf2115, clean up the includes in files
generated by QAPI so that osdep.h is included first in .c files,
and headers which it implies are not included manually.  This
patch is done manually, since Coccinelle (and therefore
scripts/clean-includes) doesn't see into the generator scripts.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 scripts/qapi-commands.py   | 1 +
 scripts/qapi-event.py      | 1 +
 scripts/qapi-introspect.py | 3 ++-
 scripts/qapi-types.py      | 3 +--
 scripts/qapi-visit.py      | 1 +
 5 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 561e47a..f68cbf7 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -297,6 +297,7 @@ h_comment = '''
                             c_comment, h_comment)
 
 fdef.write(mcgen('''
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/module.h"
 #include "qapi/qmp/types.h"
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 720486f..954c254 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -161,6 +161,7 @@ h_comment = '''
                             c_comment, h_comment)
 
 fdef.write(mcgen('''
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "%(prefix)sqapi-event.h"
 #include "%(prefix)sqapi-visit.h"
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 64f2cd0..e0f926b 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -1,7 +1,7 @@
 #
 # QAPI introspection generator
 #
-# Copyright (C) 2015 Red Hat, Inc.
+# Copyright (C) 2015-2016 Red Hat, Inc.
 #
 # Authors:
 #  Markus Armbruster <armbru@redhat.com>
@@ -204,6 +204,7 @@ h_comment = '''
                             c_comment, h_comment)
 
 fdef.write(mcgen('''
+#include "qemu/osdep.h"
 #include "%(prefix)sqmp-introspect.h"
 
 ''',
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 0d86269..f8c7253 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -279,6 +279,7 @@ h_comment = '''
                             c_comment, h_comment)
 
 fdef.write(mcgen('''
+#include "qemu/osdep.h"
 #include "qapi/dealloc-visitor.h"
 #include "%(prefix)sqapi-types.h"
 #include "%(prefix)sqapi-visit.h"
@@ -287,8 +288,6 @@ fdef.write(mcgen('''
 
 # To avoid circular headers, use only typedefs.h here, not qobject.h
 fdecl.write(mcgen('''
-#include <stdbool.h>
-#include <stdint.h>
 #include "qemu/typedefs.h"
 '''))
 
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index b93690b..2806336 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -437,6 +437,7 @@ h_comment = '''
                             c_comment, h_comment)
 
 fdef.write(mcgen('''
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "%(prefix)sqapi-visit.h"
 ''',
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 11/14] scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (9 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 10/14] qapi: Clean up includes in generated files Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 12/14] scripts/tracetool: Include qemu/osdep.h in generated .c files Peter Maydell
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

In the .c files generated by this script, include qemu/osdep.h
as the first included header, not config.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 scripts/feature_to_c.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/feature_to_c.sh b/scripts/feature_to_c.sh
index 888548e..fb1f336 100644
--- a/scripts/feature_to_c.sh
+++ b/scripts/feature_to_c.sh
@@ -36,7 +36,7 @@ for input; do
   arrayname=xml_feature_`echo $input | sed 's,.*/,,; s/[-.]/_/g'`
 
   ${AWK:-awk} 'BEGIN { n = 0
-      printf "#include \"config.h\"\n"
+      printf "#include \"qemu/osdep.h\"\n"
       printf "#include \"qemu-common.h\"\n"
       printf "#include \"exec/gdbstub.h\"\n"
       print "static const char '$arrayname'[] = {"
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 12/14] scripts/tracetool: Include qemu/osdep.h in generated .c files
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (10 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 11/14] scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 13/14] all: Clean up includes Peter Maydell
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

Include qemu/osdep.h as the first include in generated .c files,
so they don't implicitly rely on some other included header
to pull it in.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 scripts/tracetool/backend/simple.py      | 3 ++-
 scripts/tracetool/format/events_c.py     | 1 +
 scripts/tracetool/format/tcg_helper_c.py | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index e8c2cd5..3246c20 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -42,7 +42,8 @@ def generate_h(event):
 
 
 def generate_c_begin(events):
-    out('#include "trace.h"',
+    out('#include "qemu/osdep.h"',
+        '#include "trace.h"',
         '#include "trace/control.h"',
         '#include "trace/simple.h"',
         '')
diff --git a/scripts/tracetool/format/events_c.py b/scripts/tracetool/format/events_c.py
index 2717ea3..1cc6a49 100644
--- a/scripts/tracetool/format/events_c.py
+++ b/scripts/tracetool/format/events_c.py
@@ -19,6 +19,7 @@ from tracetool import out
 def generate(events, backend):
     out('/* This file is autogenerated by tracetool, do not edit. */',
         '',
+        '#include "qemu/osdep.h"',
         '#include "trace.h"',
         '#include "trace/generated-events.h"',
         '#include "trace/control.h"',
diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool/format/tcg_helper_c.py
index 96655a0..afd6e98 100644
--- a/scripts/tracetool/format/tcg_helper_c.py
+++ b/scripts/tracetool/format/tcg_helper_c.py
@@ -23,6 +23,7 @@ def generate(events, backend):
 
     out('/* This file is autogenerated by tracetool, do not edit. */',
         '',
+        '#include "qemu/osdep.h"',
         '#include "qemu-common.h"',
         '#include "trace.h"',
         '#include "exec/helper-proto.h"',
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 13/14] all: Clean up includes
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (11 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 12/14] scripts/tracetool: Include qemu/osdep.h in generated .c files Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 14/14] oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h Peter Maydell
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/bcm2835_peripherals.c           | 1 +
 hw/arm/bcm2836.c                       | 1 +
 hw/arm/raspi.c                         | 1 +
 hw/intc/bcm2835_ic.c                   | 1 +
 hw/intc/bcm2836_control.c              | 1 +
 hw/misc/bcm2835_mbox.c                 | 1 +
 hw/misc/bcm2835_property.c             | 1 +
 stubs/blockdev-close-all-bdrv-states.c | 1 +
 8 files changed, 8 insertions(+)

diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 18b72ec..866fc76 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -8,6 +8,7 @@
  * This code is licensed under the GNU GPLv2 and later.
  */
 
+#include "qemu/osdep.h"
 #include "hw/arm/bcm2835_peripherals.h"
 #include "hw/misc/bcm2835_mbox_defs.h"
 #include "hw/arm/raspi_platform.h"
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index 69c7438..3a1a7bd 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -8,6 +8,7 @@
  * This code is licensed under the GNU GPLv2 and later.
  */
 
+#include "qemu/osdep.h"
 #include "hw/arm/bcm2836.h"
 #include "hw/arm/raspi_platform.h"
 #include "hw/sysbus.h"
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 0c9427c..4f8fa00 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -8,6 +8,7 @@
  * This code is licensed under the GNU GPLv2 and later.
  */
 
+#include "qemu/osdep.h"
 #include "hw/arm/bcm2836.h"
 #include "qemu/error-report.h"
 #include "hw/boards.h"
diff --git a/hw/intc/bcm2835_ic.c b/hw/intc/bcm2835_ic.c
index 005a72b..80513b2 100644
--- a/hw/intc/bcm2835_ic.c
+++ b/hw/intc/bcm2835_ic.c
@@ -12,6 +12,7 @@
  * This code is licensed under the GPL.
  */
 
+#include "qemu/osdep.h"
 #include "hw/intc/bcm2835_ic.h"
 
 #define GPU_IRQS 64
diff --git a/hw/intc/bcm2836_control.c b/hw/intc/bcm2836_control.c
index ad622aa..d027181 100644
--- a/hw/intc/bcm2836_control.c
+++ b/hw/intc/bcm2836_control.c
@@ -13,6 +13,7 @@
  * https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf
  */
 
+#include "qemu/osdep.h"
 #include "hw/intc/bcm2836_control.h"
 
 #define REG_GPU_ROUTE           0x0c
diff --git a/hw/misc/bcm2835_mbox.c b/hw/misc/bcm2835_mbox.c
index df1d6e6..500baba 100644
--- a/hw/misc/bcm2835_mbox.c
+++ b/hw/misc/bcm2835_mbox.c
@@ -8,6 +8,7 @@
  *   https://github.com/raspberrypi/firmware/wiki/Accessing-mailboxes
  */
 
+#include "qemu/osdep.h"
 #include "hw/misc/bcm2835_mbox.h"
 
 #define MAIL0_PEEK   0x90
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
index e42b43e..5778aaa 100644
--- a/hw/misc/bcm2835_property.c
+++ b/hw/misc/bcm2835_property.c
@@ -3,6 +3,7 @@
  * This code is licensed under the GNU GPLv2 and later.
  */
 
+#include "qemu/osdep.h"
 #include "hw/misc/bcm2835_property.h"
 #include "hw/misc/bcm2835_mbox_defs.h"
 #include "sysemu/dma.h"
diff --git a/stubs/blockdev-close-all-bdrv-states.c b/stubs/blockdev-close-all-bdrv-states.c
index 12d2442..f1f1d9c 100644
--- a/stubs/blockdev-close-all-bdrv-states.c
+++ b/stubs/blockdev-close-all-bdrv-states.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "block/block_int.h"
 
 void blockdev_close_all_bdrv_states(void)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Qemu-devel] [PATCH 14/14] oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (12 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 13/14] all: Clean up includes Peter Maydell
@ 2016-02-09 15:25 ` Peter Maydell
  2016-02-09 16:08 ` [Qemu-devel] [PATCH 00/14] More #include cleanups Eric Blake
  2016-02-16 13:49 ` Peter Maydell
  15 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

The right place for "work around issues with system headers" code
is osdep.h. Move the workaround for OSX's stdlib.h emitting a
deprecation warning for daemon() to that header.

This also fixes a problem where running clean-includes on
oslib-posix.c would erroneously remove the #include <stdlib.h>
from it, breaking the workaround.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/osdep.h | 11 +++++++++++
 util/oslib-posix.c   |  9 ---------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 59a7f8d..cc055c9 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -27,6 +27,17 @@
 
 #include "config-host.h"
 #include "qemu/compiler.h"
+
+/* The following block of code temporarily renames the daemon() function so the
+ * compiler does not see the warning associated with it in stdlib.h on OSX
+ */
+#ifdef __APPLE__
+#define daemon qemu_fake_daemon_function
+#include <stdlib.h>
+#undef daemon
+extern int daemon(int, int);
+#endif
+
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdbool.h>
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index d844387..7615be4 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -26,15 +26,6 @@
  * THE SOFTWARE.
  */
 
-/* The following block of code temporarily renames the daemon() function so the
-   compiler does not see the warning associated with it in stdlib.h on OSX */
-#ifdef __APPLE__
-#define daemon qemu_fake_daemon_function
-#include <stdlib.h>
-#undef daemon
-extern int daemon(int, int);
-#endif
-
 #if defined(__linux__) && (defined(__x86_64__) || defined(__arm__))
    /* Use 2 MiB alignment so transparent hugepages can be used by KVM.
       Valgrind does not support alignments larger than 1 MiB,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 02/14] ui/cocoa.m: Include qemu/osdep.h
  2016-02-09 15:24 ` [Qemu-devel] [PATCH 02/14] ui/cocoa.m: Include qemu/osdep.h Peter Maydell
@ 2016-02-09 16:07   ` Eric Blake
  2016-02-09 16:08     ` Peter Maydell
  0 siblings, 1 reply; 33+ messages in thread
From: Eric Blake @ 2016-02-09 16:07 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

On 02/09/2016 08:24 AM, Peter Maydell wrote:
> Include "qemu/osdep.h". (This is a manual commit equivalent
> to what the clean-includes script would do, because that
> script can't handle ObjectiveC source files.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  ui/cocoa.m | 2 ++
>  1 file changed, 2 insertions(+)

This one already landed as e4a096b.

> 
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index d866f23..3ee5549 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -22,6 +22,8 @@
>   * THE SOFTWARE.
>   */
>  
> +#include "qemu/osdep.h"
> +
>  #import <Cocoa/Cocoa.h>
>  #include <crt_externs.h>
>  
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 02/14] ui/cocoa.m: Include qemu/osdep.h
  2016-02-09 16:07   ` Eric Blake
@ 2016-02-09 16:08     ` Peter Maydell
  0 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 16:08 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers, Patch Tracking

On 9 February 2016 at 16:07, Eric Blake <eblake@redhat.com> wrote:
> On 02/09/2016 08:24 AM, Peter Maydell wrote:
>> Include "qemu/osdep.h". (This is a manual commit equivalent
>> to what the clean-includes script would do, because that
>> script can't handle ObjectiveC source files.)
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  ui/cocoa.m | 2 ++
>>  1 file changed, 2 insertions(+)
>
> This one already landed as e4a096b.

Heh, so it did, forgot to rebase. No harm done...

-- PMM

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (13 preceding siblings ...)
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 14/14] oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h Peter Maydell
@ 2016-02-09 16:08 ` Eric Blake
  2016-02-09 16:11   ` Eric Blake
  2016-02-16 13:49 ` Peter Maydell
  15 siblings, 1 reply; 33+ messages in thread
From: Eric Blake @ 2016-02-09 16:08 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 10127 bytes --]

On 02/09/2016 08:24 AM, Peter Maydell wrote:
> This set of patches does a bunch more cleaning of includes.
> Specifically it does everything necessary to be able to
> remove osdep.h includes from header files including qemu-common.h
> 
> Most of these patches are small, except for the one which
> deals with tests/ (that one has already been reviewed).
> There are several patches which fix code generators to
> generate correct #includes, and some which do manual changes
> to C++ or other files that Coccinelle barfs on.
> 
> The "all:" patch is running clean-includes on the whole
> tree to pick up some new files which have been added
> recently (mostly via target-arm).
> 
> I've thrown in a couple of patches that have already appeared
> on list, just to get the whole set into one series.
> 
> I have some pending patches which:
>  * enhance clean-includes to handle header files
>  * clean up header files
>  * add a --all option to clean-includes to do a "run clean
>    on whole tree"
> 
> but I'd like to get the "add missing includes to .c files"
> parts into master before moving onto "remove includes from .h
> files" part...

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> thanks
> -- PMM
> 
> Eric Blake (1):
>   qapi: Clean up includes in generated files
> 
> Peter Maydell (13):
>   cpu: Clean up includes
>   ui/cocoa.m: Include qemu/osdep.h
>   disas/arm-a64.cc: Include osdep.h first
>   hw/block/nand.c: Include osdep.h first
>   target-cris: Remove unnecessary ifdef from mmu.c
>   cris: Clean up includes
>   libdecnumber: Clean up includes
>   tests/i440fx-test: Don't define ARRAY_SIZE locally
>   tests: Clean up includes
>   scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h
>   scripts/tracetool: Include qemu/osdep.h in generated .c files
>   all: Clean up includes
>   oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h
> 
>  disas/arm-a64.cc                         |  5 +++--
>  hw/arm/bcm2835_peripherals.c             |  1 +
>  hw/arm/bcm2836.c                         |  1 +
>  hw/arm/raspi.c                           |  1 +
>  hw/block/nand.c                          |  5 +++--
>  hw/intc/bcm2835_ic.c                     |  1 +
>  hw/intc/bcm2836_control.c                |  1 +
>  hw/misc/bcm2835_mbox.c                   |  1 +
>  hw/misc/bcm2835_property.c               |  1 +
>  include/qemu/osdep.h                     | 11 +++++++++++
>  libdecnumber/decContext.c                |  3 +--
>  libdecnumber/decNumber.c                 |  5 +----
>  libdecnumber/dpd/decimal128.c            |  3 +--
>  libdecnumber/dpd/decimal32.c             |  3 +--
>  libdecnumber/dpd/decimal64.c             |  3 +--
>  qom/cpu.c                                |  1 +
>  scripts/feature_to_c.sh                  |  2 +-
>  scripts/qapi-commands.py                 |  1 +
>  scripts/qapi-event.py                    |  1 +
>  scripts/qapi-introspect.py               |  3 ++-
>  scripts/qapi-types.py                    |  3 +--
>  scripts/qapi-visit.py                    |  1 +
>  scripts/tracetool/backend/simple.py      |  3 ++-
>  scripts/tracetool/format/events_c.py     |  1 +
>  scripts/tracetool/format/tcg_helper_c.py |  1 +
>  stubs/blockdev-close-all-bdrv-states.c   |  1 +
>  target-cris/mmu.c                        |  4 +---
>  target-i386/cpu.c                        |  5 +----
>  tests/ac97-test.c                        |  3 +--
>  tests/bios-tables-test.c                 |  4 +---
>  tests/boot-order-test.c                  |  2 +-
>  tests/check-qdict.c                      |  1 +
>  tests/check-qfloat.c                     |  1 +
>  tests/check-qint.c                       |  1 +
>  tests/check-qjson.c                      |  1 +
>  tests/check-qlist.c                      |  1 +
>  tests/check-qom-interface.c              |  1 +
>  tests/check-qom-proplist.c               |  1 +
>  tests/check-qstring.c                    |  1 +
>  tests/crypto-tls-x509-helpers.c          |  4 +---
>  tests/device-introspect-test.c           |  2 +-
>  tests/display-vga-test.c                 |  3 +--
>  tests/drive_del-test.c                   |  2 +-
>  tests/ds1338-test.c                      |  1 +
>  tests/e1000-test.c                       |  3 +--
>  tests/eepro100-test.c                    |  3 +--
>  tests/endianness-test.c                  |  5 +----
>  tests/es1370-test.c                      |  3 +--
>  tests/fdc-test.c                         |  4 +---
>  tests/fw_cfg-test.c                      |  2 +-
>  tests/hd-geo-test.c                      |  4 +---
>  tests/i440fx-test.c                      |  8 +-------
>  tests/i82801b11-test.c                   |  3 +--
>  tests/intel-hda-test.c                   |  3 +--
>  tests/io-channel-helpers.c               |  1 +
>  tests/ioh3420-test.c                     |  3 +--
>  tests/ipmi-bt-test.c                     |  5 +----
>  tests/ipmi-kcs-test.c                    |  4 +---
>  tests/ipoctal232-test.c                  |  3 +--
>  tests/ivshmem-test.c                     |  6 +-----
>  tests/libqos/fw_cfg.c                    |  1 +
>  tests/libqos/i2c-imx.c                   |  3 +--
>  tests/libqos/i2c-omap.c                  |  3 +--
>  tests/libqos/i2c.c                       |  1 +
>  tests/libqos/libqos-pc.c                 |  1 +
>  tests/libqos/libqos.c                    |  6 +-----
>  tests/libqos/malloc-generic.c            |  1 +
>  tests/libqos/malloc-pc.c                 |  1 +
>  tests/libqos/malloc.c                    |  3 +--
>  tests/libqos/pci-pc.c                    |  1 +
>  tests/libqos/pci.c                       |  1 +
>  tests/libqos/usb.c                       |  3 +--
>  tests/libqos/virtio-mmio.c               |  2 +-
>  tests/libqos/virtio-pci.c                |  2 +-
>  tests/libqos/virtio.c                    |  1 +
>  tests/libqtest.c                         | 12 ++----------
>  tests/m48t59-test.c                      |  5 +----
>  tests/ne2000-test.c                      |  3 +--
>  tests/nvme-test.c                        |  3 +--
>  tests/pc-cpu-test.c                      |  3 +--
>  tests/pcnet-test.c                       |  3 +--
>  tests/pkix_asn1_tab.c                    |  1 +
>  tests/pvpanic-test.c                     |  3 +--
>  tests/q35-test.c                         |  3 +--
>  tests/qemu-iotests/socket_scm_helper.c   |  8 +-------
>  tests/qom-test.c                         |  3 +--
>  tests/rcutorture.c                       |  5 +----
>  tests/rtc-test.c                         |  5 +----
>  tests/rtl8139-test.c                     |  3 +--
>  tests/spapr-phb-test.c                   |  1 +
>  tests/tco-test.c                         |  4 +---
>  tests/test-aio.c                         |  1 +
>  tests/test-base64.c                      |  1 +
>  tests/test-bitops.c                      |  3 +--
>  tests/test-blockjob-txn.c                |  2 +-
>  tests/test-coroutine.c                   |  1 +
>  tests/test-crypto-cipher.c               |  1 +
>  tests/test-crypto-hash.c                 |  1 +
>  tests/test-crypto-secret.c               |  1 +
>  tests/test-crypto-tlscredsx509.c         |  4 +---
>  tests/test-crypto-tlssession.c           |  4 +---
>  tests/test-cutils.c                      |  3 +--
>  tests/test-hbitmap.c                     |  4 +---
>  tests/test-int128.c                      |  3 +--
>  tests/test-io-channel-buffer.c           |  1 +
>  tests/test-io-channel-command.c          |  1 +
>  tests/test-io-channel-file.c             |  1 +
>  tests/test-io-channel-socket.c           |  1 +
>  tests/test-io-channel-tls.c              |  4 +---
>  tests/test-io-task.c                     |  1 +
>  tests/test-iov.c                         |  1 +
>  tests/test-mul64.c                       |  3 +--
>  tests/test-netfilter.c                   |  1 +
>  tests/test-opts-visitor.c                |  1 +
>  tests/test-qdev-global-props.c           |  2 +-
>  tests/test-qemu-opts.c                   |  3 +--
>  tests/test-qga.c                         |  9 +--------
>  tests/test-qmp-commands.c                |  1 +
>  tests/test-qmp-event.c                   |  2 +-
>  tests/test-qmp-input-strict.c            |  2 +-
>  tests/test-qmp-input-visitor.c           |  2 +-
>  tests/test-qmp-output-visitor.c          |  1 +
>  tests/test-rcu-list.c                    |  6 +-----
>  tests/test-rfifolock.c                   |  1 +
>  tests/test-string-input-visitor.c        |  2 +-
>  tests/test-string-output-visitor.c       |  1 +
>  tests/test-thread-pool.c                 |  1 +
>  tests/test-throttle.c                    |  1 +
>  tests/test-timed-average.c               |  2 +-
>  tests/test-visitor-serialization.c       |  3 +--
>  tests/test-vmstate.c                     |  1 +
>  tests/test-write-threshold.c             |  2 +-
>  tests/test-x86-cpuid.c                   |  1 +
>  tests/test-xbzrle.c                      |  6 +-----
>  tests/tmp105-test.c                      |  1 +
>  tests/tpci200-test.c                     |  3 +--
>  tests/vhost-user-bridge.c                | 12 +-----------
>  tests/vhost-user-test.c                  |  1 +
>  tests/virtio-balloon-test.c              |  3 +--
>  tests/virtio-blk-test.c                  |  5 +----
>  tests/virtio-console-test.c              |  3 +--
>  tests/virtio-net-test.c                  |  3 +--
>  tests/virtio-rng-test.c                  |  3 +--
>  tests/virtio-scsi-test.c                 |  4 +---
>  tests/virtio-serial-test.c               |  3 +--
>  tests/vmxnet3-test.c                     |  3 +--
>  tests/wdt_ib700-test.c                   |  3 +--
>  ui/cocoa.m                               |  2 ++
>  util/oslib-posix.c                       |  9 ---------
>  149 files changed, 166 insertions(+), 241 deletions(-)
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 16:08 ` [Qemu-devel] [PATCH 00/14] More #include cleanups Eric Blake
@ 2016-02-09 16:11   ` Eric Blake
  2016-02-09 16:21     ` Peter Maydell
  0 siblings, 1 reply; 33+ messages in thread
From: Eric Blake @ 2016-02-09 16:11 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 2012 bytes --]

On 02/09/2016 09:08 AM, Eric Blake wrote:
> On 02/09/2016 08:24 AM, Peter Maydell wrote:
>> This set of patches does a bunch more cleaning of includes.
>> Specifically it does everything necessary to be able to
>> remove osdep.h includes from header files including qemu-common.h
>>
>> Most of these patches are small, except for the one which
>> deals with tests/ (that one has already been reviewed).
>> There are several patches which fix code generators to
>> generate correct #includes, and some which do manual changes
>> to C++ or other files that Coccinelle barfs on.
>>
>> The "all:" patch is running clean-includes on the whole
>> tree to pick up some new files which have been added
>> recently (mostly via target-arm).
>>
>> I've thrown in a couple of patches that have already appeared
>> on list, just to get the whole set into one series.
>>
>> I have some pending patches which:
>>  * enhance clean-includes to handle header files
>>  * clean up header files
>>  * add a --all option to clean-includes to do a "run clean
>>    on whole tree"
>>
>> but I'd like to get the "add missing includes to .c files"
>> parts into master before moving onto "remove includes from .h
>> files" part...
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>

But failed testing:

  CC    disas/arm.o
  CXX   disas/arm-a64.o
In file included from /usr/include/c++/5.3.1/cmath:41:0,
                 from /home/eblake/qemu-tmp/disas/libvixl/vixl/utils.h:31,
                 from
/home/eblake/qemu-tmp/disas/libvixl/vixl/a64/disasm-a64.h:31,
                 from disas/arm-a64.cc:25:
/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h:1991:10:
error: expected unqualified-id before ‘namespace’
   inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
          ^

Not sure what went wrong there, but 3/14 probably needs tweaking.


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 16:11   ` Eric Blake
@ 2016-02-09 16:21     ` Peter Maydell
  2016-02-09 17:01       ` Peter Maydell
  2016-02-09 17:10       ` Eric Blake
  0 siblings, 2 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 16:21 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers, Patch Tracking

On 9 February 2016 at 16:11, Eric Blake <eblake@redhat.com> wrote:
> But failed testing:
>
>   CC    disas/arm.o
>   CXX   disas/arm-a64.o
> In file included from /usr/include/c++/5.3.1/cmath:41:0,
>                  from /home/eblake/qemu-tmp/disas/libvixl/vixl/utils.h:31,
>                  from
> /home/eblake/qemu-tmp/disas/libvixl/vixl/a64/disasm-a64.h:31,
>                  from disas/arm-a64.cc:25:
> /usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h:1991:10:
> error: expected unqualified-id before ‘namespace’
>    inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
>           ^
>
> Not sure what went wrong there, but 3/14 probably needs tweaking.

Weird. Your machine does compile libvixl right in current master?
The patch does build fine for me, and it's not clear to me why
moving the disasm-a64.h include below osdep.h and disas/bfd.h
would make it stop building. Google suggests that missing
semicolons can provoke this kind of error so maybe there's
a latent error in the headers somewhere :-(

I'll have a look and see if clang produces an error and if so
a more comprehensible one.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 16:21     ` Peter Maydell
@ 2016-02-09 17:01       ` Peter Maydell
  2016-02-09 17:10       ` Eric Blake
  1 sibling, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 17:01 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers, Patch Tracking

On 9 February 2016 at 16:21, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 9 February 2016 at 16:11, Eric Blake <eblake@redhat.com> wrote:
>> But failed testing:
>>
>>   CC    disas/arm.o
>>   CXX   disas/arm-a64.o
>> In file included from /usr/include/c++/5.3.1/cmath:41:0,
>>                  from /home/eblake/qemu-tmp/disas/libvixl/vixl/utils.h:31,
>>                  from
>> /home/eblake/qemu-tmp/disas/libvixl/vixl/a64/disasm-a64.h:31,
>>                  from disas/arm-a64.cc:25:
>> /usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h:1991:10:
>> error: expected unqualified-id before ‘namespace’
>>    inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
>>           ^
>>
>> Not sure what went wrong there, but 3/14 probably needs tweaking.
>
> Weird. Your machine does compile libvixl right in current master?
> The patch does build fine for me, and it's not clear to me why
> moving the disasm-a64.h include below osdep.h and disas/bfd.h
> would make it stop building. Google suggests that missing
> semicolons can provoke this kind of error so maybe there's
> a latent error in the headers somewhere :-(
>
> I'll have a look and see if clang produces an error and if so
> a more comprehensible one.

Nope, can't repro any kind of compile failure with clang either
on my system. Can I ask you to investigate a bit?

If we just add the osdep.h include but leave the "vixl/a64/disasm-a64.h"
include as the first one in arm-a64.cc does it build OK?
(Maybe our attempts to be first-header clash with the desire
of vixl code to have disas/libvixl/vixl/globals.h be
first-header, though it's not clear to me how.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 16:21     ` Peter Maydell
  2016-02-09 17:01       ` Peter Maydell
@ 2016-02-09 17:10       ` Eric Blake
  2016-02-09 17:18         ` Eric Blake
  1 sibling, 1 reply; 33+ messages in thread
From: Eric Blake @ 2016-02-09 17:10 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Patch Tracking

[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]

On 02/09/2016 09:21 AM, Peter Maydell wrote:
> On 9 February 2016 at 16:11, Eric Blake <eblake@redhat.com> wrote:
>> But failed testing:
>>
>>   CC    disas/arm.o
>>   CXX   disas/arm-a64.o
>> In file included from /usr/include/c++/5.3.1/cmath:41:0,
>>                  from /home/eblake/qemu-tmp/disas/libvixl/vixl/utils.h:31,
>>                  from
>> /home/eblake/qemu-tmp/disas/libvixl/vixl/a64/disasm-a64.h:31,
>>                  from disas/arm-a64.cc:25:
>> /usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h:1991:10:
>> error: expected unqualified-id before ‘namespace’
>>    inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
>>           ^
>>
>> Not sure what went wrong there, but 3/14 probably needs tweaking.
> 
> Weird. Your machine does compile libvixl right in current master?
> The patch does build fine for me, and it's not clear to me why
> moving the disasm-a64.h include below osdep.h and disas/bfd.h
> would make it stop building. Google suggests that missing
> semicolons can provoke this kind of error so maybe there's
> a latent error in the headers somewhere :-(

Yes, I bisected to 3/14; where things compiled after 1/14 (and 2/14 is
already in-tree).

Looking at the c++config.h header, I see a context of:

#if _GLIBCXX_USE_CXX11_ABI
namespace std
{
  inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}

Comparing pre- and post-patch on the preprocessor output, it used to
expand to:

# 1989 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h" 3
namespace std
{
  inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}

but with the new header order it expands to:

# 1989 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h" 3
namespace std
{

# 1991 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h"
 __attribute__ (( always_inline )) __inline__
# 1991 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h" 3
        namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}

So _something_ in osdep.h is redefining 'inline' with disastrous effects
to C++.


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 17:10       ` Eric Blake
@ 2016-02-09 17:18         ` Eric Blake
  2016-02-09 18:04           ` Peter Maydell
  0 siblings, 1 reply; 33+ messages in thread
From: Eric Blake @ 2016-02-09 17:18 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Patch Tracking

[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]

On 02/09/2016 10:10 AM, Eric Blake wrote:

> but with the new header order it expands to:
> 
> # 1989 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h" 3
> namespace std
> {
> 
> # 1991 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h"
>  __attribute__ (( always_inline )) __inline__
> # 1991 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h" 3
>         namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
> }
> 
> So _something_ in osdep.h is redefining 'inline' with disastrous effects
> to C++.

This hack seems to fix things; but I'm not enough of a C++ expert to
know if it is the best fix.

diff --git i/include/qemu/compiler.h w/include/qemu/compiler.h
index d22eb01..d50b806 100644
--- i/include/qemu/compiler.h
+++ w/include/qemu/compiler.h
@@ -77,6 +77,7 @@
 #define typeof_field(type, field) typeof(((type *)0)->field)
 #define type_check(t1,t2) ((t1*)0 - (t2*)0)

+#ifndef __cplusplus
 #ifndef always_inline
 #if !((__GNUC__ < 3) || defined(__APPLE__))
 #ifdef __OPTIMIZE__
@@ -88,6 +89,7 @@
 #undef inline
 #define inline always_inline
 #endif
+#endif

 #define QEMU_BUILD_BUG_ON(x) \
     typedef char glue(qemu_build_bug_on__,__LINE__)[(x)?-1:1]
__attribute__((unused));


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 17:18         ` Eric Blake
@ 2016-02-09 18:04           ` Peter Maydell
  2016-02-09 18:17             ` Paolo Bonzini
  2016-02-09 18:29             ` Eric Blake
  0 siblings, 2 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-09 18:04 UTC (permalink / raw)
  To: Eric Blake
  Cc: Paolo Bonzini, Richard Henderson, QEMU Developers, Patch Tracking

On 9 February 2016 at 17:18, Eric Blake <eblake@redhat.com> wrote:
> On 02/09/2016 10:10 AM, Eric Blake wrote:
>
>> but with the new header order it expands to:
>>
>> # 1989 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h" 3
>> namespace std
>> {
>>
>> # 1991 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h"
>>  __attribute__ (( always_inline )) __inline__
>> # 1991 "/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h" 3
>>         namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
>> }
>>
>> So _something_ in osdep.h is redefining 'inline' with disastrous effects
>> to C++.
>
> This hack seems to fix things; but I'm not enough of a C++ expert to
> know if it is the best fix.
>
> diff --git i/include/qemu/compiler.h w/include/qemu/compiler.h
> index d22eb01..d50b806 100644
> --- i/include/qemu/compiler.h
> +++ w/include/qemu/compiler.h
> @@ -77,6 +77,7 @@
>  #define typeof_field(type, field) typeof(((type *)0)->field)
>  #define type_check(t1,t2) ((t1*)0 - (t2*)0)
>
> +#ifndef __cplusplus
>  #ifndef always_inline
>  #if !((__GNUC__ < 3) || defined(__APPLE__))
>  #ifdef __OPTIMIZE__
> @@ -88,6 +89,7 @@
>  #undef inline
>  #define inline always_inline
>  #endif
> +#endif

Ah, well tracked down. I guess my system headers don't happen
to rely on this bit of inline syntax.

Next question -- do we really need to redefine "inline" to
always_inline at all, in C or C++? (cc'd a few people who might
have an opinion). My instinct is to say "don't do this, just
trust the compiler to decide whether to bother inlining".

Git blame says this was added back in commit df2542c737ea2 in
2007, with the rationale "To avoid discarded inlining bug"...

thanks
-- PMM

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 18:04           ` Peter Maydell
@ 2016-02-09 18:17             ` Paolo Bonzini
  2016-02-09 18:29             ` Eric Blake
  1 sibling, 0 replies; 33+ messages in thread
From: Paolo Bonzini @ 2016-02-09 18:17 UTC (permalink / raw)
  To: Peter Maydell, Eric Blake
  Cc: Richard Henderson, QEMU Developers, Patch Tracking



On 09/02/2016 19:04, Peter Maydell wrote:
> Next question -- do we really need to redefine "inline" to
> always_inline at all, in C or C++? (cc'd a few people who might
> have an opinion). My instinct is to say "don't do this, just
> trust the compiler to decide whether to bother inlining".

Besides this, it sounds like a thing you'd do in the old -ffixed-reg days...

Paolo

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 18:04           ` Peter Maydell
  2016-02-09 18:17             ` Paolo Bonzini
@ 2016-02-09 18:29             ` Eric Blake
  1 sibling, 0 replies; 33+ messages in thread
From: Eric Blake @ 2016-02-09 18:29 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Paolo Bonzini, Richard Henderson, QEMU Developers, Patch Tracking

[-- Attachment #1: Type: text/plain, Size: 1833 bytes --]

On 02/09/2016 11:04 AM, Peter Maydell wrote:

>>> So _something_ in osdep.h is redefining 'inline' with disastrous effects
>>> to C++.
>>
>> This hack seems to fix things; but I'm not enough of a C++ expert to
>> know if it is the best fix.
>>
>> diff --git i/include/qemu/compiler.h w/include/qemu/compiler.h
>> index d22eb01..d50b806 100644
>> --- i/include/qemu/compiler.h
>> +++ w/include/qemu/compiler.h
>> @@ -77,6 +77,7 @@
>>  #define typeof_field(type, field) typeof(((type *)0)->field)
>>  #define type_check(t1,t2) ((t1*)0 - (t2*)0)
>>
>> +#ifndef __cplusplus
>>  #ifndef always_inline
>>  #if !((__GNUC__ < 3) || defined(__APPLE__))
>>  #ifdef __OPTIMIZE__
>> @@ -88,6 +89,7 @@
>>  #undef inline
>>  #define inline always_inline
>>  #endif
>> +#endif
> 
> Ah, well tracked down. I guess my system headers don't happen
> to rely on this bit of inline syntax.
> 
> Next question -- do we really need to redefine "inline" to
> always_inline at all, in C or C++? (cc'd a few people who might
> have an opinion). My instinct is to say "don't do this, just
> trust the compiler to decide whether to bother inlining".

If ripping that chunk out doesn't hurt anything, I'm all in favor of it.
Redefining 'inline' tends to hurt more than it prevents (and while there
IS the case of C89 vs. C99 vs. GNU having different semantics for
'static inline', those are best worked around by writing and
consistently using wrapper macros such as 'STATIC_INLINE', not
redefining 'inline' itself).

> 
> Git blame says this was added back in commit df2542c737ea2 in
> 2007, with the rationale "To avoid discarded inlining bug"...

The date alone says it may be time to quit doing it :)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 01/14] cpu: Clean up includes
  2016-02-09 15:24 ` [Qemu-devel] [PATCH 01/14] cpu: Clean up includes Peter Maydell
@ 2016-02-12 14:49   ` Andreas Färber
  0 siblings, 0 replies; 33+ messages in thread
From: Andreas Färber @ 2016-02-12 14:49 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

Am 09.02.2016 um 16:24 schrieb Peter Maydell:
> 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.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  qom/cpu.c         | 1 +
>  target-i386/cpu.c | 5 +----
>  2 files changed, 2 insertions(+), 4 deletions(-)

Applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Thanks,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
                   ` (14 preceding siblings ...)
  2016-02-09 16:08 ` [Qemu-devel] [PATCH 00/14] More #include cleanups Eric Blake
@ 2016-02-16 13:49 ` Peter Maydell
  2016-02-16 15:47   ` Peter Maydell
  15 siblings, 1 reply; 33+ messages in thread
From: Peter Maydell @ 2016-02-16 13:49 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Patch Tracking

On 9 February 2016 at 15:24, Peter Maydell <peter.maydell@linaro.org> wrote:
> This set of patches does a bunch more cleaning of includes.
> Specifically it does everything necessary to be able to
> remove osdep.h includes from header files including qemu-common.h

> Eric Blake (1):
>   qapi: Clean up includes in generated files
>
> Peter Maydell (13):
>   cpu: Clean up includes
>   ui/cocoa.m: Include qemu/osdep.h
>   disas/arm-a64.cc: Include osdep.h first
>   hw/block/nand.c: Include osdep.h first
>   target-cris: Remove unnecessary ifdef from mmu.c
>   cris: Clean up includes
>   libdecnumber: Clean up includes
>   tests/i440fx-test: Don't define ARRAY_SIZE locally
>   tests: Clean up includes
>   scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h
>   scripts/tracetool: Include qemu/osdep.h in generated .c files
>   all: Clean up includes
>   oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h

Since I've applied Eric's don't-override-inline patch to master, I'm
going to apply patches 03..14 to master now. (Patch 02 is already in,
and patch 01 is going via Andreas' QOM tree.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] More #include cleanups
  2016-02-16 13:49 ` Peter Maydell
@ 2016-02-16 15:47   ` Peter Maydell
  0 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-16 15:47 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Patch Tracking

On 16 February 2016 at 13:49, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 9 February 2016 at 15:24, Peter Maydell <peter.maydell@linaro.org> wrote:
>> This set of patches does a bunch more cleaning of includes.
>> Specifically it does everything necessary to be able to
>> remove osdep.h includes from header files including qemu-common.h
>
>> Eric Blake (1):
>>   qapi: Clean up includes in generated files
>>
>> Peter Maydell (13):
>>   cpu: Clean up includes
>>   ui/cocoa.m: Include qemu/osdep.h
>>   disas/arm-a64.cc: Include osdep.h first
>>   hw/block/nand.c: Include osdep.h first
>>   target-cris: Remove unnecessary ifdef from mmu.c
>>   cris: Clean up includes
>>   libdecnumber: Clean up includes
>>   tests/i440fx-test: Don't define ARRAY_SIZE locally
>>   tests: Clean up includes
>>   scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h
>>   scripts/tracetool: Include qemu/osdep.h in generated .c files
>>   all: Clean up includes
>>   oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h
>
> Since I've applied Eric's don't-override-inline patch to master, I'm
> going to apply patches 03..14 to master now. (Patch 02 is already in,
> and patch 01 is going via Andreas' QOM tree.)

I dropped the arm-a64.cc change since the ancient w32 compile
didn't like it; so 04..14 pushed to master.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first
  2016-02-09 15:25 ` [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first Peter Maydell
@ 2016-02-18 15:49   ` Peter Maydell
  2016-02-18 16:41     ` Markus Armbruster
  2016-02-18 17:15     ` Eric Blake
  0 siblings, 2 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-18 15:49 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Patch Tracking

On 9 February 2016 at 15:25, Peter Maydell <peter.maydell@linaro.org> wrote:
> Rearrange include directives so that we include osdep.h first.
> This has to be done manually because clean-includes doesn't
> handle C++.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  disas/arm-a64.cc | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc
> index d4d46d5..9280950 100644
> --- a/disas/arm-a64.cc
> +++ b/disas/arm-a64.cc
> @@ -17,12 +17,13 @@
>   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>
> -#include "vixl/a64/disasm-a64.h"
> -
>  extern "C" {
> +#include "qemu/osdep.h"
>  #include "disas/bfd.h"
>  }
>
> +#include "vixl/a64/disasm-a64.h"
> +
>  using namespace vixl;
>
>  static Decoder *vixl_decoder = NULL;

So this patch doesn't build on the old mingw32 compiler. I think this
is because this compiler is not C++11, and so its <stdint.h> doesn't
provide various macros for C++ unless __STDC_CONSTANT_MACROS,
__STDC_LIMIT_MACROS and __STDC_FORMAT_MACROS are defined before the
first inclusion of <stdint.h>.

libvixl's globals.h defines these constants, but this only works if
globals.h is first-include, so making osdep.h first-include then
results in stdint.h being included before globals.h has a chance
to set the defines.

What's the best way to deal with this? I can see a couple of options:

(1) as a special case, for this file include disasm-a64.h before
osdep.h
(2) as a special case, for this file manually define the __STDC_*
before including osdep.h
(3) make osdep.h itself define the __STDC_* constants so it works
with C++-before-C++11 as well as with C and with C++11

I think I prefer (3) (though it does mean we will have to tweak
osdep.h in future if a new vixl version should ever require any
further similar #defines.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first
  2016-02-18 15:49   ` Peter Maydell
@ 2016-02-18 16:41     ` Markus Armbruster
  2016-02-18 16:42       ` Peter Maydell
  2016-02-18 17:15     ` Eric Blake
  1 sibling, 1 reply; 33+ messages in thread
From: Markus Armbruster @ 2016-02-18 16:41 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Patch Tracking

Peter Maydell <peter.maydell@linaro.org> writes:

> On 9 February 2016 at 15:25, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Rearrange include directives so that we include osdep.h first.
>> This has to be done manually because clean-includes doesn't
>> handle C++.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  disas/arm-a64.cc | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc
>> index d4d46d5..9280950 100644
>> --- a/disas/arm-a64.cc
>> +++ b/disas/arm-a64.cc
>> @@ -17,12 +17,13 @@
>>   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>>   */
>>
>> -#include "vixl/a64/disasm-a64.h"
>> -
>>  extern "C" {
>> +#include "qemu/osdep.h"
>>  #include "disas/bfd.h"
>>  }
>>
>> +#include "vixl/a64/disasm-a64.h"
>> +
>>  using namespace vixl;
>>
>>  static Decoder *vixl_decoder = NULL;
>
> So this patch doesn't build on the old mingw32 compiler. I think this
> is because this compiler is not C++11, and so its <stdint.h> doesn't
> provide various macros for C++ unless __STDC_CONSTANT_MACROS,
> __STDC_LIMIT_MACROS and __STDC_FORMAT_MACROS are defined before the
> first inclusion of <stdint.h>.
>
> libvixl's globals.h defines these constants, but this only works if
> globals.h is first-include, so making osdep.h first-include then
> results in stdint.h being included before globals.h has a chance
> to set the defines.
>
> What's the best way to deal with this? I can see a couple of options:
>
> (1) as a special case, for this file include disasm-a64.h before
> osdep.h
> (2) as a special case, for this file manually define the __STDC_*
> before including osdep.h
> (3) make osdep.h itself define the __STDC_* constants so it works
> with C++-before-C++11 as well as with C and with C++11

(4) Tell old mingw32 to take a hike :)

> I think I prefer (3) (though it does mean we will have to tweak
> osdep.h in future if a new vixl version should ever require any
> further similar #defines.)

Doesn't sound like a deal-breaker to me.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first
  2016-02-18 16:41     ` Markus Armbruster
@ 2016-02-18 16:42       ` Peter Maydell
  0 siblings, 0 replies; 33+ messages in thread
From: Peter Maydell @ 2016-02-18 16:42 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU Developers, Patch Tracking

On 18 February 2016 at 16:41, Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>> What's the best way to deal with this? I can see a couple of options:
>>
>> (1) as a special case, for this file include disasm-a64.h before
>> osdep.h
>> (2) as a special case, for this file manually define the __STDC_*
>> before including osdep.h
>> (3) make osdep.h itself define the __STDC_* constants so it works
>> with C++-before-C++11 as well as with C and with C++11
>
> (4) Tell old mingw32 to take a hike :)

I suspect it is not the only pre-C++11 compiler people in the
wild will be using, though...

thanks
-- PMM

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first
  2016-02-18 15:49   ` Peter Maydell
  2016-02-18 16:41     ` Markus Armbruster
@ 2016-02-18 17:15     ` Eric Blake
  1 sibling, 0 replies; 33+ messages in thread
From: Eric Blake @ 2016-02-18 17:15 UTC (permalink / raw)
  To: Peter Maydell, QEMU Developers; +Cc: Patch Tracking

[-- Attachment #1: Type: text/plain, Size: 1473 bytes --]

On 02/18/2016 08:49 AM, Peter Maydell wrote:
> On 9 February 2016 at 15:25, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Rearrange include directives so that we include osdep.h first.
>> This has to be done manually because clean-includes doesn't
>> handle C++.
>>

>> -#include "vixl/a64/disasm-a64.h"
>> -
>>  extern "C" {
>> +#include "qemu/osdep.h"
>>  #include "disas/bfd.h"
>>  }
>>
>> +#include "vixl/a64/disasm-a64.h"
>> +
>>  using namespace vixl;
>>
>>  static Decoder *vixl_decoder = NULL;
> 
> So this patch doesn't build on the old mingw32 compiler. I think this
> is because this compiler is not C++11, and so its <stdint.h> doesn't
> provide various macros for C++ unless __STDC_CONSTANT_MACROS,
> __STDC_LIMIT_MACROS and __STDC_FORMAT_MACROS are defined before the
> first inclusion of <stdint.h>.

> (3) make osdep.h itself define the __STDC_* constants so it works
> with C++-before-C++11 as well as with C and with C++11
> 
> I think I prefer (3) (though it does mean we will have to tweak
> osdep.h in future if a new vixl version should ever require any
> further similar #defines.)

(3) has my vote as well; it's the approach used by gnulib (wherever
practical, do whatever wrapping it takes to make all standard headers
appear like the most modern version of said header, even on older platforms)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2016-02-18 17:15 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-09 15:24 [Qemu-devel] [PATCH 00/14] More #include cleanups Peter Maydell
2016-02-09 15:24 ` [Qemu-devel] [PATCH 01/14] cpu: Clean up includes Peter Maydell
2016-02-12 14:49   ` Andreas Färber
2016-02-09 15:24 ` [Qemu-devel] [PATCH 02/14] ui/cocoa.m: Include qemu/osdep.h Peter Maydell
2016-02-09 16:07   ` Eric Blake
2016-02-09 16:08     ` Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 03/14] disas/arm-a64.cc: Include osdep.h first Peter Maydell
2016-02-18 15:49   ` Peter Maydell
2016-02-18 16:41     ` Markus Armbruster
2016-02-18 16:42       ` Peter Maydell
2016-02-18 17:15     ` Eric Blake
2016-02-09 15:25 ` [Qemu-devel] [PATCH 04/14] hw/block/nand.c: " Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 05/14] target-cris: Remove unnecessary ifdef from mmu.c Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 06/14] cris: Clean up includes Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 07/14] libdecnumber: " Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 08/14] tests/i440fx-test: Don't define ARRAY_SIZE locally Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 09/14] tests: Clean up includes Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 10/14] qapi: Clean up includes in generated files Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 11/14] scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 12/14] scripts/tracetool: Include qemu/osdep.h in generated .c files Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 13/14] all: Clean up includes Peter Maydell
2016-02-09 15:25 ` [Qemu-devel] [PATCH 14/14] oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h Peter Maydell
2016-02-09 16:08 ` [Qemu-devel] [PATCH 00/14] More #include cleanups Eric Blake
2016-02-09 16:11   ` Eric Blake
2016-02-09 16:21     ` Peter Maydell
2016-02-09 17:01       ` Peter Maydell
2016-02-09 17:10       ` Eric Blake
2016-02-09 17:18         ` Eric Blake
2016-02-09 18:04           ` Peter Maydell
2016-02-09 18:17             ` Paolo Bonzini
2016-02-09 18:29             ` Eric Blake
2016-02-16 13:49 ` Peter Maydell
2016-02-16 15:47   ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).