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-arm-f348b6d1a53e5271cf1c9f9acc4646b4b98c1771.tar.gz
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 f6aba02cb2..e3bb1b3ac4 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 ab0ade87f8..e60c124de8 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 b4107fcd4c..2a09403649 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 0507589063..b9f5e69d4a 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 77280c6b35..9170983ba9 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 792d36b994..20d25bda67 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 41432e5565..9414b7a84e 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 dca21d1eeb..adf592e867 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 fe331ca1f5..5a8f8b6239 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 041af3c711..c2611e53c8 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 d103894120..896064a131 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 6a4869a8d9..089614ee9d 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 269acc2f4e..5f4a17e473 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 cec5bd02f2..642802971c 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 615e676fc8..22b3198751 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 29dc658e43..c8e2ec40fb 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 bd07c93461..fd23891534 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 4f3fa304d5..5bc5b32530 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 a6b179b11d..48fc165422 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 cdf6b85216..71f417c461 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 5e341c678b..a1a9371bf8 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 bdce8da320..eb1126cbad 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 24c886142a..3eb05d1a90 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 0a6092bdf7..898ee05472 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 287ec1d369..27854c1f91 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 4c9a11f2c5..533f501593 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 d40b72ab10..894b0a1e0f 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 81d2d4f5a0..9726f1f477 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 151908ebdf..be2a644619 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 e4e480f668..0e431fd4df 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 6ace227c66..d510236677 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 5088ef5dcb..894041488a 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 ca995a79db..16f45f4854 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 0805c9cab4..00a4eb2a7b 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 365623e8f3..f1475dfd6d 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 1eee68b748..f1267b5441 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 4561d4a483..5382505559 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 56844c3030..b3cf0ec690 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 2076098b1d..1a8c36033a 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 80041280e2..1eeb1ab391 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 bf3a3ccac8..8fb0c10756 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 1eaa442c38..7d52205093 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 93410e35b5..6b949fe44f 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 136bf275bc..6dbbc85b97 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 7d423ed92f..f896ed7f86 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 f8883b2110..90524d5e16 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 838754d5d8..b71e6eafba 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 22169008be..96e6f4dc2e 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 7a3759d692..9eebb1a521 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 4931cb1bf4..ac7c641258 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 55071dc767..30ba1be957 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 83995ccf0f..c7472aaa9d 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 7866248b93..d96932f6ca 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 1671f4686e..24f61212ba 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 e67664deb3..bb605efae0 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 1086f88d83..32e88b3786 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 9bfa02e097..a9bb1c27df 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 793b9ed34e..3ffb85e601 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 7e80f8ac3c..2c380c26c5 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 96d66d658c..e6eedf8946 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 61204f0b6b..1abec27ec6 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 b7c5ebde40..2db229272e 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 02fa373aee..3a17ac42e4 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 a5ad3c7ae5..ad6f398c32 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 96c7953ecf..c3ce54a203 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 97a0dd1c1d..9261d51da7 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 30a6afcb9c..7bfc00abc2 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 ee602805c0..3165e18eb7 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 385b7d3076..0112949e23 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 f21fb54f5c..da4dd451b9 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 c4db0e6462..e46ca88391 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 496a7cd815..2ac0fd3e48 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 bdec4785bb..38e0cb5ad6 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 1c92438b18..7ba4e9a7c9 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 a9a6f9e56d..16c3461d99 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 b183cafece..74306b58e3 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 ff4b0c588f..ba8538e60e 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 284024e6f4..248a580457 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 194c9b4ed9..bbf3646bae 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 4005d6ae76..eed8cc88e3 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 bbb45b2e64..163bcbb861 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 0000000000..b4c9b64b8f
--- /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 0000000000..db7adadcf9
--- /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 0000000000..e39a66e77b
--- /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 0000000000..7d90335afb
--- /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 0000000000..ed5fee086f
--- /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 0000000000..d8731652d2
--- /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 19dc7f5457..e47caff7ae 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 2b1e7552da..b432bf2b1e 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 951753143c..032d338869 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 75d890dfef..0a5c0b0b29 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 9598c5f4c7..89a699419f 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 af8e16dfc7..1743317288 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 034a918d32..991313a862 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 704f6a95bf..3f057388cb 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 0601d528bc..f6a9992b3e 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 0a33c227c5..16ba443798 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 4db3f6c5cc..c858339259 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 3533602c23..955ed35303 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 1a78edf751..3b5a14298c 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 6fa2c418a5..d9c21b2b86 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 95239bceb0..0bcef226e2 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 33642ae518..c506ac31d6 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 8077d2b575..a503fa9c6e 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 26d2042922..a2a92356c1 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 3ddf9ecd7d..740e8a2613 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 92fa3baa1a..107fde38bf 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 5e2b8832a8..602f2609cc 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 be6a07ee49..e19617fa8b 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 f90e4c1208..97aaaae439 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 8b54d05486..bd93d0a774 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 13fbb5944c..139f7ebcbb 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 2963c56df7..9bb9cb7f61 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 9f51faea80..2ae37255d4 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 e091ee1af1..95d8b04a16 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 fb2f6638ba..f1cbd2a74c 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 3f16a77b44..9d0953bc29 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 6e65b82264..67ed727318 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 9833bd0730..a1285361c4 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 06dc210cbf..ef160d2119 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 6a1f03019b..8e6e68dffc 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 9ccf4157d8..3481fcc94b 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 25ad6efdf8..12b5ff6e25 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 76c33b97e7..8be0645eb0 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 3ea6b294a4..eee00d6bbd 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 40ec6fded2..159ec69790 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 9746b1ddfe..4bfff341dc 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 550671b94d..4c8c2d2991 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 3c6cfca788..bd5cdde261 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 1c6c01318e..5070d31446 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 398700df45..fb8f5b5321 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 abd309d418..49f64195a6 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 20d3370bf8..ccddda537f 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 38ef3fdb42..f372a6d5ae 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 abeef33095..d8cf5bcf74 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 6d39ddd3f9..d2ebf1fb71 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 c3dd53453a..43d1afbbec 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 2e30e74bd6..b00189a754 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 bbbadcc784..6141352955 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 b69e4b7534..003fcce66f 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 8356bdd3d8..d56d071111 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 dcc3c7ea01..09082564c4 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 4ef4a9a13b..c926db4a5c 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 d09e8c5e14..5479f76c6d 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 98967ffde9..dd9e73df54 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 6f344d4405..b87e17fa56 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 e94c97521b..bbdee790b0 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 524dca8c7c..a812a35171 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 40ed4d0cb9..6566da22d3 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"