aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVeronia Bahaa <veroniabahaa@gmail.com>2016-03-20 19:16:19 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2016-03-22 22:20:17 +0100
commitf348b6d1a53e5271cf1c9f9acc4646b4b98c1771 (patch)
tree2eb2da02e51400b1b1ecae295e32a81c7a889ab1
parent73bcb24d932912f8e75e1d88da0fc0ac6d4bce78 (diff)
downloadqemu-f348b6d1a53e5271cf1c9f9acc4646b4b98c1771.zip
qemu-f348b6d1a53e5271cf1c9f9acc4646b4b98c1771.tar.gz
qemu-f348b6d1a53e5271cf1c9f9acc4646b4b98c1771.tar.bz2
util: move declarations out of qemu-common.h
Move declarations out of qemu-common.h for functions declared in utils/ files: e.g. include/qemu/path.h for utils/path.c. Move inline functions out of qemu-common.h and into new files (e.g. include/qemu/bcd.h) Signed-off-by: Veronia Bahaa <veroniabahaa@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch_init.c1
-rw-r--r--audio/audio.c1
-rw-r--r--block.c3
-rw-r--r--block/archipelago.c2
-rw-r--r--block/backup.c1
-rw-r--r--block/blkdebug.c2
-rw-r--r--block/blkverify.c1
-rw-r--r--block/block-backend.c1
-rw-r--r--block/curl.c1
-rw-r--r--block/io.c1
-rw-r--r--block/nbd.c2
-rw-r--r--block/qapi.c1
-rw-r--r--block/qcow2-snapshot.c2
-rw-r--r--block/qcow2.c2
-rw-r--r--block/qed.h1
-rw-r--r--block/raw-posix.c2
-rw-r--r--block/raw-win32.c2
-rw-r--r--block/rbd.c2
-rw-r--r--block/sheepdog.c2
-rw-r--r--block/vdi.c2
-rw-r--r--block/vmdk.c2
-rw-r--r--block/vvfat.c2
-rw-r--r--blockdev.c2
-rw-r--r--bsd-user/elfload.c1
-rw-r--r--bsd-user/main.c3
-rw-r--r--contrib/ivshmem-server/main.c2
-rw-r--r--disas/i386.c2
-rw-r--r--dump.c2
-rw-r--r--exec.c2
-rw-r--r--gdbstub.c4
-rw-r--r--hmp.c1
-rw-r--r--hw/9pfs/9p-handle.c1
-rw-r--r--hw/9pfs/9p-local.c1
-rw-r--r--hw/9pfs/9p-proxy.c1
-rw-r--r--hw/9pfs/9p-synth.c1
-rw-r--r--hw/alpha/dp264.c1
-rw-r--r--hw/arm/nseries.c2
-rw-r--r--hw/arm/omap1.c2
-rw-r--r--hw/arm/pxa2xx.c1
-rw-r--r--hw/arm/strongarm.c1
-rw-r--r--hw/block/nvme.h1
-rw-r--r--hw/bt/hci.c1
-rw-r--r--hw/core/loader.c1
-rw-r--r--hw/core/machine.c1
-rw-r--r--hw/cris/boot.c1
-rw-r--r--hw/ide/core.c1
-rw-r--r--hw/lm32/lm32_hwsetup.h1
-rw-r--r--hw/lm32/milkymist.c1
-rw-r--r--hw/microblaze/boot.c1
-rw-r--r--hw/mips/mips_jazz.c1
-rw-r--r--hw/misc/ivshmem.c1
-rw-r--r--hw/misc/macio/cuda.c1
-rw-r--r--hw/nvram/fw_cfg.c1
-rw-r--r--hw/nvram/mac_nvram.c1
-rw-r--r--hw/pci/pci.c1
-rw-r--r--hw/ppc/mac_newworld.c1
-rw-r--r--hw/ppc/mac_oldworld.c1
-rw-r--r--hw/ppc/prep.c1
-rw-r--r--hw/ppc/spapr.c2
-rw-r--r--hw/ppc/spapr_drc.c2
-rw-r--r--hw/ppc/spapr_events.c3
-rw-r--r--hw/ppc/spapr_rtas.c1
-rw-r--r--hw/ppc/spapr_rtc.c1
-rw-r--r--hw/scsi/scsi-bus.c1
-rw-r--r--hw/scsi/scsi-disk.c2
-rw-r--r--hw/scsi/vhost-scsi.c1
-rw-r--r--hw/sparc/sun4m.c1
-rw-r--r--hw/sparc64/sun4u.c1
-rw-r--r--hw/timer/ds1338.c1
-rw-r--r--hw/timer/exynos4210_rtc.c1
-rw-r--r--hw/timer/m48t59.c1
-rw-r--r--hw/timer/mc146818rtc.c2
-rw-r--r--hw/timer/pl031.c1
-rw-r--r--hw/timer/twl92230.c1
-rw-r--r--hw/usb/bus.c1
-rw-r--r--hw/usb/dev-network.c1
-rw-r--r--hw/usb/dev-serial.c1
-rw-r--r--hw/usb/dev-storage.c1
-rw-r--r--hw/watchdog/watchdog.c2
-rw-r--r--hw/xen/xen-host-pci-device.c1
-rw-r--r--include/qemu-common.h257
-rw-r--r--include/qemu/bcd.h15
-rw-r--r--include/qemu/cutils.h183
-rw-r--r--include/qemu/help_option.h22
-rw-r--r--include/qemu/id.h13
-rw-r--r--include/qemu/path.h7
-rw-r--r--include/qemu/unicode.h6
-rw-r--r--linux-user/elfload.c1
-rw-r--r--linux-user/main.c4
-rw-r--r--linux-user/syscall.c2
-rw-r--r--linux-user/uaccess.c1
-rw-r--r--main-loop.c2
-rw-r--r--migration/block.c1
-rw-r--r--migration/migration.c2
-rw-r--r--migration/ram.c1
-rw-r--r--migration/rdma.c1
-rw-r--r--migration/savevm.c3
-rw-r--r--migration/xbzrle.c2
-rw-r--r--monitor.c1
-rw-r--r--net/net.c2
-rw-r--r--net/netmap.c1
-rw-r--r--net/slirp.c1
-rw-r--r--net/tap-bsd.c2
-rw-r--r--net/tap-linux.c2
-rw-r--r--net/tap-solaris.c1
-rw-r--r--net/tap.c1
-rw-r--r--os-posix.c1
-rw-r--r--qapi/opts-visitor.c2
-rw-r--r--qdev-monitor.c1
-rw-r--r--qemu-char.c1
-rw-r--r--qemu-img.c2
-rw-r--r--qemu-io-cmds.c1
-rw-r--r--qemu-nbd.c1
-rw-r--r--qga/commands-posix.c1
-rw-r--r--qga/commands.c1
-rw-r--r--qga/main.c1
-rw-r--r--qmp.c2
-rw-r--r--qobject/json-parser.c1
-rw-r--r--qobject/qdict.c1
-rw-r--r--qobject/qjson.c1
-rw-r--r--qom/object.c2
-rw-r--r--slirp/slirp.c1
-rw-r--r--slirp/tftp.c1
-rw-r--r--target-arm/arm-semi.c1
-rw-r--r--target-i386/cpu.c1
-rw-r--r--target-ppc/kvm.c1
-rw-r--r--target-s390x/cpu.c1
-rw-r--r--tcg/tcg.c2
-rw-r--r--tests/qom-test.c1
-rw-r--r--tests/tcg/linux-test.c1
-rw-r--r--tests/test-cutils.c3
-rw-r--r--tests/test-xbzrle.c1
-rw-r--r--trace/control.c1
-rw-r--r--ui/gtk.c1
-rw-r--r--ui/sdl.c1
-rw-r--r--ui/vnc.c1
-rw-r--r--util/cutils.c33
-rw-r--r--util/event_notifier-posix.c1
-rw-r--r--util/id.c1
-rw-r--r--util/iov.c1
-rw-r--r--util/osdep.c1
-rw-r--r--util/oslib-posix.c1
-rw-r--r--util/oslib-win32.c1
-rw-r--r--util/path.c2
-rw-r--r--util/qemu-option.c3
-rw-r--r--util/qemu-sockets.c1
-rw-r--r--util/readline.c1
-rw-r--r--util/unicode.c2
-rw-r--r--vl.c3
149 files changed, 435 insertions, 300 deletions
diff --git a/arch_init.c b/arch_init.c
index f6aba02..e3bb1b3 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -31,6 +31,7 @@
#include "qemu/error-report.h"
#include "qmp-commands.h"
#include "hw/acpi/acpi.h"
+#include "qemu/help_option.h"
#ifdef TARGET_SPARC
int graphic_width = 1024;
diff --git a/audio/audio.c b/audio/audio.c
index ab0ade8..e60c124 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -27,6 +27,7 @@
#include "monitor/monitor.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
#define AUDIO_CAP "audio"
#include "audio_int.h"
diff --git a/block.c b/block.c
index b4107fc..2a09403 100644
--- a/block.c
+++ b/block.c
@@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "trace.h"
#include "block/block_int.h"
#include "block/blockjob.h"
@@ -40,6 +39,8 @@
#include "qemu/timer.h"
#include "qapi-event.h"
#include "block/throttle-groups.h"
+#include "qemu/cutils.h"
+#include "qemu/id.h"
#ifdef CONFIG_BSD
#include <sys/ioctl.h>
diff --git a/block/archipelago.c b/block/archipelago.c
index 0507589..b9f5e69 100644
--- a/block/archipelago.c
+++ b/block/archipelago.c
@@ -51,7 +51,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "block/block_int.h"
#include "qemu/error-report.h"
#include "qemu/thread.h"
diff --git a/block/backup.c b/block/backup.c
index 77280c6..9170983 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -20,6 +20,7 @@
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h"
+#include "qemu/cutils.h"
#include "sysemu/block-backend.h"
#include "qemu/bitmap.h"
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 792d36b..20d25bd 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -24,7 +24,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/config-file.h"
#include "block/block_int.h"
#include "qemu/module.h"
diff --git a/block/blkverify.c b/block/blkverify.c
index 41432e5..9414b7a 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -13,6 +13,7 @@
#include "block/block_int.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"
+#include "qemu/cutils.h"
typedef struct {
BdrvChild *test_file;
diff --git a/block/block-backend.c b/block/block-backend.c
index dca21d1..adf592e 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -18,6 +18,7 @@
#include "sysemu/blockdev.h"
#include "sysemu/sysemu.h"
#include "qapi-event.h"
+#include "qemu/id.h"
/* Number of coroutines to reserve per attached device model */
#define COROUTINE_POOL_RESERVATION 64
diff --git a/block/curl.c b/block/curl.c
index fe331ca..5a8f8b6 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -30,6 +30,7 @@
#include "qapi/qmp/qstring.h"
#include "crypto/secret.h"
#include <curl/curl.h>
+#include "qemu/cutils.h"
// #define DEBUG_CURL
// #define DEBUG_VERBOSE
diff --git a/block/io.c b/block/io.c
index 041af3c..c2611e5 100644
--- a/block/io.c
+++ b/block/io.c
@@ -28,6 +28,7 @@
#include "block/blockjob.h"
#include "block/block_int.h"
#include "block/throttle-groups.h"
+#include "qemu/cutils.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
diff --git a/block/nbd.c b/block/nbd.c
index d103894..896064a 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -36,7 +36,7 @@
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qint.h"
#include "qapi/qmp/qstring.h"
-
+#include "qemu/cutils.h"
#define EN_OPTSTR ":exportname="
diff --git a/block/qapi.c b/block/qapi.c
index 6a4869a..089614e 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -32,6 +32,7 @@
#include "qapi/qmp-output-visitor.h"
#include "qapi/qmp/types.h"
#include "sysemu/block-backend.h"
+#include "qemu/cutils.h"
BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs, Error **errp)
{
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 269acc2..5f4a17e 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -24,10 +24,10 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "block/block_int.h"
#include "block/qcow2.h"
#include "qemu/error-report.h"
+#include "qemu/cutils.h"
void qcow2_free_snapshots(BlockDriverState *bs)
{
diff --git a/block/qcow2.c b/block/qcow2.c
index cec5bd0..6428029 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "block/block_int.h"
#include "sysemu/block-backend.h"
#include "qemu/module.h"
@@ -36,6 +35,7 @@
#include "qapi-event.h"
#include "trace.h"
#include "qemu/option_int.h"
+#include "qemu/cutils.h"
/*
Differences with QCOW:
diff --git a/block/qed.h b/block/qed.h
index 615e676..22b3198 100644
--- a/block/qed.h
+++ b/block/qed.h
@@ -16,6 +16,7 @@
#define BLOCK_QED_H
#include "block/block_int.h"
+#include "qemu/cutils.h"
/* The layout of a QED file is as follows:
*
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 29dc658..c8e2ec4 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -23,7 +23,7 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "qemu/timer.h"
#include "qemu/log.h"
diff --git a/block/raw-win32.c b/block/raw-win32.c
index bd07c93..fd23891 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -23,7 +23,7 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/timer.h"
#include "block/block_int.h"
#include "qemu/module.h"
diff --git a/block/rbd.c b/block/rbd.c
index 4f3fa30..5bc5b32 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -14,10 +14,10 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/error-report.h"
#include "block/block_int.h"
#include "crypto/secret.h"
+#include "qemu/cutils.h"
#include <rbd/librbd.h>
diff --git a/block/sheepdog.c b/block/sheepdog.c
index a6b179b..48fc165 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -14,13 +14,13 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/uri.h"
#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "block/block_int.h"
#include "sysemu/block-backend.h"
#include "qemu/bitops.h"
+#include "qemu/cutils.h"
#define SD_PROTO_VER 0x01
diff --git a/block/vdi.c b/block/vdi.c
index cdf6b85..71f417c 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -51,12 +51,12 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "block/block_int.h"
#include "sysemu/block-backend.h"
#include "qemu/module.h"
#include "migration/migration.h"
#include "qemu/coroutine.h"
+#include "qemu/cutils.h"
#if defined(CONFIG_UUID)
#include <uuid/uuid.h>
diff --git a/block/vmdk.c b/block/vmdk.c
index 5e341c6..a1a9371 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -25,13 +25,13 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "block/block_int.h"
#include "sysemu/block-backend.h"
#include "qapi/qmp/qerror.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
#include "migration/migration.h"
+#include "qemu/cutils.h"
#include <zlib.h>
#include <glib.h>
diff --git a/block/vvfat.c b/block/vvfat.c
index bdce8da..eb1126c 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -25,13 +25,13 @@
#include "qemu/osdep.h"
#include <dirent.h>
#include "qapi/error.h"
-#include "qemu-common.h"
#include "block/block_int.h"
#include "qemu/module.h"
#include "migration/migration.h"
#include "qapi/qmp/qint.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qstring.h"
+#include "qemu/cutils.h"
#ifndef S_IWGRP
#define S_IWGRP 0
diff --git a/blockdev.c b/blockdev.c
index 24c8861..3eb05d1 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -50,6 +50,8 @@
#include "qmp-commands.h"
#include "trace.h"
#include "sysemu/arch_init.h"
+#include "qemu/cutils.h"
+#include "qemu/help_option.h"
static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states);
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index 0a6092b..898ee05 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -5,6 +5,7 @@
#include "qemu.h"
#include "disas/disas.h"
+#include "qemu/path.h"
#ifdef _ARCH_PPC64
#undef ARCH_DLINFO
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 287ec1d..27854c1 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -21,7 +21,8 @@
#include <sys/mman.h>
#include "qemu.h"
-#include "qemu-common.h"
+#include "qemu/path.h"
+#include "qemu/help_option.h"
/* For tb_lock */
#include "cpu.h"
#include "tcg.h"
diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c
index 4c9a11f..533f501 100644
--- a/contrib/ivshmem-server/main.c
+++ b/contrib/ivshmem-server/main.c
@@ -8,7 +8,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "ivshmem-server.h"
diff --git a/disas/i386.c b/disas/i386.c
index d40b72a..894b0a1 100644
--- a/disas/i386.c
+++ b/disas/i386.c
@@ -33,6 +33,8 @@
#include "qemu/osdep.h"
#include "disas/bfd.h"
+#include "qemu/cutils.h"
+
/* include/opcode/i386.h r1.78 */
/* opcode/i386.h -- Intel 80386 opcode macros
diff --git a/dump.c b/dump.c
index 81d2d4f..9726f1f 100644
--- a/dump.c
+++ b/dump.c
@@ -12,7 +12,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "elf.h"
#include "cpu.h"
#include "exec/cpu-all.h"
diff --git a/exec.c b/exec.c
index 151908e..be2a644 100644
--- a/exec.c
+++ b/exec.c
@@ -22,7 +22,7 @@
#include <sys/mman.h>
#endif
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "cpu.h"
#include "tcg.h"
#include "hw/hw.h"
diff --git a/gdbstub.c b/gdbstub.c
index e4e480f..0e431fd 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -18,9 +18,9 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
-#ifdef CONFIG_USER_ONLY
+#include "qemu/cutils.h"
+#ifdef CONFIG_USER_ONLY
#include "qemu.h"
#else
#include "monitor/monitor.h"
diff --git a/hmp.c b/hmp.c
index 6ace227..d510236 100644
--- a/hmp.c
+++ b/hmp.c
@@ -34,6 +34,7 @@
#include "ui/console.h"
#include "block/qapi.h"
#include "qemu-io.h"
+#include "qemu/cutils.h"
#ifdef CONFIG_SPICE
#include <spice/enums.h>
diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c
index 5088ef5..8940414 100644
--- a/hw/9pfs/9p-handle.c
+++ b/hw/9pfs/9p-handle.c
@@ -20,6 +20,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include "qemu/xattr.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include <linux/fs.h>
#ifdef CONFIG_LINUX_MAGIC_H
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index ca995a7..16f45f4 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -21,6 +21,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include "qemu/xattr.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include <libgen.h>
#include <linux/fs.h>
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index 0805c9c..00a4eb2 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -13,6 +13,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include "9p.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "fsdev/qemu-fsdev.h"
#include "9p-proxy.h"
diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index 365623e..f1475df 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -20,6 +20,7 @@
#include "9p-synth.h"
#include "qemu/rcu.h"
#include "qemu/rcu_queue.h"
+#include "qemu/cutils.h"
/* Root node for synth file system */
static V9fsSynthNode v9fs_synth_root = {
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index 1eee68b..f1267b5 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -20,6 +20,7 @@
#include "hw/ide.h"
#include "hw/timer/i8254.h"
#include "hw/char/serial.h"
+#include "qemu/cutils.h"
#define MAX_IDE_BUS 2
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index 4561d4a..5382505 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -20,7 +20,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "sysemu/sysemu.h"
#include "hw/arm/omap.h"
#include "hw/arm/arm.h"
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 56844c3..b3cf0ec 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -31,6 +31,8 @@
#include "sysemu/blockdev.h"
#include "qemu/range.h"
#include "hw/sysbus.h"
+#include "qemu/cutils.h"
+#include "qemu/bcd.h"
/* Should signal the TCMI/GPMC */
uint32_t omap_badwidth_read8(void *opaque, hwaddr addr)
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 2076098..1a8c360 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -20,6 +20,7 @@
#include "sysemu/char.h"
#include "sysemu/block-backend.h"
#include "sysemu/blockdev.h"
+#include "qemu/cutils.h"
static struct {
hwaddr io_base;
diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c
index 8004128..1eeb1ab 100644
--- a/hw/arm/strongarm.c
+++ b/hw/arm/strongarm.c
@@ -37,6 +37,7 @@
#include "sysemu/char.h"
#include "sysemu/sysemu.h"
#include "hw/ssi/ssi.h"
+#include "qemu/cutils.h"
//#define DEBUG
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index bf3a3cc..8fb0c10 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -1,5 +1,6 @@
#ifndef HW_NVME_H
#define HW_NVME_H
+#include "qemu/cutils.h"
typedef struct NvmeBar {
uint64_t cap;
diff --git a/hw/bt/hci.c b/hw/bt/hci.c
index 1eaa442..7d52205 100644
--- a/hw/bt/hci.c
+++ b/hw/bt/hci.c
@@ -27,6 +27,7 @@
#include "hw/bt.h"
#include "qapi/qmp/qerror.h"
#include "sysemu/replay.h"
+#include "qemu/cutils.h"
struct bt_hci_s {
uint8_t *(*evt_packet)(void *opaque);
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 93410e3..6b949fe 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -54,6 +54,7 @@
#include "exec/memory.h"
#include "exec/address-spaces.h"
#include "hw/boards.h"
+#include "qemu/cutils.h"
#include <zlib.h>
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 136bf27..6dbbc85 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -18,6 +18,7 @@
#include "hw/sysbus.h"
#include "sysemu/sysemu.h"
#include "qemu/error-report.h"
+#include "qemu/cutils.h"
static char *machine_get_accel(Object *obj, Error **errp)
{
diff --git a/hw/cris/boot.c b/hw/cris/boot.c
index 7d423ed..f896ed7 100644
--- a/hw/cris/boot.c
+++ b/hw/cris/boot.c
@@ -29,6 +29,7 @@
#include "hw/loader.h"
#include "elf.h"
#include "boot.h"
+#include "qemu/cutils.h"
static void main_cpu_reset(void *opaque)
{
diff --git a/hw/ide/core.c b/hw/ide/core.c
index f8883b2..90524d5 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -33,6 +33,7 @@
#include "sysemu/dma.h"
#include "hw/block/block.h"
#include "sysemu/block-backend.h"
+#include "qemu/cutils.h"
#include <hw/ide/internal.h>
diff --git a/hw/lm32/lm32_hwsetup.h b/hw/lm32/lm32_hwsetup.h
index 838754d..b71e6ea 100644
--- a/hw/lm32/lm32_hwsetup.h
+++ b/hw/lm32/lm32_hwsetup.h
@@ -26,6 +26,7 @@
#define QEMU_HW_LM32_HWSETUP_H
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "hw/loader.h"
typedef struct {
diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index 2216900..96e6f4d 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -33,6 +33,7 @@
#include "milkymist-hw.h"
#include "lm32.h"
#include "exec/address-spaces.h"
+#include "qemu/cutils.h"
#define BIOS_FILENAME "mmone-bios.bin"
#define BIOS_OFFSET 0x00860000
diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index 7a3759d..9eebb1a 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -35,6 +35,7 @@
#include "sysemu/sysemu.h"
#include "hw/loader.h"
#include "elf.h"
+#include "qemu/cutils.h"
#include "boot.h"
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index 4931cb1..ac7c641 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -45,6 +45,7 @@
#include "exec/address-spaces.h"
#include "sysemu/qtest.h"
#include "qemu/error-report.h"
+#include "qemu/help_option.h"
enum jazz_model_e
{
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 55071dc..30ba1be 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
+#include "qemu/cutils.h"
#include "hw/hw.h"
#include "hw/i386/pc.h"
#include "hw/pci/pci.h"
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index 83995cc..c7472aa 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -28,6 +28,7 @@
#include "hw/input/adb.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
/* XXX: implement all timer modes */
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 7866248..d96932f 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -31,6 +31,7 @@
#include "trace.h"
#include "qemu/error-report.h"
#include "qemu/config-file.h"
+#include "qemu/cutils.h"
#define FW_CFG_NAME "fw_cfg"
#define FW_CFG_PATH "/machine/" FW_CFG_NAME
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index 1671f46..24f6121 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -27,6 +27,7 @@
#include "hw/nvram/openbios_firmware_abi.h"
#include "sysemu/sysemu.h"
#include "hw/ppc/mac.h"
+#include "qemu/cutils.h"
#include <zlib.h>
/* debug NVR */
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index e67664d..bb605ef 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -40,6 +40,7 @@
#include "exec/address-spaces.h"
#include "hw/hotplug.h"
#include "hw/boards.h"
+#include "qemu/cutils.h"
//#define DEBUG_PCI
#ifdef DEBUG_PCI
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 1086f88..32e88b3 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -71,6 +71,7 @@
#include "sysemu/block-backend.h"
#include "exec/address-spaces.h"
#include "hw/sysbus.h"
+#include "qemu/cutils.h"
#define MAX_IDE_BUS 2
#define CFG_ADDR 0xf0000510
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 9bfa02e..a9bb1c2 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -45,6 +45,7 @@
#include "kvm_ppc.h"
#include "sysemu/block-backend.h"
#include "exec/address-spaces.h"
+#include "qemu/cutils.h"
#define MAX_IDE_BUS 2
#define CFG_ADDR 0xf0000510
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 793b9ed..3ffb85e 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -46,6 +46,7 @@
#include "exec/address-spaces.h"
#include "trace.h"
#include "elf.h"
+#include "qemu/cutils.h"
/* SMP is not enabled, for now */
#define MAX_CPUS 1
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 7e80f8a..2c380c2 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -64,7 +64,7 @@
#include "hw/nmi.h"
#include "hw/compat.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include <libfdt.h>
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 96d66d6..e6eedf8 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -12,8 +12,8 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "cpu.h"
+#include "qemu/cutils.h"
#include "hw/ppc/spapr_drc.h"
#include "qom/object.h"
#include "hw/qdev.h"
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 61204f0..1abec27 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -37,7 +37,8 @@
#include "hw/pci/pci.h"
#include "hw/pci-host/spapr.h"
#include "hw/ppc/spapr_drc.h"
-
+#include "qemu/help_option.h"
+#include "qemu/bcd.h"
#include <libfdt.h>
struct rtas_error_log {
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index b7c5ebd..2db2292 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -39,6 +39,7 @@
#include <libfdt.h>
#include "hw/ppc/spapr_drc.h"
+#include "qemu/cutils.h"
/* #define DEBUG_SPAPR */
diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c
index 02fa373..3a17ac4 100644
--- a/hw/ppc/spapr_rtc.c
+++ b/hw/ppc/spapr_rtc.c
@@ -31,6 +31,7 @@
#include "sysemu/sysemu.h"
#include "hw/ppc/spapr.h"
#include "qapi-event.h"
+#include "qemu/cutils.h"
#define SPAPR_RTC(obj) \
OBJECT_CHECK(sPAPRRTCState, (obj), TYPE_SPAPR_RTC)
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index a5ad3c7..ad6f398 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -9,6 +9,7 @@
#include "sysemu/blockdev.h"
#include "trace.h"
#include "sysemu/dma.h"
+#include "qemu/cutils.h"
static char *scsibus_get_dev_path(DeviceState *dev);
static char *scsibus_get_fw_dev_path(DeviceState *dev);
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 96c7953..c3ce54a 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -30,7 +30,6 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/error-report.h"
#include "hw/scsi/scsi.h"
#include "block/scsi.h"
@@ -39,6 +38,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
#include "sysemu/blockdev.h"
#include "hw/block/block.h"
#include "sysemu/dma.h"
+#include "qemu/cutils.h"
#ifdef __linux
#include <scsi/sg.h>
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 97a0dd1..9261d51 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -28,6 +28,7 @@
#include "hw/virtio/virtio-access.h"
#include "hw/fw-path-provider.h"
#include "linux/vhost.h"
+#include "qemu/cutils.h"
/* Features supported by host kernel. */
static const int kernel_feature_bits[] = {
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 30a6afc..7bfc00a 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -46,6 +46,7 @@
#include "elf.h"
#include "sysemu/block-backend.h"
#include "trace.h"
+#include "qemu/cutils.h"
/*
* Sun4m architecture was used in the following machines:
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index ee60280..3165e18 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -44,6 +44,7 @@
#include "elf.h"
#include "sysemu/block-backend.h"
#include "exec/address-spaces.h"
+#include "qemu/cutils.h"
//#define DEBUG_IRQ
//#define DEBUG_EBUS
diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index 385b7d3..0112949 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -13,6 +13,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "hw/i2c/i2c.h"
+#include "qemu/bcd.h"
/* Size of NVRAM including both the user-accessible area and the
* secondary register area.
diff --git a/hw/timer/exynos4210_rtc.c b/hw/timer/exynos4210_rtc.c
index f21fb54..da4dd45 100644
--- a/hw/timer/exynos4210_rtc.c
+++ b/hw/timer/exynos4210_rtc.c
@@ -29,6 +29,7 @@
#include "hw/sysbus.h"
#include "qemu/timer.h"
#include "qemu-common.h"
+#include "qemu/bcd.h"
#include "hw/ptimer.h"
#include "hw/hw.h"
diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index c4db0e6..e46ca88 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -31,6 +31,7 @@
#include "hw/sysbus.h"
#include "hw/isa/isa.h"
#include "exec/address-spaces.h"
+#include "qemu/bcd.h"
//#define DEBUG_NVRAM
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 496a7cd..2ac0fd3 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -23,6 +23,8 @@
*/
#include "qemu/osdep.h"
#include "config-target.h"
+#include "qemu/cutils.h"
+#include "qemu/bcd.h"
#include "hw/hw.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c
index bdec478..38e0cb5 100644
--- a/hw/timer/pl031.c
+++ b/hw/timer/pl031.c
@@ -15,6 +15,7 @@
#include "hw/sysbus.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
//#define DEBUG_PL031
diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index 1c92438..7ba4e9a 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -25,6 +25,7 @@
#include "hw/i2c/i2c.h"
#include "sysemu/sysemu.h"
#include "ui/console.h"
+#include "qemu/bcd.h"
#define VERBOSE 1
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index a9a6f9e..16c3461 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -7,6 +7,7 @@
#include "sysemu/sysemu.h"
#include "monitor/monitor.h"
#include "trace.h"
+#include "qemu/cutils.h"
static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index b183caf..74306b5 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -34,6 +34,7 @@
#include "qemu/config-file.h"
#include "sysemu/sysemu.h"
#include "qemu/iov.h"
+#include "qemu/cutils.h"
/*#define TRAFFIC_DEBUG*/
/* Thanks to NetChip Technologies for donating this product ID.
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index ff4b0c5..ba8538e 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -11,6 +11,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "hw/usb.h"
#include "hw/usb/desc.h"
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 284024e..248a580 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -22,6 +22,7 @@
#include "sysemu/block-backend.h"
#include "sysemu/blockdev.h"
#include "qapi/visitor.h"
+#include "qemu/cutils.h"
//#define DEBUG_MSD
diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 194c9b4..bbf3646 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -20,7 +20,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qemu/queue.h"
@@ -29,6 +28,7 @@
#include "sysemu/watchdog.h"
#include "qapi-event.h"
#include "hw/nmi.h"
+#include "qemu/help_option.h"
static int watchdog_action = WDT_RESET;
static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c
index 4005d6a..eed8cc8 100644
--- a/hw/xen/xen-host-pci-device.c
+++ b/hw/xen/xen-host-pci-device.c
@@ -9,6 +9,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "xen-host-pci-device.h"
#define XEN_HOST_PCI_MAX_EXT_CAP \
diff --git a/include/qemu-common.h b/include/qemu-common.h
index bbb45b2..163bcbb 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -49,205 +49,6 @@ int qemu_main(int argc, char **argv, char **envp);
void qemu_get_timedate(struct tm *tm, int offset);
int qemu_timedate_diff(struct tm *tm);
-/**
- * is_help_option:
- * @s: string to test
- *
- * Check whether @s is one of the standard strings which indicate
- * that the user is asking for a list of the valid values for a
- * command option like -cpu or -M. The current accepted strings
- * are 'help' and '?'. '?' is deprecated (it is a shell wildcard
- * which makes it annoying to use in a reliable way) but provided
- * for backwards compatibility.
- *
- * Returns: true if @s is a request for a list.
- */
-static inline bool is_help_option(const char *s)
-{
- return !strcmp(s, "?") || !strcmp(s, "help");
-}
-
-/* util/cutils.c */
-/**
- * pstrcpy:
- * @buf: buffer to copy string into
- * @buf_size: size of @buf in bytes
- * @str: string to copy
- *
- * Copy @str into @buf, including the trailing NUL, but do not
- * write more than @buf_size bytes. The resulting buffer is
- * always NUL terminated (even if the source string was too long).
- * If @buf_size is zero or negative then no bytes are copied.
- *
- * This function is similar to strncpy(), but avoids two of that
- * function's problems:
- * * if @str fits in the buffer, pstrcpy() does not zero-fill the
- * remaining space at the end of @buf
- * * if @str is too long, pstrcpy() will copy the first @buf_size-1
- * bytes and then add a NUL
- */
-void pstrcpy(char *buf, int buf_size, const char *str);
-/**
- * strpadcpy:
- * @buf: buffer to copy string into
- * @buf_size: size of @buf in bytes
- * @str: string to copy
- * @pad: character to pad the remainder of @buf with
- *
- * Copy @str into @buf (but *not* its trailing NUL!), and then pad the
- * rest of the buffer with the @pad character. If @str is too large
- * for the buffer then it is truncated, so that @buf contains the
- * first @buf_size characters of @str, with no terminator.
- */
-void strpadcpy(char *buf, int buf_size, const char *str, char pad);
-/**
- * pstrcat:
- * @buf: buffer containing existing string
- * @buf_size: size of @buf in bytes
- * @s: string to concatenate to @buf
- *
- * Append a copy of @s to the string already in @buf, but do not
- * allow the buffer to overflow. If the existing contents of @buf
- * plus @str would total more than @buf_size bytes, then write
- * as much of @str as will fit followed by a NUL terminator.
- *
- * @buf must already contain a NUL-terminated string, or the
- * behaviour is undefined.
- *
- * Returns: @buf.
- */
-char *pstrcat(char *buf, int buf_size, const char *s);
-/**
- * strstart:
- * @str: string to test
- * @val: prefix string to look for
- * @ptr: NULL, or pointer to be written to indicate start of
- * the remainder of the string
- *
- * Test whether @str starts with the prefix @val.
- * If it does (including the degenerate case where @str and @val
- * are equal) then return true. If @ptr is not NULL then a
- * pointer to the first character following the prefix is written
- * to it. If @val is not a prefix of @str then return false (and
- * @ptr is not written to).
- *
- * Returns: true if @str starts with prefix @val, false otherwise.
- */
-int strstart(const char *str, const char *val, const char **ptr);
-/**
- * stristart:
- * @str: string to test
- * @val: prefix string to look for
- * @ptr: NULL, or pointer to be written to indicate start of
- * the remainder of the string
- *
- * Test whether @str starts with the case-insensitive prefix @val.
- * This function behaves identically to strstart(), except that the
- * comparison is made after calling qemu_toupper() on each pair of
- * characters.
- *
- * Returns: true if @str starts with case-insensitive prefix @val,
- * false otherwise.
- */
-int stristart(const char *str, const char *val, const char **ptr);
-/**
- * qemu_strnlen:
- * @s: string
- * @max_len: maximum number of bytes in @s to scan
- *
- * Return the length of the string @s, like strlen(), but do not
- * examine more than @max_len bytes of the memory pointed to by @s.
- * If no NUL terminator is found within @max_len bytes, then return
- * @max_len instead.
- *
- * This function has the same behaviour as the POSIX strnlen()
- * function.
- *
- * Returns: length of @s in bytes, or @max_len, whichever is smaller.
- */
-int qemu_strnlen(const char *s, int max_len);
-/**
- * qemu_strsep:
- * @input: pointer to string to parse
- * @delim: string containing delimiter characters to search for
- *
- * Locate the first occurrence of any character in @delim within
- * the string referenced by @input, and replace it with a NUL.
- * The location of the next character after the delimiter character
- * is stored into @input.
- * If the end of the string was reached without finding a delimiter
- * character, then NULL is stored into @input.
- * If @input points to a NULL pointer on entry, return NULL.
- * The return value is always the original value of *@input (and
- * so now points to a NUL-terminated string corresponding to the
- * part of the input up to the first delimiter).
- *
- * This function has the same behaviour as the BSD strsep() function.
- *
- * Returns: the pointer originally in @input.
- */
-char *qemu_strsep(char **input, const char *delim);
-time_t mktimegm(struct tm *tm);
-int qemu_fdatasync(int fd);
-int fcntl_setfl(int fd, int flag);
-int qemu_parse_fd(const char *param);
-int qemu_strtol(const char *nptr, const char **endptr, int base,
- long *result);
-int qemu_strtoul(const char *nptr, const char **endptr, int base,
- unsigned long *result);
-int qemu_strtoll(const char *nptr, const char **endptr, int base,
- int64_t *result);
-int qemu_strtoull(const char *nptr, const char **endptr, int base,
- uint64_t *result);
-
-int parse_uint(const char *s, unsigned long long *value, char **endptr,
- int base);
-int parse_uint_full(const char *s, unsigned long long *value, int base);
-
-/*
- * qemu_strtosz() suffixes used to specify the default treatment of an
- * argument passed to qemu_strtosz() without an explicit suffix.
- * These should be defined using upper case characters in the range
- * A-Z, as qemu_strtosz() will use qemu_toupper() on the given argument
- * prior to comparison.
- */
-#define QEMU_STRTOSZ_DEFSUFFIX_EB 'E'
-#define QEMU_STRTOSZ_DEFSUFFIX_PB 'P'
-#define QEMU_STRTOSZ_DEFSUFFIX_TB 'T'
-#define QEMU_STRTOSZ_DEFSUFFIX_GB 'G'
-#define QEMU_STRTOSZ_DEFSUFFIX_MB 'M'
-#define QEMU_STRTOSZ_DEFSUFFIX_KB 'K'
-#define QEMU_STRTOSZ_DEFSUFFIX_B 'B'
-int64_t qemu_strtosz(const char *nptr, char **end);
-int64_t qemu_strtosz_suffix(const char *nptr, char **end,
- const char default_suffix);
-int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end,
- const char default_suffix, int64_t unit);
-#define K_BYTE (1ULL << 10)
-#define M_BYTE (1ULL << 20)
-#define G_BYTE (1ULL << 30)
-#define T_BYTE (1ULL << 40)
-#define P_BYTE (1ULL << 50)
-#define E_BYTE (1ULL << 60)
-
-/* used to print char* safely */
-#define STR_OR_NULL(str) ((str) ? (str) : "null")
-
-/* id.c */
-
-typedef enum IdSubSystems {
- ID_QDEV,
- ID_BLOCK,
- ID_MAX /* last element, used as array size */
-} IdSubSystems;
-
-char *id_generate(IdSubSystems id);
-bool id_wellformed(const char *id);
-
-/* path.c */
-void init_paths(const char *prefix);
-const char *path(const char *pathname);
-
#define qemu_isalnum(c) isalnum((unsigned char)(c))
#define qemu_isalpha(c) isalpha((unsigned char)(c))
#define qemu_iscntrl(c) iscntrl((unsigned char)(c))
@@ -335,8 +136,6 @@ ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
#define qemu_co_send(sockfd, buf, bytes) \
qemu_co_send_recv(sockfd, buf, bytes, true)
-bool buffer_is_zero(const void *buf, size_t len);
-
void qemu_progress_init(int enabled, float min_skip);
void qemu_progress_end(void);
void qemu_progress_print(float delta, int max);
@@ -351,70 +150,14 @@ void os_setup_early_signal_handling(void);
char *os_find_datadir(void);
void os_parse_cmd_args(int index, const char *optarg);
-/* Convert a byte between binary and BCD. */
-static inline uint8_t to_bcd(uint8_t val)
-{
- return ((val / 10) << 4) | (val % 10);
-}
-
-static inline uint8_t from_bcd(uint8_t val)
-{
- return ((val >> 4) * 10) + (val & 0x0f);
-}
-
#include "qemu/module.h"
/*
- * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128)
- * Input is limited to 14-bit numbers
- */
-
-int uleb128_encode_small(uint8_t *out, uint32_t n);
-int uleb128_decode_small(const uint8_t *in, uint32_t *n);
-
-/* unicode.c */
-int mod_utf8_codepoint(const char *s, size_t n, char **end);
-
-/*
* Hexdump a buffer to a file. An optional string prefix is added to every line
*/
void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);
-/* vector definitions */
-#ifdef __ALTIVEC__
-#include <altivec.h>
-/* The altivec.h header says we're allowed to undef these for
- * C++ compatibility. Here we don't care about C++, but we
- * undef them anyway to avoid namespace pollution.
- */
-#undef vector
-#undef pixel
-#undef bool
-#define VECTYPE __vector unsigned char
-#define SPLAT(p) vec_splat(vec_ld(0, p), 0)
-#define ALL_EQ(v1, v2) vec_all_eq(v1, v2)
-#define VEC_OR(v1, v2) ((v1) | (v2))
-/* altivec.h may redefine the bool macro as vector type.
- * Reset it to POSIX semantics. */
-#define bool _Bool
-#elif defined __SSE2__
-#include <emmintrin.h>
-#define VECTYPE __m128i
-#define SPLAT(p) _mm_set1_epi8(*(p))
-#define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF)
-#define VEC_OR(v1, v2) (_mm_or_si128(v1, v2))
-#else
-#define VECTYPE unsigned long
-#define SPLAT(p) (*(p) * (~0UL / 255))
-#define ALL_EQ(v1, v2) ((v1) == (v2))
-#define VEC_OR(v1, v2) ((v1) | (v2))
-#endif
-
-#define BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR 8
-bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len);
-size_t buffer_find_nonzero_offset(const void *buf, size_t len);
-
/*
* helper to parse debug environment variables
*/
diff --git a/include/qemu/bcd.h b/include/qemu/bcd.h
new file mode 100644
index 0000000..b4c9b64
--- /dev/null
+++ b/include/qemu/bcd.h
@@ -0,0 +1,15 @@
+#ifndef QEMU_BCD_H
+#define QEMU_BCD_H 1
+
+/* Convert a byte between binary and BCD. */
+static inline uint8_t to_bcd(uint8_t val)
+{
+ return ((val / 10) << 4) | (val % 10);
+}
+
+static inline uint8_t from_bcd(uint8_t val)
+{
+ return ((val >> 4) * 10) + (val & 0x0f);
+}
+
+#endif
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
new file mode 100644
index 0000000..db7adad
--- /dev/null
+++ b/include/qemu/cutils.h
@@ -0,0 +1,183 @@
+#ifndef QEMU_CUTILS_H
+#define QEMU_CUTILS_H 1
+
+#include "qemu/fprintf-fn.h"
+
+/**
+ * pstrcpy:
+ * @buf: buffer to copy string into
+ * @buf_size: size of @buf in bytes
+ * @str: string to copy
+ *
+ * Copy @str into @buf, including the trailing NUL, but do not
+ * write more than @buf_size bytes. The resulting buffer is
+ * always NUL terminated (even if the source string was too long).
+ * If @buf_size is zero or negative then no bytes are copied.
+ *
+ * This function is similar to strncpy(), but avoids two of that
+ * function's problems:
+ * * if @str fits in the buffer, pstrcpy() does not zero-fill the
+ * remaining space at the end of @buf
+ * * if @str is too long, pstrcpy() will copy the first @buf_size-1
+ * bytes and then add a NUL
+ */
+void pstrcpy(char *buf, int buf_size, const char *str);
+/**
+ * strpadcpy:
+ * @buf: buffer to copy string into
+ * @buf_size: size of @buf in bytes
+ * @str: string to copy
+ * @pad: character to pad the remainder of @buf with
+ *
+ * Copy @str into @buf (but *not* its trailing NUL!), and then pad the
+ * rest of the buffer with the @pad character. If @str is too large
+ * for the buffer then it is truncated, so that @buf contains the
+ * first @buf_size characters of @str, with no terminator.
+ */
+void strpadcpy(char *buf, int buf_size, const char *str, char pad);
+/**
+ * pstrcat:
+ * @buf: buffer containing existing string
+ * @buf_size: size of @buf in bytes
+ * @s: string to concatenate to @buf
+ *
+ * Append a copy of @s to the string already in @buf, but do not
+ * allow the buffer to overflow. If the existing contents of @buf
+ * plus @str would total more than @buf_size bytes, then write
+ * as much of @str as will fit followed by a NUL terminator.
+ *
+ * @buf must already contain a NUL-terminated string, or the
+ * behaviour is undefined.
+ *
+ * Returns: @buf.
+ */
+char *pstrcat(char *buf, int buf_size, const char *s);
+/**
+ * strstart:
+ * @str: string to test
+ * @val: prefix string to look for
+ * @ptr: NULL, or pointer to be written to indicate start of
+ * the remainder of the string
+ *
+ * Test whether @str starts with the prefix @val.
+ * If it does (including the degenerate case where @str and @val
+ * are equal) then return true. If @ptr is not NULL then a
+ * pointer to the first character following the prefix is written
+ * to it. If @val is not a prefix of @str then return false (and
+ * @ptr is not written to).
+ *
+ * Returns: true if @str starts with prefix @val, false otherwise.
+ */
+int strstart(const char *str, const char *val, const char **ptr);
+/**
+ * stristart:
+ * @str: string to test
+ * @val: prefix string to look for
+ * @ptr: NULL, or pointer to be written to indicate start of
+ * the remainder of the string
+ *
+ * Test whether @str starts with the case-insensitive prefix @val.
+ * This function behaves identically to strstart(), except that the
+ * comparison is made after calling qemu_toupper() on each pair of
+ * characters.
+ *
+ * Returns: true if @str starts with case-insensitive prefix @val,
+ * false otherwise.
+ */
+int stristart(const char *str, const char *val, const char **ptr);
+/**
+ * qemu_strnlen:
+ * @s: string
+ * @max_len: maximum number of bytes in @s to scan
+ *
+ * Return the length of the string @s, like strlen(), but do not
+ * examine more than @max_len bytes of the memory pointed to by @s.
+ * If no NUL terminator is found within @max_len bytes, then return
+ * @max_len instead.
+ *
+ * This function has the same behaviour as the POSIX strnlen()
+ * function.
+ *
+ * Returns: length of @s in bytes, or @max_len, whichever is smaller.
+ */
+int qemu_strnlen(const char *s, int max_len);
+/**
+ * qemu_strsep:
+ * @input: pointer to string to parse
+ * @delim: string containing delimiter characters to search for
+ *
+ * Locate the first occurrence of any character in @delim within
+ * the string referenced by @input, and replace it with a NUL.
+ * The location of the next character after the delimiter character
+ * is stored into @input.
+ * If the end of the string was reached without finding a delimiter
+ * character, then NULL is stored into @input.
+ * If @input points to a NULL pointer on entry, return NULL.
+ * The return value is always the original value of *@input (and
+ * so now points to a NUL-terminated string corresponding to the
+ * part of the input up to the first delimiter).
+ *
+ * This function has the same behaviour as the BSD strsep() function.
+ *
+ * Returns: the pointer originally in @input.
+ */
+char *qemu_strsep(char **input, const char *delim);
+time_t mktimegm(struct tm *tm);
+int qemu_fdatasync(int fd);
+int fcntl_setfl(int fd, int flag);
+int qemu_parse_fd(const char *param);
+int qemu_strtol(const char *nptr, const char **endptr, int base,
+ long *result);
+int qemu_strtoul(const char *nptr, const char **endptr, int base,
+ unsigned long *result);
+int qemu_strtoll(const char *nptr, const char **endptr, int base,
+ int64_t *result);
+int qemu_strtoull(const char *nptr, const char **endptr, int base,
+ uint64_t *result);
+
+int parse_uint(const char *s, unsigned long long *value, char **endptr,
+ int base);
+int parse_uint_full(const char *s, unsigned long long *value, int base);
+
+/*
+ * qemu_strtosz() suffixes used to specify the default treatment of an
+ * argument passed to qemu_strtosz() without an explicit suffix.
+ * These should be defined using upper case characters in the range
+ * A-Z, as qemu_strtosz() will use qemu_toupper() on the given argument
+ * prior to comparison.
+ */
+#define QEMU_STRTOSZ_DEFSUFFIX_EB 'E'
+#define QEMU_STRTOSZ_DEFSUFFIX_PB 'P'
+#define QEMU_STRTOSZ_DEFSUFFIX_TB 'T'
+#define QEMU_STRTOSZ_DEFSUFFIX_GB 'G'
+#define QEMU_STRTOSZ_DEFSUFFIX_MB 'M'
+#define QEMU_STRTOSZ_DEFSUFFIX_KB 'K'
+#define QEMU_STRTOSZ_DEFSUFFIX_B 'B'
+int64_t qemu_strtosz(const char *nptr, char **end);
+int64_t qemu_strtosz_suffix(const char *nptr, char **end,
+ const char default_suffix);
+int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end,
+ const char default_suffix, int64_t unit);
+#define K_BYTE (1ULL << 10)
+#define M_BYTE (1ULL << 20)
+#define G_BYTE (1ULL << 30)
+#define T_BYTE (1ULL << 40)
+#define P_BYTE (1ULL << 50)
+#define E_BYTE (1ULL << 60)
+
+/* used to print char* safely */
+#define STR_OR_NULL(str) ((str) ? (str) : "null")
+
+bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len);
+size_t buffer_find_nonzero_offset(const void *buf, size_t len);
+bool buffer_is_zero(const void *buf, size_t len);
+
+/*
+ * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128)
+ * Input is limited to 14-bit numbers
+ */
+
+int uleb128_encode_small(uint8_t *out, uint32_t n);
+int uleb128_decode_small(const uint8_t *in, uint32_t *n);
+
+#endif
diff --git a/include/qemu/help_option.h b/include/qemu/help_option.h
new file mode 100644
index 0000000..e39a66e
--- /dev/null
+++ b/include/qemu/help_option.h
@@ -0,0 +1,22 @@
+#ifndef QEMU_HELP_OPTION_H
+#define QEMU_HELP_OPTION_H 1
+
+/**
+ * is_help_option:
+ * @s: string to test
+ *
+ * Check whether @s is one of the standard strings which indicate
+ * that the user is asking for a list of the valid values for a
+ * command option like -cpu or -M. The current accepted strings
+ * are 'help' and '?'. '?' is deprecated (it is a shell wildcard
+ * which makes it annoying to use in a reliable way) but provided
+ * for backwards compatibility.
+ *
+ * Returns: true if @s is a request for a list.
+ */
+static inline bool is_help_option(const char *s)
+{
+ return !strcmp(s, "?") || !strcmp(s, "help");
+}
+
+#endif
diff --git a/include/qemu/id.h b/include/qemu/id.h
new file mode 100644
index 0000000..7d90335
--- /dev/null
+++ b/include/qemu/id.h
@@ -0,0 +1,13 @@
+#ifndef QEMU_ID_H
+#define QEMU_ID_H 1
+
+typedef enum IdSubSystems {
+ ID_QDEV,
+ ID_BLOCK,
+ ID_MAX /* last element, used as array size */
+} IdSubSystems;
+
+char *id_generate(IdSubSystems id);
+bool id_wellformed(const char *id);
+
+#endif
diff --git a/include/qemu/path.h b/include/qemu/path.h
new file mode 100644
index 0000000..ed5fee0
--- /dev/null
+++ b/include/qemu/path.h
@@ -0,0 +1,7 @@
+#ifndef QEMU_PATH_H
+#define QEMU_PATH_H 1
+
+void init_paths(const char *prefix);
+const char *path(const char *pathname);
+
+#endif
diff --git a/include/qemu/unicode.h b/include/qemu/unicode.h
new file mode 100644
index 0000000..d873165
--- /dev/null
+++ b/include/qemu/unicode.h
@@ -0,0 +1,6 @@
+#ifndef QEMU_UNICODE_H
+#define QEMU_UNICODE_H 1
+
+int mod_utf8_codepoint(const char *s, size_t n, char **end);
+
+#endif
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 19dc7f5..e47caff 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -7,6 +7,7 @@
#include "qemu.h"
#include "disas/disas.h"
+#include "qemu/path.h"
#ifdef _ARCH_PPC64
#undef ARCH_DLINFO
diff --git a/linux-user/main.c b/linux-user/main.c
index 2b1e755..b432bf2 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -22,7 +22,9 @@
#include <sys/resource.h>
#include "qemu.h"
-#include "qemu-common.h"
+#include "qemu/path.h"
+#include "qemu/cutils.h"
+#include "qemu/help_option.h"
#include "cpu.h"
#include "tcg.h"
#include "qemu/timer.h"
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9517531..032d338 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -18,6 +18,8 @@
*/
#define _ATFILE_SOURCE
#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
#include <elf.h>
#include <endian.h>
#include <grp.h>
diff --git a/linux-user/uaccess.c b/linux-user/uaccess.c
index 75d890d..0a5c0b0 100644
--- a/linux-user/uaccess.c
+++ b/linux-user/uaccess.c
@@ -1,5 +1,6 @@
/* User memory access */
#include "qemu/osdep.h"
+#include "qemu/cutils.h"
#include "qemu.h"
diff --git a/main-loop.c b/main-loop.c
index 9598c5f..89a6994 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -24,7 +24,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/timer.h"
#include "qemu/sockets.h" // struct in_addr needed for libslirp.h
#include "sysemu/qtest.h"
diff --git a/migration/block.c b/migration/block.c
index af8e16d..1743317 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -20,6 +20,7 @@
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "hw/hw.h"
+#include "qemu/cutils.h"
#include "qemu/queue.h"
#include "qemu/timer.h"
#include "migration/block.h"
diff --git a/migration/migration.c b/migration/migration.c
index 034a918..991313a 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -14,7 +14,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "migration/migration.h"
diff --git a/migration/ram.c b/migration/ram.c
index 704f6a9..3f05738 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -28,6 +28,7 @@
#include "qemu/osdep.h"
#include <zlib.h>
#include "qapi-event.h"
+#include "qemu/cutils.h"
#include "qemu/bitops.h"
#include "qemu/bitmap.h"
#include "qemu/timer.h"
diff --git a/migration/rdma.c b/migration/rdma.c
index 0601d52..f6a9992 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -14,6 +14,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "migration/migration.h"
#include "migration/qemu-file.h"
#include "exec/cpu-common.h"
diff --git a/migration/savevm.c b/migration/savevm.c
index 0a33c22..16ba443 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -27,7 +27,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "hw/boards.h"
#include "hw/hw.h"
#include "hw/qdev.h"
@@ -50,7 +49,7 @@
#include "qemu/iov.h"
#include "block/snapshot.h"
#include "block/qapi.h"
-
+#include "qemu/cutils.h"
#ifndef ETH_P_RARP
#define ETH_P_RARP 0x8035
diff --git a/migration/xbzrle.c b/migration/xbzrle.c
index 4db3f6c..c858339 100644
--- a/migration/xbzrle.c
+++ b/migration/xbzrle.c
@@ -11,7 +11,7 @@
*
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "include/migration/migration.h"
/*
diff --git a/monitor.c b/monitor.c
index 3533602..955ed35 100644
--- a/monitor.c
+++ b/monitor.c
@@ -78,6 +78,7 @@
#include "qmp-introspect.h"
#include "sysemu/block-backend.h"
#include "sysemu/qtest.h"
+#include "qemu/cutils.h"
/* for hmp_info_irq/pic */
#if defined(TARGET_SPARC)
diff --git a/net/net.c b/net/net.c
index 1a78edf..3b5a142 100644
--- a/net/net.c
+++ b/net/net.c
@@ -32,9 +32,11 @@
#include "monitor/monitor.h"
#include "qemu-common.h"
+#include "qemu/help_option.h"
#include "qapi/qmp/qerror.h"
#include "qemu/error-report.h"
#include "qemu/sockets.h"
+#include "qemu/cutils.h"
#include "qemu/config-file.h"
#include "qmp-commands.h"
#include "hw/qdev.h"
diff --git a/net/netmap.c b/net/netmap.c
index 6fa2c41..d9c21b2 100644
--- a/net/netmap.c
+++ b/net/netmap.c
@@ -37,6 +37,7 @@
#include "sysemu/sysemu.h"
#include "qemu/error-report.h"
#include "qemu/iov.h"
+#include "qemu/cutils.h"
typedef struct NetmapState {
NetClientState nc;
diff --git a/net/slirp.c b/net/slirp.c
index 95239bc..0bcef22 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -38,6 +38,7 @@
#include "slirp/libslirp.h"
#include "slirp/ip6.h"
#include "sysemu/char.h"
+#include "qemu/cutils.h"
static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
{
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index 33642ae..c506ac3 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -25,7 +25,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "tap_int.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "sysemu/sysemu.h"
#include "qemu/error-report.h"
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 8077d2b..a503fa9 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -33,8 +33,8 @@
#include "sysemu/sysemu.h"
#include "qapi/error.h"
-#include "qemu-common.h"
#include "qemu/error-report.h"
+#include "qemu/cutils.h"
#define PATH_NET_TUN "/dev/net/tun"
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index 26d2042..a2a9235 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -26,6 +26,7 @@
#include "qapi/error.h"
#include "tap_int.h"
#include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
#include <sys/ethernet.h>
#include <sys/sockio.h>
diff --git a/net/tap.c b/net/tap.c
index 3ddf9ec..740e8a2 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -38,6 +38,7 @@
#include "sysemu/sysemu.h"
#include "qapi/error.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "net/tap.h"
diff --git a/os-posix.c b/os-posix.c
index 92fa3ba..107fde3 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -38,6 +38,7 @@
#include "qemu/rcu.h"
#include "qemu/error-report.h"
#include "qemu/log.h"
+#include "qemu/cutils.h"
#ifdef CONFIG_LINUX
#include <sys/prctl.h>
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 5e2b883..602f260 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -12,7 +12,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qapi/qmp/qerror.h"
#include "qapi/opts-visitor.h"
#include "qemu/queue.h"
diff --git a/qdev-monitor.c b/qdev-monitor.c
index be6a07e..e19617f 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -27,6 +27,7 @@
#include "qapi/qmp/qerror.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
+#include "qemu/help_option.h"
/*
* Aliases were a bad idea from the start. Let's keep them
diff --git a/qemu-char.c b/qemu-char.c
index f90e4c1..97aaaae 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
#include "sysemu/block-backend.h"
diff --git a/qemu-img.c b/qemu-img.c
index 8b54d05..bd93d0a 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -27,7 +27,7 @@
#include "qapi/qmp-output-visitor.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/config-file.h"
#include "qemu/option.h"
#include "qemu/error-report.h"
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 13fbb59..139f7eb 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -19,6 +19,7 @@
#include "qemu/main-loop.h"
#include "qemu/timer.h"
#include "sysemu/block-backend.h"
+#include "qemu/cutils.h"
#define CMD_NOFILE_OK 0x01
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 2963c56..9bb9cb7 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "sysemu/block-backend.h"
#include "block/block_int.h"
#include "block/nbd.h"
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 9f51fae..2ae3725 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -23,6 +23,7 @@
#include "qemu/host-utils.h"
#include "qemu/sockets.h"
#include "qemu/base64.h"
+#include "qemu/cutils.h"
#ifndef CONFIG_HAS_ENVIRON
#ifdef __APPLE__
diff --git a/qga/commands.c b/qga/commands.c
index e091ee1..95d8b04 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -16,6 +16,7 @@
#include "qga-qmp-commands.h"
#include "qapi/qmp/qerror.h"
#include "qemu/base64.h"
+#include "qemu/cutils.h"
/* Maximum captured guest-exec out_data/err_data - 16MB */
#define GUEST_EXEC_MAX_OUTPUT (16*1024*1024)
diff --git a/qga/main.c b/qga/main.c
index fb2f663..f1cbd2a 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -28,6 +28,7 @@
#include "qapi/qmp/dispatch.h"
#include "qga/channel.h"
#include "qemu/bswap.h"
+#include "qemu/help_option.h"
#ifdef _WIN32
#include "qga/service-win32.h"
#include "qga/vss-win32.h"
diff --git a/qmp.c b/qmp.c
index 3f16a77..9d0953b 100644
--- a/qmp.c
+++ b/qmp.c
@@ -14,7 +14,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
#include "qmp-commands.h"
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index 6e65b82..67ed727 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -12,7 +12,6 @@
*/
#include "qemu/osdep.h"
-
#include "qapi/error.h"
#include "qemu-common.h"
#include "qapi/qmp/qstring.h"
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 9833bd0..a128536 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -19,6 +19,7 @@
#include "qapi/qmp/qobject.h"
#include "qemu/queue.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
/**
* qdict_new(): Create a new QDict
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 06dc210..ef160d2 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -21,6 +21,7 @@
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qfloat.h"
#include "qapi/qmp/qdict.h"
+#include "qemu/unicode.h"
typedef struct JSONParsingState
{
diff --git a/qom/object.c b/qom/object.c
index 6a1f030..8e6e68d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -14,7 +14,7 @@
#include "qapi/error.h"
#include "qom/object.h"
#include "qom/object_interfaces.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qapi/visitor.h"
#include "qapi-visit.h"
#include "qapi/string-input-visitor.h"
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 9ccf415..3481fcc 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -28,6 +28,7 @@
#include "sysemu/char.h"
#include "slirp.h"
#include "hw/hw.h"
+#include "qemu/cutils.h"
/* host loopback address */
struct in_addr loopback_addr;
diff --git a/slirp/tftp.c b/slirp/tftp.c
index 25ad6ef..12b5ff6 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include <slirp.h>
#include "qemu-common.h"
+#include "qemu/cutils.h"
static inline int tftp_session_in_use(struct tftp_session *spt)
{
diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c
index 76c33b9..8be0645 100644
--- a/target-arm/arm-semi.c
+++ b/target-arm/arm-semi.c
@@ -30,6 +30,7 @@
#include "qemu-common.h"
#include "exec/gdbstub.h"
#include "hw/arm/arm.h"
+#include "qemu/cutils.h"
#endif
#define TARGET_SYS_OPEN 0x01
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 3ea6b29..eee00d6 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -17,6 +17,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
+#include "qemu/cutils.h"
#include "cpu.h"
#include "sysemu/kvm.h"
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 40ec6fd..159ec69 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -42,6 +42,7 @@
#include "exec/gdbstub.h"
#include "exec/memattrs.h"
#include "sysemu/hostmem.h"
+#include "qemu/cutils.h"
//#define DEBUG_KVM
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 9746b1d..4bfff34 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -27,6 +27,7 @@
#include "qapi/error.h"
#include "cpu.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/timer.h"
#include "qemu/error-report.h"
#include "hw/hw.h"
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 550671b..4c8c2d2 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -36,7 +36,7 @@
#define NDEBUG
#endif
-#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/host-utils.h"
#include "qemu/timer.h"
diff --git a/tests/qom-test.c b/tests/qom-test.c
index 3c6cfca..bd5cdde 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -11,6 +11,7 @@
#include <glib.h>
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "libqtest.h"
#include "qapi/qmp/types.h"
diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
index 1c6c013..5070d31 100644
--- a/tests/tcg/linux-test.c
+++ b/tests/tcg/linux-test.c
@@ -39,6 +39,7 @@
#include <dirent.h>
#include <setjmp.h>
#include <sys/shm.h>
+#include "qemu/cutils.h"
#define TESTPATH "/tmp/linux-test.tmp"
#define TESTPORT 7654
diff --git a/tests/test-cutils.c b/tests/test-cutils.c
index 398700d..fb8f5b5 100644
--- a/tests/test-cutils.c
+++ b/tests/test-cutils.c
@@ -28,8 +28,7 @@
#include "qemu/osdep.h"
#include <glib.h>
-#include "qemu-common.h"
-
+#include "qemu/cutils.h"
static void test_parse_uint_null(void)
{
diff --git a/tests/test-xbzrle.c b/tests/test-xbzrle.c
index abd309d..49f6419 100644
--- a/tests/test-xbzrle.c
+++ b/tests/test-xbzrle.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "include/migration/migration.h"
#define PAGE_SIZE 4096
diff --git a/trace/control.c b/trace/control.c
index 20d3370..ccddda5 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -9,6 +9,7 @@
#include "qemu/osdep.h"
#include "trace/control.h"
+#include "qemu/help_option.h"
#ifdef CONFIG_TRACE_SIMPLE
#include "trace/simple.h"
#endif
diff --git a/ui/gtk.c b/ui/gtk.c
index 38ef3fd..f372a6d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -36,6 +36,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "ui/console.h"
#include "ui/gtk.h"
diff --git a/ui/sdl.c b/ui/sdl.c
index abeef33..d8cf5bc 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -30,6 +30,7 @@
#include <SDL_syswm.h>
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "ui/console.h"
#include "ui/input.h"
#include "sysemu/sysemu.h"
diff --git a/ui/vnc.c b/ui/vnc.c
index 6d39ddd..d2ebf1f 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -44,6 +44,7 @@
#include "crypto/tlscredsanon.h"
#include "crypto/tlscredsx509.h"
#include "qom/object_interfaces.h"
+#include "qemu/cutils.h"
#define VNC_REFRESH_INTERVAL_BASE GUI_REFRESH_INTERVAL_DEFAULT
#define VNC_REFRESH_INTERVAL_INC 50
diff --git a/util/cutils.c b/util/cutils.c
index c3dd534..43d1afb 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -29,6 +29,7 @@
#include "qemu/sockets.h"
#include "qemu/iov.h"
#include "net/net.h"
+#include "qemu/cutils.h"
void strpadcpy(char *buf, int buf_size, const char *str, char pad)
{
@@ -160,6 +161,38 @@ int qemu_fdatasync(int fd)
#endif
}
+/* vector definitions */
+#ifdef __ALTIVEC__
+#include <altivec.h>
+/* The altivec.h header says we're allowed to undef these for
+ * C++ compatibility. Here we don't care about C++, but we
+ * undef them anyway to avoid namespace pollution.
+ */
+#undef vector
+#undef pixel
+#undef bool
+#define VECTYPE __vector unsigned char
+#define SPLAT(p) vec_splat(vec_ld(0, p), 0)
+#define ALL_EQ(v1, v2) vec_all_eq(v1, v2)
+#define VEC_OR(v1, v2) ((v1) | (v2))
+/* altivec.h may redefine the bool macro as vector type.
+ * Reset it to POSIX semantics. */
+#define bool _Bool
+#elif defined __SSE2__
+#include <emmintrin.h>
+#define VECTYPE __m128i
+#define SPLAT(p) _mm_set1_epi8(*(p))
+#define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF)
+#define VEC_OR(v1, v2) (_mm_or_si128(v1, v2))
+#else
+#define VECTYPE unsigned long
+#define SPLAT(p) (*(p) * (~0UL / 255))
+#define ALL_EQ(v1, v2) ((v1) == (v2))
+#define VEC_OR(v1, v2) ((v1) | (v2))
+#endif
+
+#define BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR 8
+
static bool
can_use_buffer_find_nonzero_offset_inner(const void *buf, size_t len)
{
diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 2e30e74..b00189a 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -12,6 +12,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/event_notifier.h"
#include "sysemu/char.h"
#include "qemu/main-loop.h"
diff --git a/util/id.c b/util/id.c
index bbbadcc..6141352 100644
--- a/util/id.c
+++ b/util/id.c
@@ -12,6 +12,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "qemu/id.h"
bool id_wellformed(const char *id)
{
diff --git a/util/iov.c b/util/iov.c
index b69e4b7..003fcce 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -20,6 +20,7 @@
#include "qemu-common.h"
#include "qemu/iov.h"
#include "qemu/sockets.h"
+#include "qemu/cutils.h"
size_t iov_from_buf_full(const struct iovec *iov, unsigned int iov_cnt,
size_t offset, const void *buf, size_t bytes)
diff --git a/util/osdep.c b/util/osdep.c
index 8356bdd..d56d071 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -37,6 +37,7 @@ extern int madvise(caddr_t, size_t, int);
#endif
#include "qemu-common.h"
+#include "qemu/cutils.h"
#include "qemu/sockets.h"
#include "qemu/error-report.h"
#include "monitor/monitor.h"
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index dcc3c7e..0908256 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -52,6 +52,7 @@
#include <libgen.h>
#include <setjmp.h>
#include <sys/signal.h>
+#include "qemu/cutils.h"
#ifdef CONFIG_LINUX
#include <sys/syscall.h>
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 4ef4a9a..c926db4 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -37,6 +37,7 @@
#include "qemu/main-loop.h"
#include "trace.h"
#include "qemu/sockets.h"
+#include "qemu/cutils.h"
/* this must come after including "trace.h" */
#include <shlobj.h>
diff --git a/util/path.c b/util/path.c
index d09e8c5..5479f76 100644
--- a/util/path.c
+++ b/util/path.c
@@ -7,6 +7,8 @@
#include <sys/param.h>
#include <dirent.h>
#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
struct pathelem
{
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 98967ff..dd9e73d 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -31,6 +31,9 @@
#include "qapi/qmp/types.h"
#include "qapi/qmp/qerror.h"
#include "qemu/option_int.h"
+#include "qemu/cutils.h"
+#include "qemu/id.h"
+#include "qemu/help_option.h"
/*
* Extracts the name of an option from the parameter string (p points at the
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 6f344d4..b87e17f 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -24,6 +24,7 @@
#include "qapi/qmp-input-visitor.h"
#include "qapi/qmp-output-visitor.h"
#include "qapi-visit.h"
+#include "qemu/cutils.h"
#ifndef AI_ADDRCONFIG
# define AI_ADDRCONFIG 0
diff --git a/util/readline.c b/util/readline.c
index e94c975..bbdee79 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/readline.h"
+#include "qemu/cutils.h"
#define IS_NORM 0
#define IS_ESC 1
diff --git a/util/unicode.c b/util/unicode.c
index 524dca8..a812a35 100644
--- a/util/unicode.c
+++ b/util/unicode.c
@@ -11,7 +11,7 @@
*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/unicode.h"
/**
* mod_utf8_codepoint:
diff --git a/vl.c b/vl.c
index 40ed4d0..6566da2 100644
--- a/vl.c
+++ b/vl.c
@@ -22,7 +22,8 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
-
+#include "qemu/cutils.h"
+#include "qemu/help_option.h"
#ifdef CONFIG_SECCOMP
#include "sysemu/seccomp.h"