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>
This commit is contained in:
Veronia Bahaa 2016-03-20 19:16:19 +02:00 committed by Paolo Bonzini
parent 73bcb24d93
commit f348b6d1a5
149 changed files with 435 additions and 300 deletions

View File

@ -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;

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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="

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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:

View File

@ -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:
*

View File

@ -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"

View File

@ -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"

View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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);

View File

@ -5,6 +5,7 @@
#include "qemu.h"
#include "disas/disas.h"
#include "qemu/path.h"
#ifdef _ARCH_PPC64
#undef ARCH_DLINFO

View File

@ -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"

View File

@ -8,7 +8,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "qemu/cutils.h"
#include "ivshmem-server.h"

View File

@ -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

2
dump.c
View File

@ -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"

2
exec.c
View File

@ -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"

View File

@ -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"

1
hmp.c
View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -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"

View File

@ -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 = {

View File

@ -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

View File

@ -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"

View File

@ -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)

View File

@ -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;

View File

@ -37,6 +37,7 @@
#include "sysemu/char.h"
#include "sysemu/sysemu.h"
#include "hw/ssi/ssi.h"
#include "qemu/cutils.h"
//#define DEBUG

View File

@ -1,5 +1,6 @@
#ifndef HW_NVME_H
#define HW_NVME_H
#include "qemu/cutils.h"
typedef struct NvmeBar {
uint64_t cap;

View File

@ -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);

View File

@ -54,6 +54,7 @@
#include "exec/memory.h"
#include "exec/address-spaces.h"
#include "hw/boards.h"
#include "qemu/cutils.h"
#include <zlib.h>

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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>

View File

@ -26,6 +26,7 @@
#define QEMU_HW_LM32_HWSETUP_H
#include "qemu-common.h"
#include "qemu/cutils.h"
#include "hw/loader.h"
typedef struct {

View File

@ -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

View File

@ -35,6 +35,7 @@
#include "sysemu/sysemu.h"
#include "hw/loader.h"
#include "elf.h"
#include "qemu/cutils.h"
#include "boot.h"

View File

@ -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
{

View File

@ -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"

View File

@ -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 */

View File

@ -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

View File

@ -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 */

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -64,7 +64,7 @@
#include "hw/nmi.h"
#include "hw/compat.h"
#include "qemu-common.h"
#include "qemu/cutils.h"
#include <libfdt.h>

View File

@ -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"

View File

@ -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 {

View File

@ -39,6 +39,7 @@
#include <libfdt.h>
#include "hw/ppc/spapr_drc.h"
#include "qemu/cutils.h"
/* #define DEBUG_SPAPR */

View File

@ -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)

View File

@ -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);

View File

@ -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>

View File

@ -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[] = {

View File

@ -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:

View File

@ -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

View File

@ -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.

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -15,6 +15,7 @@
#include "hw/sysbus.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
#include "qemu/cutils.h"
//#define DEBUG_PL031

View File

@ -25,6 +25,7 @@
#include "hw/i2c/i2c.h"
#include "sysemu/sysemu.h"
#include "ui/console.h"
#include "qemu/bcd.h"
#define VERBOSE 1

View File

@ -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);

View File

@ -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.

View File

@ -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"

View File

@ -22,6 +22,7 @@
#include "sysemu/block-backend.h"
#include "sysemu/blockdev.h"
#include "qapi/visitor.h"
#include "qemu/cutils.h"
//#define DEBUG_MSD

View File

@ -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;

View File

@ -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 \

View File

@ -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
*/

15
include/qemu/bcd.h Normal file
View File

@ -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

183
include/qemu/cutils.h Normal file
View File

@ -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

View File

@ -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

13
include/qemu/id.h Normal file
View File

@ -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

7
include/qemu/path.h Normal file
View File

@ -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

6
include/qemu/unicode.h Normal file
View File

@ -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

View File

@ -7,6 +7,7 @@
#include "qemu.h"
#include "disas/disas.h"
#include "qemu/path.h"
#ifdef _ARCH_PPC64
#undef ARCH_DLINFO

View File

@ -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"

View File

@ -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>

View File

@ -1,5 +1,6 @@
/* User memory access */
#include "qemu/osdep.h"
#include "qemu/cutils.h"
#include "qemu.h"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -11,7 +11,7 @@
*
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/cutils.h"
#include "include/migration/migration.h"
/*

View File

@ -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)

View File

@ -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"

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