Merge branch 'noglib' of https://github.com/cseagle/unicorn into cseagle-noglib
This commit is contained in:
commit
5f81c00559
8
Makefile
8
Makefile
@ -82,12 +82,6 @@ CC = $(CROSS)-gcc
|
||||
AR = $(CROSS)-ar
|
||||
RANLIB = $(CROSS)-ranlib
|
||||
STRIP = $(CROSS)-strip
|
||||
GLIB = "-L/usr/$(CROSS)/lib/ -lglib-2.0"
|
||||
endif
|
||||
|
||||
# Find GLIB
|
||||
ifndef GLIB
|
||||
GLIB = `pkg-config --libs glib-2.0`
|
||||
endif
|
||||
|
||||
ifeq ($(PKG_EXTRA),)
|
||||
@ -195,7 +189,7 @@ else
|
||||
PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig
|
||||
endif
|
||||
|
||||
$(LIBNAME)_LDFLAGS += $(GLIB) -lm
|
||||
$(LIBNAME)_LDFLAGS += -lm
|
||||
|
||||
.PHONY: all
|
||||
all: unicorn
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -O3 -Wall -Werror -I../../../include
|
||||
#cgo LDFLAGS: -L../../../ -lunicorn -lglib-2.0
|
||||
#cgo LDFLAGS: -L../../../ -lunicorn
|
||||
#include <unicorn/unicorn.h>
|
||||
#include "uc.h"
|
||||
*/
|
||||
|
@ -28,7 +28,6 @@ ALL_WINDOWS_DLLS = (
|
||||
"libiconv-2.dll",
|
||||
"libpcre-1.dll",
|
||||
"libintl-8.dll",
|
||||
"libglib-2.0-0.dll",
|
||||
)
|
||||
|
||||
# are we building from the repository or from a source distribution?
|
||||
|
@ -32,7 +32,6 @@ _all_windows_dlls = (
|
||||
"libiconv-2.dll",
|
||||
"libpcre-1.dll",
|
||||
"libintl-8.dll",
|
||||
"libglib-2.0-0.dll",
|
||||
)
|
||||
|
||||
_loaded_windows_dlls = set()
|
||||
|
4
make.sh
4
make.sh
@ -3,9 +3,6 @@
|
||||
# Unicorn Engine
|
||||
# By Nguyen Anh Quynh <aquynh@gmail.com>, 2015
|
||||
|
||||
# Note: to cross-compile to Windows on Linux, Mingw-glib2 is required.
|
||||
# See README on how to install Mingw-glib2.
|
||||
|
||||
MAKE_JOBS=$((${MAKE_JOBS}+0))
|
||||
[ ${MAKE_JOBS} -lt 1 ] && \
|
||||
MAKE_JOBS=4
|
||||
@ -42,7 +39,6 @@ build_cross() {
|
||||
CC=$CROSS-gcc \
|
||||
AR=$CROSS-gcc-ar \
|
||||
RANLIB=$CROSS-gcc-ranlib \
|
||||
GLIB="-L/usr/$CROSS/lib/ -lglib-2.0" \
|
||||
${MAKE}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ util-obj-y = util/ qobject/ qapi/ qapi-types.o qapi-visit.o
|
||||
# block-obj-y is code used by both qemu system emulation and qemu-img
|
||||
|
||||
block-obj-y =
|
||||
block-obj-y += ../uc.o ../list.o
|
||||
block-obj-y += ../uc.o ../list.o glib_compat.o
|
||||
#block-obj-$(CONFIG_POSIX) += aio-posix.o
|
||||
#block-obj-$(CONFIG_WIN32) += aio-win32.o
|
||||
|
||||
|
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_aarch64
|
||||
#define object_property_get object_property_get_aarch64
|
||||
#define object_property_get_bool object_property_get_bool_aarch64
|
||||
#define object_property_get_enum object_property_get_enum_aarch64
|
||||
#define object_property_get_int object_property_get_int_aarch64
|
||||
#define object_property_get_link object_property_get_link_aarch64
|
||||
#define object_property_get_qobject object_property_get_qobject_aarch64
|
||||
#define object_property_get_str object_property_get_str_aarch64
|
||||
#define object_property_get_type object_property_get_type_aarch64
|
||||
#define object_property_get_uint16List object_property_get_uint16List_aarch64
|
||||
#define object_property_is_child object_property_is_child_aarch64
|
||||
#define object_property_print object_property_print_aarch64
|
||||
#define object_property_set object_property_set_aarch64
|
||||
#define object_property_set_description object_property_set_description_aarch64
|
||||
#define object_property_set_link object_property_set_link_aarch64
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_aarch64
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_aarch64
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_aarch64
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_aarch64
|
||||
#define qemu_get_ram_block qemu_get_ram_block_aarch64
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_aarch64
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_aarch64
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_aarch64
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_aarch64
|
||||
#define string_input_visitor_new string_input_visitor_new_aarch64
|
||||
#define string_output_append string_output_append_aarch64
|
||||
#define string_output_append_range string_output_append_range_aarch64
|
||||
#define string_output_get_string string_output_get_string_aarch64
|
||||
#define string_output_get_visitor string_output_get_visitor_aarch64
|
||||
#define string_output_set string_output_set_aarch64
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_aarch64
|
||||
#define string_output_visitor_new string_output_visitor_new_aarch64
|
||||
#define stristart stristart_aarch64
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_aarch64
|
||||
#define strpadcpy strpadcpy_aarch64
|
||||
|
@ -101,7 +101,7 @@ static AccelClass *accel_find(struct uc_struct *uc, const char *opt_name)
|
||||
{
|
||||
char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);
|
||||
AccelClass *ac = ACCEL_CLASS(uc, object_class_by_name(uc, class_name));
|
||||
g_free(class_name);
|
||||
free(class_name);
|
||||
return ac;
|
||||
}
|
||||
|
||||
|
11
qemu/arm.h
11
qemu/arm.h
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_arm
|
||||
#define object_property_get object_property_get_arm
|
||||
#define object_property_get_bool object_property_get_bool_arm
|
||||
#define object_property_get_enum object_property_get_enum_arm
|
||||
#define object_property_get_int object_property_get_int_arm
|
||||
#define object_property_get_link object_property_get_link_arm
|
||||
#define object_property_get_qobject object_property_get_qobject_arm
|
||||
#define object_property_get_str object_property_get_str_arm
|
||||
#define object_property_get_type object_property_get_type_arm
|
||||
#define object_property_get_uint16List object_property_get_uint16List_arm
|
||||
#define object_property_is_child object_property_is_child_arm
|
||||
#define object_property_print object_property_print_arm
|
||||
#define object_property_set object_property_set_arm
|
||||
#define object_property_set_description object_property_set_description_arm
|
||||
#define object_property_set_link object_property_set_link_arm
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_arm
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_arm
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_arm
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_arm
|
||||
#define qemu_get_ram_block qemu_get_ram_block_arm
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_arm
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_arm
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_arm
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_arm
|
||||
#define string_input_visitor_new string_input_visitor_new_arm
|
||||
#define string_output_append string_output_append_arm
|
||||
#define string_output_append_range string_output_append_range_arm
|
||||
#define string_output_get_string string_output_get_string_arm
|
||||
#define string_output_get_visitor string_output_get_visitor_arm
|
||||
#define string_output_set string_output_set_arm
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_arm
|
||||
#define string_output_visitor_new string_output_visitor_new_arm
|
||||
#define stristart stristart_arm
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_arm
|
||||
#define strpadcpy strpadcpy_arm
|
||||
|
32
qemu/configure
vendored
32
qemu/configure
vendored
@ -1087,34 +1087,6 @@ if test -n "$libtool"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
##########################################
|
||||
# glib support probe
|
||||
|
||||
if test "$mingw32" = yes; then
|
||||
# g_poll is required in order to integrate with the glib main loop.
|
||||
glib_req_ver=2.20
|
||||
else
|
||||
glib_req_ver=2.12
|
||||
fi
|
||||
glib_modules=gthread-2.0
|
||||
|
||||
for i in $glib_modules; do
|
||||
if $pkg_config --atleast-version=$glib_req_ver $i; then
|
||||
glib_cflags=`$pkg_config --cflags $i`
|
||||
glib_libs=`$pkg_config --libs $i`
|
||||
CFLAGS="$glib_cflags $CFLAGS"
|
||||
LIBS="$glib_libs $LIBS"
|
||||
else
|
||||
error_exit "glib-$glib_req_ver $i is required to compile QEMU"
|
||||
fi
|
||||
done
|
||||
|
||||
# g_test_trap_subprocess added in 2.38. Used by some tests.
|
||||
glib_subprocess=yes
|
||||
if ! $pkg_config --atleast-version=2.38 glib-2.0; then
|
||||
glib_subprocess=no
|
||||
fi
|
||||
|
||||
##########################################
|
||||
# pthread probe
|
||||
PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
|
||||
@ -1599,10 +1571,6 @@ fi
|
||||
if test "$bswap_h" = "yes" ; then
|
||||
echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
|
||||
fi
|
||||
if test "glib_subprocess" = "yes" ; then
|
||||
echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
|
||||
fi
|
||||
echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
|
||||
if test "$signalfd" = "yes" ; then
|
||||
echo "CONFIG_SIGNALFD=y" >> $config_host_mak
|
||||
fi
|
||||
|
@ -108,7 +108,7 @@ static void *qemu_tcg_cpu_loop(struct uc_struct *uc)
|
||||
|
||||
cpu->created = false;
|
||||
qemu_cond_destroy(cpu->halt_cond);
|
||||
g_free(cpu->halt_cond);
|
||||
free(cpu->halt_cond);
|
||||
cpu->halt_cond = NULL;
|
||||
|
||||
qemu_mutex_unlock(&uc->qemu_global_mutex);
|
||||
|
28
qemu/exec.c
28
qemu/exec.c
@ -517,7 +517,7 @@ void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint)
|
||||
|
||||
tlb_flush_page(cpu, watchpoint->vaddr);
|
||||
|
||||
g_free(watchpoint);
|
||||
free(watchpoint);
|
||||
}
|
||||
|
||||
/* Remove all matching watchpoints. */
|
||||
@ -610,7 +610,7 @@ void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *breakpoint)
|
||||
|
||||
breakpoint_invalidate(cpu, breakpoint->pc);
|
||||
|
||||
g_free(breakpoint);
|
||||
free(breakpoint);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -814,7 +814,7 @@ static void phys_section_destroy(MemoryRegion *mr)
|
||||
if (mr->subpage) {
|
||||
subpage_t *subpage = container_of(mr, subpage_t, iomem);
|
||||
object_unref(mr->uc, OBJECT(&subpage->iomem));
|
||||
g_free(subpage);
|
||||
free(subpage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -824,8 +824,8 @@ static void phys_sections_free(PhysPageMap *map)
|
||||
MemoryRegionSection *section = &map->sections[--map->sections_nb];
|
||||
phys_section_destroy(section->mr);
|
||||
}
|
||||
g_free(map->sections);
|
||||
g_free(map->nodes);
|
||||
free(map->sections);
|
||||
free(map->nodes);
|
||||
}
|
||||
|
||||
static void register_subpage(struct uc_struct* uc,
|
||||
@ -1086,7 +1086,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
||||
}
|
||||
addr = ram_block_add(mr->uc, new_block, &local_err);
|
||||
if (local_err) {
|
||||
g_free(new_block);
|
||||
free(new_block);
|
||||
error_propagate(errp, local_err);
|
||||
return -1;
|
||||
}
|
||||
@ -1109,7 +1109,7 @@ void qemu_ram_free_from_ptr(struct uc_struct *uc, ram_addr_t addr)
|
||||
QTAILQ_REMOVE(&uc->ram_list.blocks, block, next);
|
||||
uc->ram_list.mru_block = NULL;
|
||||
uc->ram_list.version++;
|
||||
g_free(block);
|
||||
free(block);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1137,7 +1137,7 @@ void qemu_ram_free(struct uc_struct *uc, ram_addr_t addr)
|
||||
} else {
|
||||
qemu_anon_ram_free(block->host, block->length);
|
||||
}
|
||||
g_free(block);
|
||||
free(block);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1457,7 +1457,7 @@ MemoryRegion *iotlb_to_region(AddressSpace *as, hwaddr index)
|
||||
void phys_mem_clean(struct uc_struct* uc)
|
||||
{
|
||||
AddressSpaceDispatch* d = uc->as.next_dispatch;
|
||||
g_free(d->map.sections);
|
||||
free(d->map.sections);
|
||||
}
|
||||
|
||||
static void mem_begin(MemoryListener *listener)
|
||||
@ -1494,7 +1494,7 @@ static void mem_commit(MemoryListener *listener)
|
||||
|
||||
if (cur) {
|
||||
phys_sections_free(&cur->map);
|
||||
g_free(cur);
|
||||
free(cur);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1531,13 +1531,13 @@ void address_space_destroy_dispatch(AddressSpace *as)
|
||||
AddressSpaceDispatch *d = as->dispatch;
|
||||
|
||||
memory_listener_unregister(as->uc, &as->dispatch_listener);
|
||||
g_free(d->map.nodes);
|
||||
g_free(d);
|
||||
free(d->map.nodes);
|
||||
free(d);
|
||||
|
||||
if (as->dispatch != as->next_dispatch) {
|
||||
d = as->next_dispatch;
|
||||
g_free(d->map.nodes);
|
||||
g_free(d);
|
||||
free(d->map.nodes);
|
||||
free(d);
|
||||
}
|
||||
|
||||
as->dispatch = NULL;
|
||||
|
707
qemu/glib_compat.c
Normal file
707
qemu/glib_compat.c
Normal file
@ -0,0 +1,707 @@
|
||||
/*
|
||||
glib_compat.c replacement functionality for glib code used in qemu
|
||||
Copyright (C) 2016 Chris Eagle cseagle at gmail dot com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glib_compat.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN64
|
||||
#define __HAVE_64_BIT_PTRS
|
||||
#else
|
||||
#define __HAVE_32_BIT_PTRS
|
||||
#endif
|
||||
#else
|
||||
#ifdef _WIN64
|
||||
#define __HAVE_64_BIT_PTRS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef __x86_64__
|
||||
#define __HAVE_64_BIT_PTRS
|
||||
#else
|
||||
#ifdef __ppc64__
|
||||
#define __HAVE_64_BIT_PTRS
|
||||
#else
|
||||
#ifdef __aarch64__
|
||||
#define __HAVE_64_BIT_PTRS
|
||||
#else
|
||||
#define __HAVE_32_BIT_PTRS
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* All functions below added to eliminate GLIB dependency */
|
||||
|
||||
/* hashing and equality functions */
|
||||
|
||||
/*
|
||||
Too many pointers are multiples of 8/16 so I rotate the low bits out
|
||||
otherwise we get too many collisions at multiples of 8/16
|
||||
This may be marginally better than what glib does in their direct_hash
|
||||
but someone with some chops in this space should fix if it needs improving
|
||||
*/
|
||||
uint32_t g_direct_hash(const void *v) {
|
||||
#ifdef __HAVE_64_BIT_PTRS
|
||||
uint64_t hash = (uint64_t)v;
|
||||
hash = (hash >> 4) | (hash << 60);
|
||||
hash = hash ^ (hash >> 32);
|
||||
return (uint32_t)hash;
|
||||
#else
|
||||
uint32_t hash = (uint32_t)v;
|
||||
hash = (hash >> 3) | (hash << 29);
|
||||
return hash;
|
||||
#endif
|
||||
}
|
||||
|
||||
int g_direct_equal(const void *v1, const void *v2) {
|
||||
return v1 == v2;
|
||||
}
|
||||
|
||||
/*
|
||||
djb2+ string hashing
|
||||
see: http://www.cse.yorku.ca/~oz/hash.html
|
||||
*/
|
||||
uint32_t g_str_hash(const void *v) {
|
||||
const char *s = (const char*)v;
|
||||
uint32_t hash = 5381;
|
||||
while (*s) {
|
||||
hash = ((hash << 5) + hash) ^ (int)*s;
|
||||
s++;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
int g_str_equal(const void *v1, const void *v2) {
|
||||
return strcmp((const char*)v1, (const char*)v2) == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Bob Jenkins integer hash algorithm
|
||||
see: http://burtleburtle.net/bob/hash/integer.html
|
||||
*/
|
||||
uint32_t g_int_hash(const void *v) {
|
||||
uint32_t hash = *(const uint32_t*)v;
|
||||
hash = (hash + 0x7ed55d16) + (hash << 12);
|
||||
hash = (hash ^ 0xc761c23c) ^ (hash >> 19);
|
||||
hash = (hash + 0x165667b1) + (hash << 5);
|
||||
hash = (hash + 0xd3a2646c) ^ (hash << 9);
|
||||
hash = (hash + 0xfd7046c5) + (hash << 3);
|
||||
hash = (hash ^ 0xb55a4f09) ^ (hash >> 16);
|
||||
return hash;
|
||||
}
|
||||
|
||||
int g_int_equal(const void *v1, const void *v2) {
|
||||
return *(const int*)v1 == *(const int*)v2;
|
||||
}
|
||||
|
||||
/* Doubly-linked list */
|
||||
|
||||
GList *g_list_first(GList *list) {
|
||||
if (list == NULL) return NULL;
|
||||
while (list->prev) list = list->prev;
|
||||
return list;
|
||||
}
|
||||
|
||||
void g_list_foreach(GList *list, list_func func, void* user_data) {
|
||||
GList *lp;
|
||||
for (lp = list; lp; lp = lp->next) {
|
||||
(*func)(lp->data, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
void g_list_free(GList *list) {
|
||||
GList *lp, *next, *prev = NULL;
|
||||
if (list) prev = list->prev;
|
||||
for (lp = list; lp; lp = next) {
|
||||
next = lp->next;
|
||||
free(lp);
|
||||
}
|
||||
for (lp = prev; lp; lp = prev) {
|
||||
prev = lp->prev;
|
||||
free(lp);
|
||||
}
|
||||
}
|
||||
|
||||
GList *g_list_insert_sorted(GList *list, void* data, compare_func compare) {
|
||||
GList *i;
|
||||
GList *n = (GList*)g_malloc(sizeof(GList));
|
||||
n->data = data;
|
||||
if (list == NULL) {
|
||||
n->next = n->prev = NULL;
|
||||
return n;
|
||||
}
|
||||
for (i = list; i; i = i->next) {
|
||||
n->prev = i->prev;
|
||||
if ((*compare)(data, i->data) <= 0) {
|
||||
n->next = i;
|
||||
i->prev = n;
|
||||
if (i == list) return n;
|
||||
else return list;
|
||||
}
|
||||
}
|
||||
n->prev = n->prev->next;
|
||||
n->next = NULL;
|
||||
n->prev->next = n;
|
||||
return list;
|
||||
}
|
||||
|
||||
GList *g_list_prepend(GList *list, void* data) {
|
||||
GList *n = (GList*)g_malloc(sizeof(GList));
|
||||
n->next = list;
|
||||
n->prev = NULL;
|
||||
n->data = data;
|
||||
return n;
|
||||
}
|
||||
|
||||
GList *g_list_remove_link(GList *list, GList *llink) {
|
||||
if (llink == list) list = list->next;
|
||||
if (llink->prev) llink->prev->next = llink->next;
|
||||
if (llink->next) llink->next->prev = llink->prev;
|
||||
return list;
|
||||
}
|
||||
|
||||
GList *g_list_sort(GList *list, compare_func compare) {
|
||||
GList *i, *it, *j;
|
||||
/* base case for singletons or empty lists */
|
||||
if (list == NULL || list->next == NULL) return list;
|
||||
i = list;
|
||||
j = i->next;
|
||||
/* i walks half as fast as j, ends up in middle */
|
||||
while (j) {
|
||||
j = j->next;
|
||||
if (j) {
|
||||
i = i->next;
|
||||
j = j->next;
|
||||
}
|
||||
}
|
||||
/* split the list midway */
|
||||
j = i->next;
|
||||
j->prev = NULL; /* make j the head of its own list */
|
||||
i->next = NULL;
|
||||
/* will never have NULL return from either call below */
|
||||
i = g_list_sort(list, compare);
|
||||
j = g_list_sort(j, compare);
|
||||
if ((*compare)(i->data, j->data) <= 0) {
|
||||
list = i;
|
||||
i = i->next;
|
||||
}
|
||||
else {
|
||||
list = j;
|
||||
j = j->next;
|
||||
}
|
||||
it = list;
|
||||
while (i && j) {
|
||||
if ((*compare)(i->data, j->data) <= 0) {
|
||||
it->next = i;
|
||||
i = i->next;
|
||||
}
|
||||
else {
|
||||
it->next = j;
|
||||
j = j->next;
|
||||
}
|
||||
it = it->next;
|
||||
}
|
||||
if (i) it->next = i;
|
||||
else it->next = j;
|
||||
return list;
|
||||
}
|
||||
|
||||
/* END of g_list related functions */
|
||||
|
||||
/* Singly-linked list */
|
||||
|
||||
GSList *g_slist_append(GSList *list, void* data) {
|
||||
GSList *head = list;
|
||||
if (list) {
|
||||
while (list->next) list = list->next;
|
||||
list->next = (GSList*)g_malloc(sizeof(GSList));
|
||||
list = list->next;
|
||||
}
|
||||
else {
|
||||
head = list = (GSList*)g_malloc(sizeof(GSList));
|
||||
}
|
||||
list->data = data;
|
||||
list->next = NULL;
|
||||
return head;
|
||||
}
|
||||
|
||||
void g_slist_foreach(GSList *list, list_func func, void* user_data) {
|
||||
GSList *lp;
|
||||
for (lp = list; lp; lp = lp->next) {
|
||||
(*func)(lp->data, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
void g_slist_free(GSList *list) {
|
||||
GSList *lp, *next;
|
||||
for (lp = list; lp; lp = next) {
|
||||
next = lp->next;
|
||||
free(lp);
|
||||
}
|
||||
}
|
||||
|
||||
void g_slist_free_full(GSList *list, GDestroyNotify free_func) {
|
||||
GSList *lp, *next;
|
||||
for (lp = list; lp; lp = next) {
|
||||
next = lp->next;
|
||||
if (free_func) (*free_func)(lp->data);
|
||||
free(lp);
|
||||
}
|
||||
}
|
||||
|
||||
GSList *g_slist_prepend(GSList *list, void* data) {
|
||||
GSList *head = (GSList*)g_malloc(sizeof(GSList));
|
||||
head->next = list;
|
||||
head->data = data;
|
||||
return head;
|
||||
}
|
||||
|
||||
GSList *g_slist_sort(GSList *list, compare_func compare) {
|
||||
GSList *i, *it, *j;
|
||||
/* base case for singletons or empty lists */
|
||||
if (list == NULL || list->next == NULL) return list;
|
||||
i = list;
|
||||
j = i->next;
|
||||
/* i walks half as fast as j, ends up in middle */
|
||||
while (j) {
|
||||
j = j->next;
|
||||
if (j) {
|
||||
i = i->next;
|
||||
j = j->next;
|
||||
}
|
||||
}
|
||||
/* split the list midway */
|
||||
j = i->next;
|
||||
i->next = NULL;
|
||||
/* will never have NULL return from either call below */
|
||||
i = g_slist_sort(list, compare);
|
||||
j = g_slist_sort(j, compare);
|
||||
if ((*compare)(i->data, j->data) <= 0) {
|
||||
list = i;
|
||||
i = i->next;
|
||||
}
|
||||
else {
|
||||
list = j;
|
||||
j = j->next;
|
||||
}
|
||||
it = list;
|
||||
while (i && j) {
|
||||
if ((*compare)(i->data, j->data) <= 0) {
|
||||
it->next = i;
|
||||
i = i->next;
|
||||
}
|
||||
else {
|
||||
it->next = j;
|
||||
j = j->next;
|
||||
}
|
||||
it = it->next;
|
||||
}
|
||||
if (i) it->next = i;
|
||||
else it->next = j;
|
||||
return list;
|
||||
}
|
||||
|
||||
GSList *g_slist_find_custom(GSList *list, const void *data, compare_func func) {
|
||||
GSList *lp;
|
||||
for (lp = list; lp; lp = lp->next) {
|
||||
if ((*func)(lp->data, data) == 0) return lp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GSList *g_slist_remove(GSList *list, const void *data) {
|
||||
GSList *lp, *prev = NULL;
|
||||
for (lp = list; lp; lp = lp->next) {
|
||||
if (lp->data == data) {
|
||||
if (prev == NULL) {
|
||||
list = lp->next;
|
||||
}
|
||||
else {
|
||||
prev->next = lp->next;
|
||||
}
|
||||
free(lp);
|
||||
break;
|
||||
}
|
||||
prev = lp;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/* END of g_slist related functions */
|
||||
|
||||
|
||||
/* Hash table */
|
||||
|
||||
typedef struct _KeyValue {
|
||||
void *key;
|
||||
void *value;
|
||||
} KeyValue;
|
||||
|
||||
typedef struct _GHashTable {
|
||||
GHashFunc hash_func;
|
||||
GEqualFunc key_equal_func;
|
||||
GDestroyNotify key_destroy_func;
|
||||
GDestroyNotify value_destroy_func;
|
||||
uint32_t refcount;
|
||||
uint32_t size;
|
||||
uint32_t num_entries;
|
||||
GSList **buckets;
|
||||
} GHashTable;
|
||||
|
||||
void g_hash_table_destroy(GHashTable *hash_table) {
|
||||
if (hash_table == NULL) return;
|
||||
g_hash_table_remove_all(hash_table);
|
||||
g_hash_table_unref(hash_table);
|
||||
}
|
||||
|
||||
void* g_hash_table_find(GHashTable *hash_table, GHRFunc predicate, void* user_data) {
|
||||
if (hash_table == NULL) return NULL;
|
||||
int i;
|
||||
for (i = 0; i < hash_table->size; i++) {
|
||||
GSList *lp;
|
||||
for (lp = hash_table->buckets[i]; lp; lp = lp->next) {
|
||||
KeyValue *kv = (KeyValue*)(lp->data);
|
||||
if ((*predicate)(kv->key, kv->value, user_data)) return kv->value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void g_hash_table_foreach(GHashTable *hash_table, GHFunc func, void* user_data) {
|
||||
if (hash_table == NULL) return;
|
||||
int i;
|
||||
for (i = 0; i < hash_table->size; i++) {
|
||||
GSList *lp;
|
||||
for (lp = hash_table->buckets[i]; lp; lp = lp->next) {
|
||||
KeyValue *kv = (KeyValue*)(lp->data);
|
||||
(*func)(kv->key, kv->value, user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int g_hash_table_insert(GHashTable *hash_table, void* key, void* value) {
|
||||
if (hash_table == NULL) return 1;
|
||||
GSList *lp;
|
||||
uint32_t hash = (*hash_table->hash_func)(key);
|
||||
int bnum = hash % hash_table->size;
|
||||
for (lp = hash_table->buckets[bnum]; lp; lp = lp->next) {
|
||||
KeyValue *kv = (KeyValue*)(lp->data);
|
||||
int match = hash_table->key_equal_func ? (*hash_table->key_equal_func)(kv->key, key) : (kv->key == key);
|
||||
if (match) {
|
||||
/* replace */
|
||||
kv->value = value;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* new key */
|
||||
KeyValue *pair = (KeyValue*)g_malloc(sizeof(KeyValue));
|
||||
pair->key = key;
|
||||
pair->value = value;
|
||||
hash_table->buckets[bnum] = g_slist_prepend(hash_table->buckets[bnum], pair);
|
||||
hash_table->num_entries++;
|
||||
/* grow and rehash at num_entries / size == ??? */
|
||||
return 1;
|
||||
}
|
||||
|
||||
void* g_hash_table_lookup(GHashTable *hash_table, const void* key) {
|
||||
if (hash_table == NULL) return NULL;
|
||||
GSList *lp;
|
||||
uint32_t hash = (*hash_table->hash_func)(key);
|
||||
int bnum = hash % hash_table->size;
|
||||
for (lp = hash_table->buckets[bnum]; lp; lp = lp->next) {
|
||||
KeyValue *kv = (KeyValue*)(lp->data);
|
||||
int match = hash_table->key_equal_func ? (*hash_table->key_equal_func)(kv->key, key) : (kv->key == key);
|
||||
if (match) {
|
||||
return kv->value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GHashTable *g_hash_table_new(GHashFunc hash_func, GEqualFunc key_equal_func) {
|
||||
return g_hash_table_new_full(hash_func, key_equal_func, NULL, NULL);
|
||||
}
|
||||
|
||||
GHashTable *g_hash_table_new_full(GHashFunc hash_func, GEqualFunc key_equal_func,
|
||||
GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func) {
|
||||
GHashTable *ht = (GHashTable*)g_malloc(sizeof(GHashTable));
|
||||
ht->hash_func = hash_func ? hash_func : g_direct_hash;
|
||||
ht->key_equal_func = key_equal_func;
|
||||
ht->key_destroy_func = key_destroy_func;
|
||||
ht->value_destroy_func = value_destroy_func;
|
||||
g_hash_table_ref(ht);
|
||||
ht->size = 512;
|
||||
ht->num_entries = 0;
|
||||
ht->buckets = (GSList **)g_new0_(sizeof(GSList*), ht->size);
|
||||
return ht;
|
||||
}
|
||||
|
||||
void g_hash_table_remove_all(GHashTable *hash_table) {
|
||||
if (hash_table == NULL) return;
|
||||
int i;
|
||||
for (i = 0; i < hash_table->size; i++) {
|
||||
GSList *lp;
|
||||
for (lp = hash_table->buckets[i]; lp; lp = lp->next) {
|
||||
KeyValue *kv = (KeyValue*)lp->data;
|
||||
if (hash_table->key_destroy_func) (*hash_table->key_destroy_func)(kv->key);
|
||||
if (hash_table->value_destroy_func) (*hash_table->value_destroy_func)(kv->value);
|
||||
free(lp->data);
|
||||
}
|
||||
g_slist_free(hash_table->buckets[i]);
|
||||
hash_table->buckets[i] = NULL;
|
||||
}
|
||||
hash_table->num_entries = 0;
|
||||
}
|
||||
|
||||
int g_hash_table_remove(GHashTable *hash_table, const void* key) {
|
||||
GSList *lp, *prev = NULL;
|
||||
if (hash_table == NULL) return 0;
|
||||
uint32_t hash = (*hash_table->hash_func)(key);
|
||||
int bnum = hash % hash_table->size;
|
||||
for (lp = hash_table->buckets[bnum]; lp; lp = lp->next) {
|
||||
KeyValue *kv = (KeyValue*)(lp->data);
|
||||
int match = hash_table->key_equal_func ? (*hash_table->key_equal_func)(kv->key, key) : (kv->key == key);
|
||||
if (match) {
|
||||
if (hash_table->key_destroy_func) (*hash_table->key_destroy_func)(kv->key);
|
||||
if (hash_table->value_destroy_func) (*hash_table->value_destroy_func)(kv->value);
|
||||
free(kv);
|
||||
if (prev == NULL) {
|
||||
hash_table->buckets[bnum] = lp->next;
|
||||
}
|
||||
else {
|
||||
prev->next = lp->next;
|
||||
}
|
||||
free(lp);
|
||||
return 1;
|
||||
}
|
||||
prev = lp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void g_hash_table_unref(GHashTable *hash_table) {
|
||||
if (hash_table == NULL) return;
|
||||
hash_table->refcount--;
|
||||
if (hash_table->refcount == 0) {
|
||||
free(hash_table->buckets);
|
||||
free(hash_table);
|
||||
}
|
||||
}
|
||||
|
||||
GHashTable *g_hash_table_ref(GHashTable *hash_table) {
|
||||
if (hash_table == NULL) return NULL;
|
||||
hash_table->refcount++;
|
||||
return hash_table;
|
||||
}
|
||||
|
||||
uint32_t g_hash_table_size(GHashTable *hash_table) {
|
||||
return hash_table ? hash_table->num_entries : 0;
|
||||
}
|
||||
|
||||
|
||||
/* END of g_hash_table related functions */
|
||||
|
||||
/* general g_XXX substitutes */
|
||||
|
||||
void *g_malloc(size_t size) {
|
||||
if (size == 0) return NULL;
|
||||
void *res = malloc(size);
|
||||
if (res == NULL) exit(1);
|
||||
return res;
|
||||
}
|
||||
|
||||
void *g_malloc0(size_t size) {
|
||||
if (size == 0) return NULL;
|
||||
void *res = calloc(size, 1);
|
||||
if (res == NULL) exit(1);
|
||||
return res;
|
||||
}
|
||||
|
||||
void *g_try_malloc0(size_t size) {
|
||||
if (size == 0) return NULL;
|
||||
void *res = calloc(size, 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
void *g_realloc(void *ptr, size_t size) {
|
||||
if (size == 0) {
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
void *res = realloc(ptr, size);
|
||||
if (res == NULL) exit(1);
|
||||
return res;
|
||||
}
|
||||
|
||||
char *g_strdup(const char *str) {
|
||||
return str ? strdup(str) : NULL;
|
||||
}
|
||||
|
||||
char *g_strdup_printf(const char *format, ...) {
|
||||
va_list ap;
|
||||
char *res;
|
||||
va_start(ap, format);
|
||||
res = g_strdup_vprintf(format, ap);
|
||||
va_end(ap);
|
||||
return res;
|
||||
}
|
||||
|
||||
char *g_strdup_vprintf(const char *format, va_list ap) {
|
||||
char *str_res = NULL;
|
||||
vasprintf(&str_res, format, ap);
|
||||
return str_res;
|
||||
}
|
||||
|
||||
char *g_strndup(const char *str, size_t n) {
|
||||
/* try to mimic glib's g_strndup */
|
||||
char *res = calloc(n + 1, 1);
|
||||
strncpy(res, str, n);
|
||||
return res;
|
||||
}
|
||||
|
||||
void g_strfreev(char **str_array) {
|
||||
char **p = str_array;
|
||||
if (p) {
|
||||
while (*p) {
|
||||
free(*p++);
|
||||
}
|
||||
}
|
||||
free(str_array);
|
||||
}
|
||||
|
||||
void *g_memdup(const void *mem, size_t byte_size) {
|
||||
if (mem) {
|
||||
void *res = g_malloc(byte_size);
|
||||
memcpy(res, mem, byte_size);
|
||||
return res;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *g_new_(size_t sz, size_t n_structs) {
|
||||
size_t need = sz * n_structs;
|
||||
if ((need / sz) != n_structs) return NULL;
|
||||
return g_malloc(need);
|
||||
}
|
||||
|
||||
void *g_new0_(size_t sz, size_t n_structs) {
|
||||
size_t need = sz * n_structs;
|
||||
if ((need / sz) != n_structs) return NULL;
|
||||
return g_malloc0(need);
|
||||
}
|
||||
|
||||
void *g_renew_(size_t sz, void *mem, size_t n_structs) {
|
||||
size_t need = sz * n_structs;
|
||||
if ((need / sz) != n_structs) return NULL;
|
||||
return g_realloc(mem, need);
|
||||
}
|
||||
|
||||
char *g_strconcat (const char *string1, ...) {
|
||||
va_list ap;
|
||||
char *res;
|
||||
size_t sz = strlen(string1);
|
||||
va_start(ap, string1);
|
||||
while (1) {
|
||||
char *arg = va_arg(ap, char*);
|
||||
if (arg == NULL) break;
|
||||
sz += strlen(arg);
|
||||
}
|
||||
va_end(ap);
|
||||
res = g_malloc(sz + 1);
|
||||
strcpy(res, string1);
|
||||
va_start(ap, string1);
|
||||
while (1) {
|
||||
char *arg = va_arg(ap, char*);
|
||||
if (arg == NULL) break;
|
||||
strcat(res, arg);
|
||||
}
|
||||
va_end(ap);
|
||||
return res;
|
||||
}
|
||||
|
||||
char **g_strsplit(const char *string, const char *delimiter, int max_tokens) {
|
||||
char **res;
|
||||
if (string == NULL || *string == 0) {
|
||||
res = (char**)g_malloc(sizeof(char*));
|
||||
*res = NULL;
|
||||
}
|
||||
else {
|
||||
uint32_t ntokens, i, max = (uint32_t) max_tokens;
|
||||
if (max == 0) max--;
|
||||
int dlen = strlen(delimiter);
|
||||
const char *p = string, *b;
|
||||
for (ntokens = 1; ntokens < max; ntokens++) {
|
||||
p = strstr(p, delimiter);
|
||||
if (p == NULL) break;
|
||||
p += dlen;
|
||||
}
|
||||
res = (char**)g_new_(sizeof(char*), ntokens + 1);
|
||||
p = string;
|
||||
for (b = p, i = 0; i < ntokens; b = p, i++) {
|
||||
int len;
|
||||
if (i == (ntokens - 1)) {
|
||||
/* last piece special handling */
|
||||
res[i] = strdup(b);
|
||||
}
|
||||
else {
|
||||
p = strstr(b, delimiter);
|
||||
len = p - b;
|
||||
res[i] = (char*)g_malloc(len + 1);
|
||||
memcpy(res[i], b, len);
|
||||
res[i][len] = 0;
|
||||
p += dlen;
|
||||
}
|
||||
}
|
||||
res[ntokens] = NULL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
char *g_win32_error_message(int error) {
|
||||
char *msg;
|
||||
char *winMsg = NULL;
|
||||
if (error == 0) {
|
||||
return (char*)g_malloc0(1);
|
||||
}
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&msg, 0, NULL);
|
||||
|
||||
/* give the caller something they can just free */
|
||||
msg = strdup(winMsg);
|
||||
/* Free the allocated message. */
|
||||
HeapFree(GetProcessHeap(), 0, winMsg);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
#endif
|
@ -2185,15 +2185,12 @@ symbols = (
|
||||
'object_property_find',
|
||||
'object_property_get',
|
||||
'object_property_get_bool',
|
||||
'object_property_get_enum',
|
||||
'object_property_get_int',
|
||||
'object_property_get_link',
|
||||
'object_property_get_qobject',
|
||||
'object_property_get_str',
|
||||
'object_property_get_type',
|
||||
'object_property_get_uint16List',
|
||||
'object_property_is_child',
|
||||
'object_property_print',
|
||||
'object_property_set',
|
||||
'object_property_set_description',
|
||||
'object_property_set_link',
|
||||
@ -2433,7 +2430,6 @@ symbols = (
|
||||
'qemu_get_cpu',
|
||||
'qemu_get_guest_memory_mapping',
|
||||
'qemu_get_guest_simple_memory_mapping',
|
||||
'qemu_get_local_state_pathname',
|
||||
'qemu_get_ram_block',
|
||||
'qemu_get_ram_block_host_ptr',
|
||||
'qemu_get_ram_fd',
|
||||
@ -2722,13 +2718,6 @@ symbols = (
|
||||
'string_input_get_visitor',
|
||||
'string_input_visitor_cleanup',
|
||||
'string_input_visitor_new',
|
||||
'string_output_append',
|
||||
'string_output_append_range',
|
||||
'string_output_get_string',
|
||||
'string_output_get_visitor',
|
||||
'string_output_set',
|
||||
'string_output_visitor_cleanup',
|
||||
'string_output_visitor_new',
|
||||
'stristart',
|
||||
'strongarm_cp_reginfo',
|
||||
'strpadcpy',
|
||||
|
@ -176,7 +176,7 @@ static int device_set_realized(struct uc_struct *uc, Object *obj, bool value, Er
|
||||
object_property_add_child(container_get(qdev_get_machine(),
|
||||
"/unattached"),
|
||||
name, obj, &error_abort);
|
||||
g_free(name);
|
||||
free(name);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -305,7 +305,7 @@ static void qbus_finalize(struct uc_struct *uc, Object *obj, void *opaque)
|
||||
{
|
||||
BusState *bus = BUS(uc, obj);
|
||||
|
||||
g_free((char *)bus->name);
|
||||
free((char *)bus->name);
|
||||
}
|
||||
|
||||
static const TypeInfo bus_info = {
|
||||
|
@ -745,7 +745,7 @@ static void prom_init(hwaddr addr, const char *bios_name)
|
||||
if (ret < 0 || ret > PROM_SIZE_MAX) {
|
||||
ret = load_image_targphys(filename, addr, PROM_SIZE_MAX);
|
||||
}
|
||||
g_free(filename);
|
||||
free(filename);
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
|
@ -1,201 +0,0 @@
|
||||
/*
|
||||
* GLIB Compatibility Functions
|
||||
*
|
||||
* Copyright IBM, Corp. 2013
|
||||
*
|
||||
* Authors:
|
||||
* Anthony Liguori <aliguori@us.ibm.com>
|
||||
* Michael Tokarev <mjt@tls.msk.ru>
|
||||
* Paolo Bonzini <pbonzini@redhat.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef QEMU_GLIB_COMPAT_H
|
||||
#define QEMU_GLIB_COMPAT_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/* GLIB version compatibility flags */
|
||||
#if !GLIB_CHECK_VERSION(2, 26, 0)
|
||||
#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT(1000000))
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2, 14, 0)
|
||||
static inline guint g_timeout_add_seconds(guint interval, GSourceFunc function,
|
||||
gpointer data)
|
||||
{
|
||||
return g_timeout_add(interval * 1000, function, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2, 28, 0)
|
||||
static inline gint64 g_get_monotonic_time(void)
|
||||
{
|
||||
/* g_get_monotonic_time() is best-effort so we can use the wall clock as a
|
||||
* fallback.
|
||||
*/
|
||||
|
||||
GTimeVal time;
|
||||
g_get_current_time(&time);
|
||||
|
||||
return time.tv_sec * G_TIME_SPAN_SECOND + time.tv_usec;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2, 16, 0)
|
||||
static inline int g_strcmp0(const char *str1, const char *str2)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!str1) {
|
||||
result = -(str1 != str2);
|
||||
} else if (!str2) {
|
||||
result = (str1 != str2);
|
||||
} else {
|
||||
result = strcmp(str1, str2);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* g_poll has a problem on Windows when using
|
||||
* timeouts < 10ms, so use wrapper.
|
||||
*/
|
||||
#define g_poll(fds, nfds, timeout) g_poll_fixed(fds, nfds, timeout)
|
||||
gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeout);
|
||||
#elif !GLIB_CHECK_VERSION(2, 20, 0)
|
||||
/*
|
||||
* Glib before 2.20.0 doesn't implement g_poll, so wrap it to compile properly
|
||||
* on older systems.
|
||||
*/
|
||||
static inline gint g_poll(GPollFD *fds, guint nfds, gint timeout)
|
||||
{
|
||||
GMainContext *ctx = g_main_context_default();
|
||||
return g_main_context_get_poll_func(ctx)(fds, nfds, timeout);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2, 31, 0)
|
||||
/* before glib-2.31, GMutex and GCond was dynamic-only (there was a separate
|
||||
* GStaticMutex, but it didn't work with condition variables).
|
||||
*
|
||||
* Our implementation uses GOnce to fake a static implementation that does
|
||||
* not require separate initialization.
|
||||
* We need to rename the types to avoid passing our CompatGMutex/CompatGCond
|
||||
* by mistake to a function that expects GMutex/GCond. However, for ease
|
||||
* of use we keep the GLib function names. GLib uses macros for the
|
||||
* implementation, we use inline functions instead and undefine the macros.
|
||||
*/
|
||||
|
||||
typedef struct CompatGMutex {
|
||||
GOnce once;
|
||||
} CompatGMutex;
|
||||
|
||||
typedef struct CompatGCond {
|
||||
GOnce once;
|
||||
} CompatGCond;
|
||||
|
||||
static inline gpointer do_g_mutex_new(gpointer unused)
|
||||
{
|
||||
return (gpointer) g_mutex_new();
|
||||
}
|
||||
|
||||
static inline void g_mutex_init(CompatGMutex *mutex)
|
||||
{
|
||||
mutex->once = (GOnce) G_ONCE_INIT;
|
||||
}
|
||||
|
||||
static inline void g_mutex_clear(CompatGMutex *mutex)
|
||||
{
|
||||
assert(mutex->once.status != G_ONCE_STATUS_PROGRESS);
|
||||
if (mutex->once.retval) {
|
||||
g_mutex_free((GMutex *) mutex->once.retval);
|
||||
}
|
||||
mutex->once = (GOnce) G_ONCE_INIT;
|
||||
}
|
||||
|
||||
static inline void (g_mutex_lock)(CompatGMutex *mutex)
|
||||
{
|
||||
g_once(&mutex->once, do_g_mutex_new, NULL);
|
||||
g_mutex_lock((GMutex *) mutex->once.retval);
|
||||
}
|
||||
#undef g_mutex_lock
|
||||
|
||||
static inline gboolean (g_mutex_trylock)(CompatGMutex *mutex)
|
||||
{
|
||||
g_once(&mutex->once, do_g_mutex_new, NULL);
|
||||
return g_mutex_trylock((GMutex *) mutex->once.retval);
|
||||
}
|
||||
#undef g_mutex_trylock
|
||||
|
||||
|
||||
static inline void (g_mutex_unlock)(CompatGMutex *mutex)
|
||||
{
|
||||
g_mutex_unlock((GMutex *) mutex->once.retval);
|
||||
}
|
||||
#undef g_mutex_unlock
|
||||
|
||||
static inline gpointer do_g_cond_new(gpointer unused)
|
||||
{
|
||||
return (gpointer) g_cond_new();
|
||||
}
|
||||
|
||||
static inline void g_cond_init(CompatGCond *cond)
|
||||
{
|
||||
cond->once = (GOnce) G_ONCE_INIT;
|
||||
}
|
||||
|
||||
static inline void g_cond_clear(CompatGCond *cond)
|
||||
{
|
||||
assert(cond->once.status != G_ONCE_STATUS_PROGRESS);
|
||||
if (cond->once.retval) {
|
||||
g_cond_free((GCond *) cond->once.retval);
|
||||
}
|
||||
cond->once = (GOnce) G_ONCE_INIT;
|
||||
}
|
||||
|
||||
static inline void (g_cond_wait)(CompatGCond *cond, CompatGMutex *mutex)
|
||||
{
|
||||
assert(mutex->once.status != G_ONCE_STATUS_PROGRESS);
|
||||
g_once(&cond->once, do_g_cond_new, NULL);
|
||||
g_cond_wait((GCond *) cond->once.retval, (GMutex *) mutex->once.retval);
|
||||
}
|
||||
#undef g_cond_wait
|
||||
|
||||
static inline void (g_cond_broadcast)(CompatGCond *cond)
|
||||
{
|
||||
g_once(&cond->once, do_g_cond_new, NULL);
|
||||
g_cond_broadcast((GCond *) cond->once.retval);
|
||||
}
|
||||
#undef g_cond_broadcast
|
||||
|
||||
static inline void (g_cond_signal)(CompatGCond *cond)
|
||||
{
|
||||
g_once(&cond->once, do_g_cond_new, NULL);
|
||||
g_cond_signal((GCond *) cond->once.retval);
|
||||
}
|
||||
#undef g_cond_signal
|
||||
|
||||
|
||||
/* before 2.31 there was no g_thread_new() */
|
||||
static inline GThread *g_thread_new(const char *name,
|
||||
GThreadFunc func, gpointer data)
|
||||
{
|
||||
GThread *thread = g_thread_create(func, data, TRUE, NULL);
|
||||
if (!thread) {
|
||||
g_error("creating thread");
|
||||
}
|
||||
return thread;
|
||||
}
|
||||
#else
|
||||
#define CompatGMutex GMutex
|
||||
#define CompatGCond GCond
|
||||
#endif /* glib 2.31 */
|
||||
|
||||
#endif
|
135
qemu/include/glib_compat.h
Normal file
135
qemu/include/glib_compat.h
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
glib_compat.h replacement functionality for glib code used in qemu
|
||||
Copyright (C) 2016 Chris Eagle cseagle at gmail dot com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIB_COMPAT_H
|
||||
#define __GLIB_COMPAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 1
|
||||
#endif
|
||||
|
||||
#define g_assert(expr) assert(expr)
|
||||
#define g_assert_not_reached() assert(0)
|
||||
|
||||
/* typedefs for glib related types that may still be referenced */
|
||||
typedef void* gpointer;
|
||||
typedef const void *gconstpointer;
|
||||
typedef uint32_t guint;
|
||||
typedef char gchar;
|
||||
typedef int gboolean;
|
||||
|
||||
typedef int (*GCompareFunc)(const void *v1, const void *v2);
|
||||
typedef void (*GDestroyNotify)(void *data);
|
||||
|
||||
uint32_t g_direct_hash(const void *v);
|
||||
int g_direct_equal(const void *v1, const void *v2);
|
||||
uint32_t g_str_hash(const void *v);
|
||||
int g_str_equal(const void *v1, const void *v2);
|
||||
uint32_t g_int_hash(const void *v);
|
||||
int g_int_equal(const void *v1, const void *v2);
|
||||
|
||||
typedef struct _GList {
|
||||
void *data;
|
||||
struct _GList *next;
|
||||
struct _GList *prev;
|
||||
} GList;
|
||||
|
||||
typedef void (*list_func)(void* data, void* user_data);
|
||||
typedef int (*compare_func)(const void *d1, const void *d2);
|
||||
|
||||
GList *g_list_first(GList *list);
|
||||
void g_list_foreach(GList *list, list_func func, void* user_data);
|
||||
void g_list_free(GList *list);
|
||||
GList *g_list_insert_sorted(GList *list, void* data, compare_func compare);
|
||||
#define g_list_next(list) (list->next)
|
||||
GList *g_list_prepend(GList *list, void* data);
|
||||
GList *g_list_remove_link(GList *list, GList *llink);
|
||||
GList *g_list_sort(GList *list, compare_func compare);
|
||||
|
||||
typedef struct _GSList {
|
||||
void *data;
|
||||
struct _GSList *next;
|
||||
} GSList;
|
||||
|
||||
GSList *g_slist_append(GSList *list, void* data);
|
||||
void g_slist_foreach(GSList *list, list_func func, void* user_data);
|
||||
void g_slist_free(GSList *list);
|
||||
void g_slist_free_full(GSList *list, GDestroyNotify free_func);
|
||||
GSList *g_slist_prepend(GSList *list, void* data);
|
||||
GSList *g_slist_sort(GSList *list, compare_func compare);
|
||||
GSList *g_slist_find_custom(GSList *list, const void *data, compare_func func);
|
||||
GSList *g_slist_remove(GSList *list, const void *data);
|
||||
|
||||
typedef uint32_t (*GHashFunc)(const void *key);
|
||||
typedef int (*GEqualFunc)(const void *a, const void *b);
|
||||
typedef void (*GHFunc)(void* key, void* value, void* user_data);
|
||||
typedef int (*GHRFunc)(void* key, void* value, void* user_data);
|
||||
|
||||
typedef struct _GHashTable GHashTable;
|
||||
|
||||
void g_hash_table_destroy(GHashTable *hash_table);
|
||||
void* g_hash_table_find(GHashTable *hash_table, GHRFunc predicate, void* user_data);
|
||||
void g_hash_table_foreach(GHashTable *hash_table, GHFunc func, void* user_data);
|
||||
int g_hash_table_insert(GHashTable *hash_table, void* key, void* value);
|
||||
void* g_hash_table_lookup(GHashTable *hash_table, const void* key);
|
||||
GHashTable *g_hash_table_new(GHashFunc hash_func, GEqualFunc key_equal_func);
|
||||
GHashTable *g_hash_table_new_full(GHashFunc hash_func, GEqualFunc key_equal_func,
|
||||
GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
|
||||
void g_hash_table_remove_all(GHashTable *hash_table);
|
||||
int g_hash_table_remove(GHashTable *hash_table, const void* key);
|
||||
void g_hash_table_unref(GHashTable *hash_table);
|
||||
GHashTable *g_hash_table_ref(GHashTable *hash_table);
|
||||
uint32_t g_hash_table_size(GHashTable *hash_table);
|
||||
|
||||
/* replacement for g_malloc dependency */
|
||||
void *g_malloc(size_t size);
|
||||
void *g_malloc0(size_t size);
|
||||
void *g_try_malloc0(size_t size);
|
||||
void *g_realloc(void *ptr, size_t size);
|
||||
char *g_strdup(const char *str);
|
||||
char *g_strdup_printf(const char *format, ...);
|
||||
char *g_strdup_vprintf(const char *format, va_list ap);
|
||||
char *g_strndup(const char *str, size_t n);
|
||||
void g_strfreev(char **v);
|
||||
void *g_memdup(const void *mem, size_t byte_size);
|
||||
void *g_new_(size_t sz, size_t n_structs);
|
||||
void *g_new0_(size_t sz, size_t n_structs);
|
||||
void *g_renew_(size_t sz, void *mem, size_t n_structs);
|
||||
char *g_strconcat(const char *string1, ...);
|
||||
|
||||
char **g_strsplit(const char *string, const char *delimiter, int max_tokens);
|
||||
|
||||
#define g_new(struct_type, n_structs) ((struct_type*)g_new_(sizeof(struct_type), n_structs))
|
||||
#define g_new0(struct_type, n_structs) ((struct_type*)g_new0_(sizeof(struct_type), n_structs))
|
||||
#define g_renew(struct_type, mem, n_structs) ((struct_type*)g_renew_(sizeof(struct_type), mem, n_structs))
|
||||
|
||||
#ifdef _WIN32
|
||||
char *g_win32_error_message(int error);
|
||||
#endif
|
||||
|
||||
#endif
|
@ -57,7 +57,7 @@ struct arm_boot_info {
|
||||
* sets get_dtb. This will only be used if no dtb file is provided
|
||||
* by the user. On success, sets *size to the length of the created
|
||||
* dtb, and returns a pointer to it. (The caller must free this memory
|
||||
* with g_free() when it has finished with it.) On failure, returns NULL.
|
||||
* with free() when it has finished with it.) On failure, returns NULL.
|
||||
*/
|
||||
void *(*get_dtb)(const struct arm_boot_info *info, int *size);
|
||||
/* if a board needs to be able to modify a device tree provided by
|
||||
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* String printing Visitor
|
||||
*
|
||||
* Copyright Red Hat, Inc. 2012
|
||||
*
|
||||
* Author: Paolo Bonzini <pbonzini@redhat.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING.LIB file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef STRING_OUTPUT_VISITOR_H
|
||||
#define STRING_OUTPUT_VISITOR_H
|
||||
|
||||
#include "qapi/visitor.h"
|
||||
|
||||
typedef struct StringOutputVisitor StringOutputVisitor;
|
||||
|
||||
StringOutputVisitor *string_output_visitor_new(bool human);
|
||||
void string_output_visitor_cleanup(StringOutputVisitor *v);
|
||||
|
||||
char *string_output_get_string(StringOutputVisitor *v);
|
||||
Visitor *string_output_get_visitor(StringOutputVisitor *v);
|
||||
|
||||
#endif
|
@ -41,7 +41,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include "glib-compat.h"
|
||||
#include "glib_compat.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "sysemu/os-win32.h"
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef BITMAP_H
|
||||
#define BITMAP_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "glib_compat.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -209,19 +209,8 @@ const char *qemu_get_version(void);
|
||||
void fips_set_state(bool requested);
|
||||
bool fips_get_state(void);
|
||||
|
||||
/* Return a dynamically allocated pathname denoting a file or directory that is
|
||||
* appropriate for storing local state.
|
||||
*
|
||||
* @relative_pathname need not start with a directory separator; one will be
|
||||
* added automatically.
|
||||
*
|
||||
* The caller is responsible for releasing the value returned with g_free()
|
||||
* after use.
|
||||
*/
|
||||
char *qemu_get_local_state_pathname(const char *relative_pathname);
|
||||
|
||||
/* Get the saved exec dir.
|
||||
* Caller needs to release the returned string by g_free() */
|
||||
* Caller needs to release the returned string by free() */
|
||||
char *qemu_get_exec_dir(void);
|
||||
|
||||
/**
|
||||
|
@ -119,7 +119,7 @@ static inline GList *g_list_insert_sorted_merged(GList *list,
|
||||
return list;
|
||||
}
|
||||
|
||||
static inline gint range_compare(gconstpointer a, gconstpointer b)
|
||||
static inline int32_t range_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
Range *ra = (Range *)a, *rb = (Range *)b;
|
||||
if (ra->begin == rb->begin && ra->end == rb->end) {
|
||||
|
@ -574,19 +574,6 @@ void timer_put(QEMUFile *f, QEMUTimer *ts);
|
||||
*/
|
||||
int qemu_timeout_ns_to_ms(int64_t ns);
|
||||
|
||||
/**
|
||||
* qemu_poll_ns:
|
||||
* @fds: Array of file descriptors
|
||||
* @nfds: number of file descriptors
|
||||
* @timeout: timeout in nanoseconds
|
||||
*
|
||||
* Perform a poll like g_poll but with a timeout in nanoseconds.
|
||||
* See g_poll documentation for further details.
|
||||
*
|
||||
* Returns: number of fds ready
|
||||
*/
|
||||
int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout);
|
||||
|
||||
/**
|
||||
* qemu_soonest_timeout:
|
||||
* @timeout1: first timeout in nanoseconds (or -1 for infinite)
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef QEMU_OBJECT_H
|
||||
#define QEMU_OBJECT_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "glib_compat.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "qemu/queue.h"
|
||||
@ -932,34 +932,6 @@ void object_property_set_int(struct uc_struct *uc, Object *obj, int64_t value,
|
||||
int64_t object_property_get_int(struct uc_struct *uc, Object *obj, const char *name,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* object_property_get_enum:
|
||||
* @obj: the object
|
||||
* @name: the name of the property
|
||||
* @strings: strings corresponding to enums
|
||||
* @errp: returns an error if this function fails
|
||||
*
|
||||
* Returns: the value of the property, converted to an integer, or
|
||||
* undefined if an error occurs (including when the property value is not
|
||||
* an enum).
|
||||
*/
|
||||
int object_property_get_enum(struct uc_struct *uc, Object *obj, const char *name,
|
||||
const char *strings[], Error **errp);
|
||||
|
||||
/**
|
||||
* object_property_get_uint16List:
|
||||
* @obj: the object
|
||||
* @name: the name of the property
|
||||
* @list: the returned int list
|
||||
* @errp: returns an error if this function fails
|
||||
*
|
||||
* Returns: the value of the property, converted to integers, or
|
||||
* undefined if an error occurs (including when the property value is not
|
||||
* an list of integers).
|
||||
*/
|
||||
void object_property_get_uint16List(struct uc_struct *uc, Object *obj, const char *name,
|
||||
uint16List **list, Error **errp);
|
||||
|
||||
/**
|
||||
* object_property_set:
|
||||
* @obj: the object
|
||||
@ -986,19 +958,6 @@ void object_property_set(struct uc_struct *uc, Object *obj, struct Visitor *v, c
|
||||
void object_property_parse(struct uc_struct *uc, Object *obj, const char *string,
|
||||
const char *name, Error **errp);
|
||||
|
||||
/**
|
||||
* object_property_print:
|
||||
* @obj: the object
|
||||
* @name: the name of the property
|
||||
* @human: if true, print for human consumption
|
||||
* @errp: returns an error if this function fails
|
||||
*
|
||||
* Returns a string representation of the value of the property. The
|
||||
* caller shall free the string.
|
||||
*/
|
||||
char *object_property_print(struct uc_struct *uc, Object *obj, const char *name, bool human,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* object_property_get_type:
|
||||
* @obj: the object
|
||||
@ -1166,7 +1125,7 @@ void object_property_add_link(Object *obj, const char *name,
|
||||
* @obj: the object to add a property to
|
||||
* @name: the name of the property
|
||||
* @get: the getter or NULL if the property is write-only. This function must
|
||||
* return a string to be freed by g_free().
|
||||
* return a string to be freed by free().
|
||||
* @set: the setter or NULL if the property is read-only
|
||||
* @errp: if an error occurs, a pointer to an area to store the error
|
||||
*
|
||||
|
11
qemu/m68k.h
11
qemu/m68k.h
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_m68k
|
||||
#define object_property_get object_property_get_m68k
|
||||
#define object_property_get_bool object_property_get_bool_m68k
|
||||
#define object_property_get_enum object_property_get_enum_m68k
|
||||
#define object_property_get_int object_property_get_int_m68k
|
||||
#define object_property_get_link object_property_get_link_m68k
|
||||
#define object_property_get_qobject object_property_get_qobject_m68k
|
||||
#define object_property_get_str object_property_get_str_m68k
|
||||
#define object_property_get_type object_property_get_type_m68k
|
||||
#define object_property_get_uint16List object_property_get_uint16List_m68k
|
||||
#define object_property_is_child object_property_is_child_m68k
|
||||
#define object_property_print object_property_print_m68k
|
||||
#define object_property_set object_property_set_m68k
|
||||
#define object_property_set_description object_property_set_description_m68k
|
||||
#define object_property_set_link object_property_set_link_m68k
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_m68k
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_m68k
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_m68k
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_m68k
|
||||
#define qemu_get_ram_block qemu_get_ram_block_m68k
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_m68k
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_m68k
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_m68k
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_m68k
|
||||
#define string_input_visitor_new string_input_visitor_new_m68k
|
||||
#define string_output_append string_output_append_m68k
|
||||
#define string_output_append_range string_output_append_range_m68k
|
||||
#define string_output_get_string string_output_get_string_m68k
|
||||
#define string_output_get_visitor string_output_get_visitor_m68k
|
||||
#define string_output_set string_output_set_m68k
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_m68k
|
||||
#define string_output_visitor_new string_output_visitor_new_m68k
|
||||
#define stristart stristart_m68k
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_m68k
|
||||
#define strpadcpy strpadcpy_m68k
|
||||
|
@ -91,9 +91,9 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
|
||||
mr->destructor(mr);
|
||||
obj = OBJECT(mr);
|
||||
obj->ref = 1;
|
||||
obj->free = g_free;
|
||||
g_free(mr->ioeventfds);
|
||||
g_free((char *)mr->name);
|
||||
obj->free = free;
|
||||
free(mr->ioeventfds);
|
||||
free((char *)mr->name);
|
||||
mr->name = NULL;
|
||||
object_property_del_child(mr->uc, qdev_get_machine(mr->uc), obj, &error_abort);
|
||||
break;
|
||||
@ -114,8 +114,8 @@ int memory_free(struct uc_struct *uc)
|
||||
mr->destructor(mr);
|
||||
obj = OBJECT(mr);
|
||||
obj->ref = 1;
|
||||
obj->free = g_free;
|
||||
g_free(mr->ioeventfds);
|
||||
obj->free = free;
|
||||
free(mr->ioeventfds);
|
||||
object_property_del_child(mr->uc, qdev_get_machine(mr->uc), obj, &error_abort);
|
||||
}
|
||||
|
||||
@ -375,8 +375,8 @@ static void flatview_destroy(FlatView *view)
|
||||
for (i = 0; i < view->nr; i++) {
|
||||
memory_region_unref(view->ranges[i].mr);
|
||||
}
|
||||
g_free(view->ranges);
|
||||
g_free(view);
|
||||
free(view->ranges);
|
||||
free(view);
|
||||
}
|
||||
|
||||
static void flatview_ref(FlatView *view)
|
||||
@ -767,7 +767,7 @@ static void address_space_update_ioeventfds(AddressSpace *as)
|
||||
address_space_add_del_ioeventfds(as, ioeventfds, ioeventfd_nb,
|
||||
as->ioeventfds, as->ioeventfd_nb);
|
||||
|
||||
g_free(as->ioeventfds);
|
||||
free(as->ioeventfds);
|
||||
as->ioeventfds = ioeventfds;
|
||||
as->ioeventfd_nb = ioeventfd_nb;
|
||||
flatview_unref(view);
|
||||
@ -973,8 +973,8 @@ void memory_region_init(struct uc_struct *uc, MemoryRegion *mr,
|
||||
char *name_array = g_strdup_printf("%s[*]", escaped_name);
|
||||
object_property_add_child(owner, name_array, OBJECT(mr), &error_abort);
|
||||
object_unref(uc, OBJECT(mr));
|
||||
g_free(name_array);
|
||||
g_free(escaped_name);
|
||||
free(name_array);
|
||||
free(escaped_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -998,7 +998,7 @@ static void memory_region_get_container(struct uc_struct *uc, Object *obj, Visit
|
||||
}
|
||||
visit_type_str(v, &path, name, errp);
|
||||
if (mr->container) {
|
||||
g_free(path);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1283,8 +1283,8 @@ static void memory_region_finalize(struct uc_struct *uc, Object *obj, void *opaq
|
||||
// assert(memory_region_transaction_depth == 0);
|
||||
mr->destructor(mr);
|
||||
memory_region_clear_coalescing(mr);
|
||||
g_free((char *)mr->name);
|
||||
g_free(mr->ioeventfds);
|
||||
free((char *)mr->name);
|
||||
free(mr->ioeventfds);
|
||||
}
|
||||
|
||||
void memory_region_ref(MemoryRegion *mr)
|
||||
@ -1482,7 +1482,7 @@ void memory_region_clear_coalescing(MemoryRegion *mr)
|
||||
while (!QTAILQ_EMPTY(&mr->coalesced)) {
|
||||
cmr = QTAILQ_FIRST(&mr->coalesced);
|
||||
QTAILQ_REMOVE(&mr->coalesced, cmr, link);
|
||||
g_free(cmr);
|
||||
free(cmr);
|
||||
updated = true;
|
||||
}
|
||||
|
||||
@ -1883,8 +1883,8 @@ void address_space_destroy(AddressSpace *as)
|
||||
}
|
||||
|
||||
flatview_unref(as->current_map);
|
||||
g_free(as->name);
|
||||
g_free(as->ioeventfds);
|
||||
free(as->name);
|
||||
free(as->ioeventfds);
|
||||
}
|
||||
|
||||
bool io_mem_read(MemoryRegion *mr, hwaddr addr, uint64_t *pval, unsigned size)
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
/* Modified for Unicorn Engine by Nguyen Anh Quynh, 2015 */
|
||||
|
||||
#include <glib.h>
|
||||
#include "glib_compat.h"
|
||||
|
||||
#include "cpu.h"
|
||||
#include "exec/cpu-all.h"
|
||||
@ -161,7 +161,7 @@ void memory_mapping_list_free(MemoryMappingList *list)
|
||||
|
||||
QTAILQ_FOREACH_SAFE(p, &list->head, next, q) {
|
||||
QTAILQ_REMOVE(&list->head, p, next);
|
||||
g_free(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
list->num = 0;
|
||||
@ -181,7 +181,7 @@ void guest_phys_blocks_free(GuestPhysBlockList *list)
|
||||
|
||||
QTAILQ_FOREACH_SAFE(p, &list->head, next, q) {
|
||||
QTAILQ_REMOVE(&list->head, p, next);
|
||||
g_free(p);
|
||||
free(p);
|
||||
}
|
||||
list->num = 0;
|
||||
}
|
||||
|
11
qemu/mips.h
11
qemu/mips.h
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_mips
|
||||
#define object_property_get object_property_get_mips
|
||||
#define object_property_get_bool object_property_get_bool_mips
|
||||
#define object_property_get_enum object_property_get_enum_mips
|
||||
#define object_property_get_int object_property_get_int_mips
|
||||
#define object_property_get_link object_property_get_link_mips
|
||||
#define object_property_get_qobject object_property_get_qobject_mips
|
||||
#define object_property_get_str object_property_get_str_mips
|
||||
#define object_property_get_type object_property_get_type_mips
|
||||
#define object_property_get_uint16List object_property_get_uint16List_mips
|
||||
#define object_property_is_child object_property_is_child_mips
|
||||
#define object_property_print object_property_print_mips
|
||||
#define object_property_set object_property_set_mips
|
||||
#define object_property_set_description object_property_set_description_mips
|
||||
#define object_property_set_link object_property_set_link_mips
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_mips
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_mips
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_mips
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_mips
|
||||
#define qemu_get_ram_block qemu_get_ram_block_mips
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_mips
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_mips
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_mips
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_mips
|
||||
#define string_input_visitor_new string_input_visitor_new_mips
|
||||
#define string_output_append string_output_append_mips
|
||||
#define string_output_append_range string_output_append_range_mips
|
||||
#define string_output_get_string string_output_get_string_mips
|
||||
#define string_output_get_visitor string_output_get_visitor_mips
|
||||
#define string_output_set string_output_set_mips
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_mips
|
||||
#define string_output_visitor_new string_output_visitor_new_mips
|
||||
#define stristart stristart_mips
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_mips
|
||||
#define strpadcpy strpadcpy_mips
|
||||
|
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_mips64
|
||||
#define object_property_get object_property_get_mips64
|
||||
#define object_property_get_bool object_property_get_bool_mips64
|
||||
#define object_property_get_enum object_property_get_enum_mips64
|
||||
#define object_property_get_int object_property_get_int_mips64
|
||||
#define object_property_get_link object_property_get_link_mips64
|
||||
#define object_property_get_qobject object_property_get_qobject_mips64
|
||||
#define object_property_get_str object_property_get_str_mips64
|
||||
#define object_property_get_type object_property_get_type_mips64
|
||||
#define object_property_get_uint16List object_property_get_uint16List_mips64
|
||||
#define object_property_is_child object_property_is_child_mips64
|
||||
#define object_property_print object_property_print_mips64
|
||||
#define object_property_set object_property_set_mips64
|
||||
#define object_property_set_description object_property_set_description_mips64
|
||||
#define object_property_set_link object_property_set_link_mips64
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_mips64
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_mips64
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_mips64
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_mips64
|
||||
#define qemu_get_ram_block qemu_get_ram_block_mips64
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_mips64
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_mips64
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_mips64
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_mips64
|
||||
#define string_input_visitor_new string_input_visitor_new_mips64
|
||||
#define string_output_append string_output_append_mips64
|
||||
#define string_output_append_range string_output_append_range_mips64
|
||||
#define string_output_get_string string_output_get_string_mips64
|
||||
#define string_output_get_visitor string_output_get_visitor_mips64
|
||||
#define string_output_set string_output_set_mips64
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_mips64
|
||||
#define string_output_visitor_new string_output_visitor_new_mips64
|
||||
#define stristart stristart_mips64
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_mips64
|
||||
#define strpadcpy strpadcpy_mips64
|
||||
|
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_mips64el
|
||||
#define object_property_get object_property_get_mips64el
|
||||
#define object_property_get_bool object_property_get_bool_mips64el
|
||||
#define object_property_get_enum object_property_get_enum_mips64el
|
||||
#define object_property_get_int object_property_get_int_mips64el
|
||||
#define object_property_get_link object_property_get_link_mips64el
|
||||
#define object_property_get_qobject object_property_get_qobject_mips64el
|
||||
#define object_property_get_str object_property_get_str_mips64el
|
||||
#define object_property_get_type object_property_get_type_mips64el
|
||||
#define object_property_get_uint16List object_property_get_uint16List_mips64el
|
||||
#define object_property_is_child object_property_is_child_mips64el
|
||||
#define object_property_print object_property_print_mips64el
|
||||
#define object_property_set object_property_set_mips64el
|
||||
#define object_property_set_description object_property_set_description_mips64el
|
||||
#define object_property_set_link object_property_set_link_mips64el
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_mips64el
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_mips64el
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_mips64el
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_mips64el
|
||||
#define qemu_get_ram_block qemu_get_ram_block_mips64el
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_mips64el
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_mips64el
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_mips64el
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_mips64el
|
||||
#define string_input_visitor_new string_input_visitor_new_mips64el
|
||||
#define string_output_append string_output_append_mips64el
|
||||
#define string_output_append_range string_output_append_range_mips64el
|
||||
#define string_output_get_string string_output_get_string_mips64el
|
||||
#define string_output_get_visitor string_output_get_visitor_mips64el
|
||||
#define string_output_set string_output_set_mips64el
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_mips64el
|
||||
#define string_output_visitor_new string_output_visitor_new_mips64el
|
||||
#define stristart stristart_mips64el
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_mips64el
|
||||
#define strpadcpy strpadcpy_mips64el
|
||||
|
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_mipsel
|
||||
#define object_property_get object_property_get_mipsel
|
||||
#define object_property_get_bool object_property_get_bool_mipsel
|
||||
#define object_property_get_enum object_property_get_enum_mipsel
|
||||
#define object_property_get_int object_property_get_int_mipsel
|
||||
#define object_property_get_link object_property_get_link_mipsel
|
||||
#define object_property_get_qobject object_property_get_qobject_mipsel
|
||||
#define object_property_get_str object_property_get_str_mipsel
|
||||
#define object_property_get_type object_property_get_type_mipsel
|
||||
#define object_property_get_uint16List object_property_get_uint16List_mipsel
|
||||
#define object_property_is_child object_property_is_child_mipsel
|
||||
#define object_property_print object_property_print_mipsel
|
||||
#define object_property_set object_property_set_mipsel
|
||||
#define object_property_set_description object_property_set_description_mipsel
|
||||
#define object_property_set_link object_property_set_link_mipsel
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_mipsel
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_mipsel
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_mipsel
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_mipsel
|
||||
#define qemu_get_ram_block qemu_get_ram_block_mipsel
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_mipsel
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_mipsel
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_mipsel
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_mipsel
|
||||
#define string_input_visitor_new string_input_visitor_new_mipsel
|
||||
#define string_output_append string_output_append_mipsel
|
||||
#define string_output_append_range string_output_append_range_mipsel
|
||||
#define string_output_get_string string_output_get_string_mipsel
|
||||
#define string_output_get_visitor string_output_get_visitor_mipsel
|
||||
#define string_output_set string_output_set_mipsel
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_mipsel
|
||||
#define string_output_visitor_new string_output_visitor_new_mipsel
|
||||
#define stristart stristart_mipsel
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_mipsel
|
||||
#define strpadcpy strpadcpy_mipsel
|
||||
|
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_powerpc
|
||||
#define object_property_get object_property_get_powerpc
|
||||
#define object_property_get_bool object_property_get_bool_powerpc
|
||||
#define object_property_get_enum object_property_get_enum_powerpc
|
||||
#define object_property_get_int object_property_get_int_powerpc
|
||||
#define object_property_get_link object_property_get_link_powerpc
|
||||
#define object_property_get_qobject object_property_get_qobject_powerpc
|
||||
#define object_property_get_str object_property_get_str_powerpc
|
||||
#define object_property_get_type object_property_get_type_powerpc
|
||||
#define object_property_get_uint16List object_property_get_uint16List_powerpc
|
||||
#define object_property_is_child object_property_is_child_powerpc
|
||||
#define object_property_print object_property_print_powerpc
|
||||
#define object_property_set object_property_set_powerpc
|
||||
#define object_property_set_description object_property_set_description_powerpc
|
||||
#define object_property_set_link object_property_set_link_powerpc
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_powerpc
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_powerpc
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_powerpc
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_powerpc
|
||||
#define qemu_get_ram_block qemu_get_ram_block_powerpc
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_powerpc
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_powerpc
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_powerpc
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_powerpc
|
||||
#define string_input_visitor_new string_input_visitor_new_powerpc
|
||||
#define string_output_append string_output_append_powerpc
|
||||
#define string_output_append_range string_output_append_range_powerpc
|
||||
#define string_output_get_string string_output_get_string_powerpc
|
||||
#define string_output_get_visitor string_output_get_visitor_powerpc
|
||||
#define string_output_set string_output_set_powerpc
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_powerpc
|
||||
#define string_output_visitor_new string_output_visitor_new_powerpc
|
||||
#define stristart stristart_powerpc
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_powerpc
|
||||
#define strpadcpy strpadcpy_powerpc
|
||||
|
@ -1,3 +1,3 @@
|
||||
util-obj-y = qapi-visit-core.o qapi-dealloc-visitor.o qmp-input-visitor.o
|
||||
util-obj-y += qmp-output-visitor.o
|
||||
util-obj-y += string-input-visitor.o string-output-visitor.o
|
||||
util-obj-y += string-input-visitor.o
|
||||
|
@ -55,7 +55,7 @@ static void *qapi_dealloc_pop(QapiDeallocVisitor *qov)
|
||||
QObject *value;
|
||||
QTAILQ_REMOVE(&qov->stack, e, node);
|
||||
value = e->value;
|
||||
g_free(e);
|
||||
free(e);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ static void qapi_dealloc_end_struct(Visitor *v, Error **errp)
|
||||
QapiDeallocVisitor *qov = to_qov(v);
|
||||
void **obj = qapi_dealloc_pop(qov);
|
||||
if (obj) {
|
||||
g_free(*obj);
|
||||
free(*obj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ static void qapi_dealloc_end_implicit_struct(Visitor *v, Error **errp)
|
||||
QapiDeallocVisitor *qov = to_qov(v);
|
||||
void **obj = qapi_dealloc_pop(qov);
|
||||
if (obj) {
|
||||
g_free(*obj);
|
||||
free(*obj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList **listp,
|
||||
|
||||
if (list) {
|
||||
list = list->next;
|
||||
g_free(*listp);
|
||||
free(*listp);
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
if (obj) {
|
||||
g_free(*obj);
|
||||
free(*obj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v)
|
||||
|
||||
void qapi_dealloc_visitor_cleanup(QapiDeallocVisitor *v)
|
||||
{
|
||||
g_free(v);
|
||||
free(v);
|
||||
}
|
||||
|
||||
QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
|
||||
|
@ -304,10 +304,10 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
|
||||
if (strings[value] == NULL) {
|
||||
error_set(errp, QERR_INVALID_PARAMETER, enum_str);
|
||||
g_free(enum_str);
|
||||
free(enum_str);
|
||||
return;
|
||||
}
|
||||
|
||||
g_free(enum_str);
|
||||
free(enum_str);
|
||||
*obj = value;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ Visitor *qmp_input_get_visitor(QmpInputVisitor *v)
|
||||
void qmp_input_visitor_cleanup(QmpInputVisitor *v)
|
||||
{
|
||||
qobject_decref(v->stack[0].obj);
|
||||
g_free(v);
|
||||
free(v);
|
||||
}
|
||||
|
||||
QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
|
||||
|
@ -59,7 +59,7 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov)
|
||||
QObject *value;
|
||||
QTAILQ_REMOVE(&qov->stack, e, node);
|
||||
value = e->value;
|
||||
g_free(e);
|
||||
free(e);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -211,11 +211,11 @@ void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
|
||||
|
||||
QTAILQ_FOREACH_SAFE(e, &v->stack, node, tmp) {
|
||||
QTAILQ_REMOVE(&v->stack, e, node);
|
||||
g_free(e);
|
||||
free(e);
|
||||
}
|
||||
|
||||
qobject_decref(root);
|
||||
g_free(v);
|
||||
free(v);
|
||||
}
|
||||
|
||||
QmpOutputVisitor *qmp_output_visitor_new(void)
|
||||
|
@ -34,7 +34,7 @@ struct StringInputVisitor
|
||||
|
||||
static void free_range(void *range, void *dummy)
|
||||
{
|
||||
g_free(range);
|
||||
free(range);
|
||||
}
|
||||
|
||||
static void parse_str(StringInputVisitor *siv, Error **errp)
|
||||
@ -321,7 +321,7 @@ void string_input_visitor_cleanup(StringInputVisitor *v)
|
||||
{
|
||||
g_list_foreach(v->ranges, free_range, NULL);
|
||||
g_list_free(v->ranges);
|
||||
g_free(v);
|
||||
free(v);
|
||||
}
|
||||
|
||||
StringInputVisitor *string_input_visitor_new(const char *str)
|
||||
|
@ -1,354 +0,0 @@
|
||||
/*
|
||||
* String printing Visitor
|
||||
*
|
||||
* Copyright Red Hat, Inc. 2012
|
||||
*
|
||||
* Author: Paolo Bonzini <pbonzini@redhat.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING.LIB file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "qemu-common.h"
|
||||
#include "qapi/string-output-visitor.h"
|
||||
#include "qapi/visitor-impl.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/host-utils.h"
|
||||
#include <math.h>
|
||||
#include "qemu/range.h"
|
||||
|
||||
enum ListMode {
|
||||
LM_NONE, /* not traversing a list of repeated options */
|
||||
LM_STARTED, /* start_list() succeeded */
|
||||
|
||||
LM_IN_PROGRESS, /* next_list() has been called.
|
||||
*
|
||||
* Generating the next list link will consume the most
|
||||
* recently parsed QemuOpt instance of the repeated
|
||||
* option.
|
||||
*
|
||||
* Parsing a value into the list link will examine the
|
||||
* next QemuOpt instance of the repeated option, and
|
||||
* possibly enter LM_SIGNED_INTERVAL or
|
||||
* LM_UNSIGNED_INTERVAL.
|
||||
*/
|
||||
|
||||
LM_SIGNED_INTERVAL, /* next_list() has been called.
|
||||
*
|
||||
* Generating the next list link will consume the most
|
||||
* recently stored element from the signed interval,
|
||||
* parsed from the most recent QemuOpt instance of the
|
||||
* repeated option. This may consume QemuOpt itself
|
||||
* and return to LM_IN_PROGRESS.
|
||||
*
|
||||
* Parsing a value into the list link will store the
|
||||
* next element of the signed interval.
|
||||
*/
|
||||
|
||||
LM_UNSIGNED_INTERVAL,/* Same as above, only for an unsigned interval. */
|
||||
|
||||
LM_END
|
||||
};
|
||||
|
||||
typedef enum ListMode ListMode;
|
||||
|
||||
struct StringOutputVisitor
|
||||
{
|
||||
Visitor visitor;
|
||||
bool human;
|
||||
GString *string;
|
||||
bool head;
|
||||
ListMode list_mode;
|
||||
union {
|
||||
int64_t s;
|
||||
uint64_t u;
|
||||
} range_start, range_end;
|
||||
GList *ranges;
|
||||
};
|
||||
|
||||
static void string_output_set(StringOutputVisitor *sov, char *string)
|
||||
{
|
||||
if (sov->string) {
|
||||
g_string_free(sov->string, true);
|
||||
}
|
||||
sov->string = g_string_new(string);
|
||||
g_free(string);
|
||||
}
|
||||
|
||||
static void string_output_append(StringOutputVisitor *sov, int64_t a)
|
||||
{
|
||||
Range *r = g_malloc0(sizeof(*r));
|
||||
r->begin = a;
|
||||
r->end = a + 1;
|
||||
sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);
|
||||
}
|
||||
|
||||
static void string_output_append_range(StringOutputVisitor *sov,
|
||||
int64_t s, int64_t e)
|
||||
{
|
||||
Range *r = g_malloc0(sizeof(*r));
|
||||
r->begin = s;
|
||||
r->end = e + 1;
|
||||
sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);
|
||||
}
|
||||
|
||||
static void format_string(StringOutputVisitor *sov, Range *r, bool next,
|
||||
bool human)
|
||||
{
|
||||
if (r->end - r->begin > 1) {
|
||||
if (human) {
|
||||
g_string_append_printf(sov->string, "0x%" PRIx64 "-0x%" PRIx64,
|
||||
r->begin, r->end - 1);
|
||||
|
||||
} else {
|
||||
g_string_append_printf(sov->string, "%" PRId64 "-%" PRId64,
|
||||
r->begin, r->end - 1);
|
||||
}
|
||||
} else {
|
||||
if (human) {
|
||||
g_string_append_printf(sov->string, "0x%" PRIx64, r->begin);
|
||||
} else {
|
||||
g_string_append_printf(sov->string, "%" PRId64, r->begin);
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
g_string_append(sov->string, ",");
|
||||
}
|
||||
}
|
||||
|
||||
static void print_type_int(Visitor *v, int64_t *obj, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
|
||||
GList *l;
|
||||
|
||||
switch (sov->list_mode) {
|
||||
case LM_NONE:
|
||||
string_output_append(sov, *obj);
|
||||
break;
|
||||
|
||||
case LM_STARTED:
|
||||
sov->range_start.s = *obj;
|
||||
sov->range_end.s = *obj;
|
||||
sov->list_mode = LM_IN_PROGRESS;
|
||||
return;
|
||||
|
||||
case LM_IN_PROGRESS:
|
||||
if (sov->range_end.s + 1 == *obj) {
|
||||
sov->range_end.s++;
|
||||
} else {
|
||||
if (sov->range_start.s == sov->range_end.s) {
|
||||
string_output_append(sov, sov->range_end.s);
|
||||
} else {
|
||||
assert(sov->range_start.s < sov->range_end.s);
|
||||
string_output_append_range(sov, sov->range_start.s,
|
||||
sov->range_end.s);
|
||||
}
|
||||
|
||||
sov->range_start.s = *obj;
|
||||
sov->range_end.s = *obj;
|
||||
}
|
||||
return;
|
||||
|
||||
case LM_END:
|
||||
if (sov->range_end.s + 1 == *obj) {
|
||||
sov->range_end.s++;
|
||||
assert(sov->range_start.s < sov->range_end.s);
|
||||
string_output_append_range(sov, sov->range_start.s,
|
||||
sov->range_end.s);
|
||||
} else {
|
||||
if (sov->range_start.s == sov->range_end.s) {
|
||||
string_output_append(sov, sov->range_end.s);
|
||||
} else {
|
||||
assert(sov->range_start.s < sov->range_end.s);
|
||||
|
||||
string_output_append_range(sov, sov->range_start.s,
|
||||
sov->range_end.s);
|
||||
}
|
||||
string_output_append(sov, *obj);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
l = sov->ranges;
|
||||
while (l) {
|
||||
Range *r = l->data;
|
||||
format_string(sov, r, l->next != NULL, false);
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
if (sov->human) {
|
||||
l = sov->ranges;
|
||||
g_string_append(sov->string, " (");
|
||||
while (l) {
|
||||
Range *r = l->data;
|
||||
format_string(sov, r, l->next != NULL, true);
|
||||
l = l->next;
|
||||
}
|
||||
g_string_append(sov->string, ")");
|
||||
}
|
||||
}
|
||||
|
||||
static void print_type_size(Visitor *v, uint64_t *obj, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
|
||||
static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' };
|
||||
uint64_t div, val;
|
||||
char *out;
|
||||
int i;
|
||||
|
||||
if (!sov->human) {
|
||||
out = g_strdup_printf("%"PRIu64, *obj);
|
||||
string_output_set(sov, out);
|
||||
return;
|
||||
}
|
||||
|
||||
val = *obj;
|
||||
|
||||
/* The exponent (returned in i) minus one gives us
|
||||
* floor(log2(val * 1024 / 1000). The correction makes us
|
||||
* switch to the higher power when the integer part is >= 1000.
|
||||
*/
|
||||
frexp(val / (1000.0 / 1024.0), &i);
|
||||
i = (i - 1) / 10;
|
||||
assert(i < ARRAY_SIZE(suffixes));
|
||||
div = 1ULL << (i * 10);
|
||||
|
||||
out = g_strdup_printf("%"PRIu64" (%0.3g %c%s)", val,
|
||||
(double)val/div, suffixes[i], i ? "iB" : "");
|
||||
string_output_set(sov, out);
|
||||
}
|
||||
|
||||
static void print_type_bool(Visitor *v, bool *obj, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
|
||||
string_output_set(sov, g_strdup(*obj ? "true" : "false"));
|
||||
}
|
||||
|
||||
static void print_type_str(Visitor *v, char **obj, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
|
||||
char *out;
|
||||
|
||||
if (sov->human) {
|
||||
out = *obj ? g_strdup_printf("\"%s\"", *obj) : g_strdup("<null>");
|
||||
} else {
|
||||
out = g_strdup(*obj ? *obj : "");
|
||||
}
|
||||
string_output_set(sov, out);
|
||||
}
|
||||
|
||||
static void print_type_number(Visitor *v, double *obj, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
|
||||
string_output_set(sov, g_strdup_printf("%f", *obj));
|
||||
}
|
||||
|
||||
static void
|
||||
start_list(Visitor *v, const char *name, Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
|
||||
|
||||
/* we can't traverse a list in a list */
|
||||
assert(sov->list_mode == LM_NONE);
|
||||
sov->list_mode = LM_STARTED;
|
||||
sov->head = true;
|
||||
}
|
||||
|
||||
static GenericList *
|
||||
next_list(Visitor *v, GenericList **list, Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
|
||||
GenericList *ret = NULL;
|
||||
if (*list) {
|
||||
if (sov->head) {
|
||||
ret = *list;
|
||||
} else {
|
||||
ret = (*list)->next;
|
||||
}
|
||||
|
||||
if (sov->head) {
|
||||
if (ret && ret->next == NULL) {
|
||||
sov->list_mode = LM_NONE;
|
||||
}
|
||||
sov->head = false;
|
||||
} else {
|
||||
if (ret && ret->next == NULL) {
|
||||
sov->list_mode = LM_END;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
end_list(Visitor *v, Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v);
|
||||
|
||||
assert(sov->list_mode == LM_STARTED ||
|
||||
sov->list_mode == LM_END ||
|
||||
sov->list_mode == LM_NONE ||
|
||||
sov->list_mode == LM_IN_PROGRESS);
|
||||
sov->list_mode = LM_NONE;
|
||||
sov->head = true;
|
||||
|
||||
}
|
||||
|
||||
char *string_output_get_string(StringOutputVisitor *sov)
|
||||
{
|
||||
char *string = g_string_free(sov->string, false);
|
||||
sov->string = NULL;
|
||||
return string;
|
||||
}
|
||||
|
||||
Visitor *string_output_get_visitor(StringOutputVisitor *sov)
|
||||
{
|
||||
return &sov->visitor;
|
||||
}
|
||||
|
||||
static void free_range(void *range, void *dummy)
|
||||
{
|
||||
g_free(range);
|
||||
}
|
||||
|
||||
void string_output_visitor_cleanup(StringOutputVisitor *sov)
|
||||
{
|
||||
if (sov->string) {
|
||||
g_string_free(sov->string, true);
|
||||
}
|
||||
|
||||
g_list_foreach(sov->ranges, free_range, NULL);
|
||||
g_list_free(sov->ranges);
|
||||
g_free(sov);
|
||||
}
|
||||
|
||||
StringOutputVisitor *string_output_visitor_new(bool human)
|
||||
{
|
||||
StringOutputVisitor *v;
|
||||
|
||||
v = g_malloc0(sizeof(*v));
|
||||
|
||||
v->string = g_string_new(NULL);
|
||||
v->human = human;
|
||||
v->visitor.type_enum = output_type_enum;
|
||||
v->visitor.type_int = print_type_int;
|
||||
v->visitor.type_size = print_type_size;
|
||||
v->visitor.type_bool = print_type_bool;
|
||||
v->visitor.type_str = print_type_str;
|
||||
v->visitor.type_number = print_type_number;
|
||||
v->visitor.start_list = start_list;
|
||||
v->visitor.next_list = next_list;
|
||||
v->visitor.end_list = end_list;
|
||||
|
||||
return v;
|
||||
}
|
@ -103,7 +103,7 @@ void timerlist_free(QEMUTimerList *timer_list)
|
||||
QLIST_REMOVE(timer_list, list);
|
||||
}
|
||||
qemu_mutex_destroy(&timer_list->active_timers_lock);
|
||||
g_free(timer_list);
|
||||
free(timer_list);
|
||||
}
|
||||
|
||||
bool timerlist_has_timers(QEMUTimerList *timer_list)
|
||||
|
@ -354,8 +354,8 @@ static void parser_context_free(JSONParserContext *ctxt)
|
||||
for (i = 0; i < ctxt->tokens.count; i++) {
|
||||
qobject_decref(ctxt->tokens.buf[i]);
|
||||
}
|
||||
g_free(ctxt->tokens.buf);
|
||||
g_free(ctxt);
|
||||
free(ctxt->tokens.buf);
|
||||
free(ctxt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,5 +64,5 @@ QBool *qobject_to_qbool(const QObject *obj)
|
||||
static void qbool_destroy_obj(QObject *obj)
|
||||
{
|
||||
assert(obj != NULL);
|
||||
g_free(qobject_to_qbool(obj));
|
||||
free(qobject_to_qbool(obj));
|
||||
}
|
||||
|
@ -432,8 +432,8 @@ static void qentry_destroy(QDictEntry *e)
|
||||
assert(e->value != NULL);
|
||||
|
||||
qobject_decref(e->value);
|
||||
g_free(e->key);
|
||||
g_free(e);
|
||||
free(e->key);
|
||||
free(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -474,7 +474,7 @@ static void qdict_destroy_obj(QObject *obj)
|
||||
}
|
||||
}
|
||||
|
||||
g_free(qdict);
|
||||
free(qdict);
|
||||
}
|
||||
|
||||
static void qdict_flatten_qdict(QDict *qdict, QDict *target,
|
||||
@ -509,7 +509,7 @@ static void qdict_flatten_qlist(QList *qlist, QDict *target, const char *prefix)
|
||||
qdict_put_obj(target, new_key, value);
|
||||
}
|
||||
|
||||
g_free(new_key);
|
||||
free(new_key);
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix)
|
||||
delete = true;
|
||||
}
|
||||
|
||||
g_free(new_key);
|
||||
free(new_key);
|
||||
|
||||
if (delete) {
|
||||
qdict_del(qdict, entry->key);
|
||||
|
@ -64,5 +64,5 @@ QFloat *qobject_to_qfloat(const QObject *obj)
|
||||
static void qfloat_destroy_obj(QObject *obj)
|
||||
{
|
||||
assert(obj != NULL);
|
||||
g_free(qobject_to_qfloat(obj));
|
||||
free(qobject_to_qfloat(obj));
|
||||
}
|
||||
|
@ -63,5 +63,5 @@ QInt *qobject_to_qint(const QObject *obj)
|
||||
static void qint_destroy_obj(QObject *obj)
|
||||
{
|
||||
assert(obj != NULL);
|
||||
g_free(qobject_to_qint(obj));
|
||||
free(qobject_to_qint(obj));
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ QObject *qlist_pop(QList *qlist)
|
||||
QTAILQ_REMOVE(&qlist->head, entry, next);
|
||||
|
||||
ret = entry->value;
|
||||
g_free(entry);
|
||||
free(entry);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -163,8 +163,8 @@ static void qlist_destroy_obj(QObject *obj)
|
||||
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
|
||||
QTAILQ_REMOVE(&qlist->head, entry, next);
|
||||
qobject_decref(entry->value);
|
||||
g_free(entry);
|
||||
free(entry);
|
||||
}
|
||||
|
||||
g_free(qlist);
|
||||
free(qlist);
|
||||
}
|
||||
|
@ -144,6 +144,6 @@ static void qstring_destroy_obj(QObject *obj)
|
||||
|
||||
assert(obj != NULL);
|
||||
qs = qobject_to_qstring(obj);
|
||||
g_free(qs->string);
|
||||
g_free(qs);
|
||||
free(qs->string);
|
||||
free(qs);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ CPUState *cpu_generic_init(struct uc_struct *uc, const char *typename, const cha
|
||||
|
||||
oc = cpu_class_by_name(uc, typename, name);
|
||||
if (oc == NULL) {
|
||||
g_free(str);
|
||||
free(str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ CPUState *cpu_generic_init(struct uc_struct *uc, const char *typename, const cha
|
||||
|
||||
featurestr = strtok(NULL, ",");
|
||||
cc->parse_features(cpu, featurestr, &err);
|
||||
g_free(str);
|
||||
free(str);
|
||||
if (err != NULL) {
|
||||
goto out;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "qapi/visitor.h"
|
||||
#include "qapi-visit.h"
|
||||
#include "qapi/string-input-visitor.h"
|
||||
#include "qapi/string-output-visitor.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
|
||||
/* TODO: replace QObject with a simpler visitor to avoid a dependency
|
||||
@ -228,7 +227,7 @@ static void type_initialize_interface(struct uc_struct *uc, TypeImpl *ti, TypeIm
|
||||
iface_impl = type_new(uc, &info);
|
||||
iface_impl->parent_type = parent_type;
|
||||
type_initialize(uc, iface_impl);
|
||||
g_free((char *)info.name);
|
||||
free((char *)info.name);
|
||||
|
||||
new_iface = (InterfaceClass *)iface_impl->class;
|
||||
new_iface->concrete_class = ti->class;
|
||||
@ -364,10 +363,10 @@ static void object_property_del_all(struct uc_struct *uc, Object *obj)
|
||||
prop->release(uc, obj, prop->name, prop->opaque);
|
||||
}
|
||||
|
||||
g_free(prop->name);
|
||||
g_free(prop->type);
|
||||
g_free(prop->description);
|
||||
g_free(prop);
|
||||
free(prop->name);
|
||||
free(prop->type);
|
||||
free(prop->description);
|
||||
free(prop);
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,7 +423,7 @@ static Object *object_new_with_type(struct uc_struct *uc, Type type)
|
||||
|
||||
obj = g_malloc(type->instance_size);
|
||||
object_initialize_with_type(uc, obj, type->instance_size, type);
|
||||
obj->free = g_free;
|
||||
obj->free = free;
|
||||
|
||||
return obj;
|
||||
}
|
||||
@ -734,12 +733,12 @@ object_property_add(Object *obj, const char *name, const char *type,
|
||||
|
||||
ret = object_property_add(obj, full_name, type, get, set,
|
||||
release, opaque, NULL);
|
||||
g_free(full_name);
|
||||
free(full_name);
|
||||
if (ret) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_free(name_no_array);
|
||||
free(name_no_array);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -794,10 +793,10 @@ void object_property_del(struct uc_struct *uc, Object *obj, const char *name, Er
|
||||
|
||||
QTAILQ_REMOVE(&obj->properties, prop, node);
|
||||
|
||||
g_free(prop->name);
|
||||
g_free(prop->type);
|
||||
g_free(prop->description);
|
||||
g_free(prop);
|
||||
free(prop->name);
|
||||
free(prop->type);
|
||||
free(prop->description);
|
||||
free(prop);
|
||||
}
|
||||
|
||||
void object_property_get(struct uc_struct *uc, Object *obj, Visitor *v, const char *name,
|
||||
@ -868,7 +867,7 @@ void object_property_set_link(struct uc_struct *uc, Object *obj, Object *value,
|
||||
if (value) {
|
||||
gchar *path = object_get_canonical_path(value);
|
||||
object_property_set_str(uc, obj, path, name, errp);
|
||||
g_free(path);
|
||||
free(path);
|
||||
} else {
|
||||
object_property_set_str(uc, obj, "", name, errp);
|
||||
}
|
||||
@ -887,7 +886,7 @@ Object *object_property_get_link(struct uc_struct *uc, Object *obj, const char *
|
||||
}
|
||||
}
|
||||
|
||||
g_free(str);
|
||||
free(str);
|
||||
return target;
|
||||
}
|
||||
|
||||
@ -953,48 +952,6 @@ int64_t object_property_get_int(struct uc_struct *uc, Object *obj, const char *n
|
||||
return retval;
|
||||
}
|
||||
|
||||
int object_property_get_enum(struct uc_struct *uc, Object *obj, const char *name,
|
||||
const char *strings[], Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov;
|
||||
StringInputVisitor *siv;
|
||||
char *str;
|
||||
int ret;
|
||||
|
||||
sov = string_output_visitor_new(false);
|
||||
object_property_get(uc, obj, string_output_get_visitor(sov), name, errp);
|
||||
str = string_output_get_string(sov);
|
||||
siv = string_input_visitor_new(str);
|
||||
string_output_visitor_cleanup(sov);
|
||||
visit_type_enum(string_input_get_visitor(siv),
|
||||
&ret, strings, NULL, name, errp);
|
||||
|
||||
g_free(str);
|
||||
string_input_visitor_cleanup(siv);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void object_property_get_uint16List(struct uc_struct *uc, Object *obj, const char *name,
|
||||
uint16List **list, Error **errp)
|
||||
{
|
||||
StringOutputVisitor *ov;
|
||||
StringInputVisitor *iv;
|
||||
char *str;
|
||||
|
||||
ov = string_output_visitor_new(false);
|
||||
object_property_get(uc, obj, string_output_get_visitor(ov),
|
||||
name, errp);
|
||||
str = string_output_get_string(ov);
|
||||
iv = string_input_visitor_new(str);
|
||||
visit_type_uint16List(string_input_get_visitor(iv),
|
||||
list, NULL, errp);
|
||||
|
||||
g_free(str);
|
||||
string_output_visitor_cleanup(ov);
|
||||
string_input_visitor_cleanup(iv);
|
||||
}
|
||||
|
||||
void object_property_parse(struct uc_struct *uc, Object *obj, const char *string,
|
||||
const char *name, Error **errp)
|
||||
{
|
||||
@ -1005,27 +962,6 @@ void object_property_parse(struct uc_struct *uc, Object *obj, const char *string
|
||||
string_input_visitor_cleanup(mi);
|
||||
}
|
||||
|
||||
char *object_property_print(struct uc_struct *uc, Object *obj, const char *name, bool human,
|
||||
Error **errp)
|
||||
{
|
||||
StringOutputVisitor *mo;
|
||||
char *string = NULL;
|
||||
Error *local_err = NULL;
|
||||
|
||||
mo = string_output_visitor_new(human);
|
||||
object_property_get(uc, obj, string_output_get_visitor(mo), name, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
goto out;
|
||||
}
|
||||
|
||||
string = string_output_get_string(mo);
|
||||
|
||||
out:
|
||||
string_output_visitor_cleanup(mo);
|
||||
return string;
|
||||
}
|
||||
|
||||
const char *object_property_get_type(Object *obj, const char *name, Error **errp)
|
||||
{
|
||||
ObjectProperty *prop = object_property_find(obj, name, errp);
|
||||
@ -1053,7 +989,7 @@ static void object_get_child_property(struct uc_struct *uc, Object *obj, Visitor
|
||||
|
||||
path = object_get_canonical_path(child);
|
||||
visit_type_str(v, &path, name, errp);
|
||||
g_free(path);
|
||||
free(path);
|
||||
}
|
||||
|
||||
static Object *object_resolve_child_property(struct uc_struct *uc, Object *parent, void *opaque, const gchar *part)
|
||||
@ -1099,7 +1035,7 @@ void object_property_add_child(Object *obj, const char *name,
|
||||
child->parent = obj;
|
||||
|
||||
out:
|
||||
g_free(type);
|
||||
free(type);
|
||||
}
|
||||
|
||||
void object_property_allow_set_link(Object *obj, const char *name,
|
||||
@ -1124,7 +1060,7 @@ static void object_get_link_property(struct uc_struct *uc, Object *obj, Visitor
|
||||
if (*child) {
|
||||
path = object_get_canonical_path(*child);
|
||||
visit_type_str(v, &path, name, errp);
|
||||
g_free(path);
|
||||
free(path);
|
||||
} else {
|
||||
path = (gchar *)"";
|
||||
visit_type_str(v, &path, name, errp);
|
||||
@ -1165,7 +1101,7 @@ static Object *object_resolve_link(struct uc_struct *uc, Object *obj, const char
|
||||
}
|
||||
target = NULL;
|
||||
}
|
||||
g_free(target_type);
|
||||
free(target_type);
|
||||
|
||||
return target;
|
||||
}
|
||||
@ -1186,7 +1122,7 @@ static int object_set_link_property(struct uc_struct *uc, Object *obj, Visitor *
|
||||
new_target = object_resolve_link(uc, obj, name, path, &local_err);
|
||||
}
|
||||
|
||||
g_free(path);
|
||||
free(path);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return -1;
|
||||
@ -1220,7 +1156,7 @@ static void object_release_link_property(struct uc_struct *uc, Object *obj, cons
|
||||
if ((prop->flags & OBJ_PROP_LINK_UNREF_ON_RELEASE) && *prop->child) {
|
||||
object_unref(uc, *prop->child);
|
||||
}
|
||||
g_free(prop);
|
||||
free(prop);
|
||||
}
|
||||
|
||||
void object_property_add_link(Object *obj, const char *name,
|
||||
@ -1249,14 +1185,14 @@ void object_property_add_link(Object *obj, const char *name,
|
||||
&local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
g_free(prop);
|
||||
free(prop);
|
||||
goto out;
|
||||
}
|
||||
|
||||
op->resolve = object_resolve_link_property;
|
||||
|
||||
out:
|
||||
g_free(full_type);
|
||||
free(full_type);
|
||||
}
|
||||
|
||||
gchar *object_get_canonical_path_component(Object *obj)
|
||||
@ -1291,8 +1227,8 @@ gchar *object_get_canonical_path(Object *obj)
|
||||
|
||||
if (path) {
|
||||
newpath = g_strdup_printf("%s/%s", component, path);
|
||||
g_free(component);
|
||||
g_free(path);
|
||||
free(component);
|
||||
free(path);
|
||||
path = newpath;
|
||||
} else {
|
||||
path = component;
|
||||
@ -1302,7 +1238,7 @@ gchar *object_get_canonical_path(Object *obj)
|
||||
}
|
||||
|
||||
newpath = g_strdup_printf("/%s", path ? path : "");
|
||||
g_free(path);
|
||||
free(path);
|
||||
|
||||
return newpath;
|
||||
}
|
||||
@ -1425,7 +1361,7 @@ static void property_get_str(struct uc_struct *uc, Object *obj, Visitor *v, void
|
||||
value = prop->get(uc, obj, errp);
|
||||
if (value) {
|
||||
visit_type_str(v, &value, name, errp);
|
||||
g_free(value);
|
||||
free(value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1443,7 +1379,7 @@ static int property_set_str(struct uc_struct *uc, Object *obj, Visitor *v, void
|
||||
}
|
||||
|
||||
prop->set(uc, obj, value, errp);
|
||||
g_free(value);
|
||||
free(value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1452,7 +1388,7 @@ static void property_release_str(struct uc_struct *uc, Object *obj, const char *
|
||||
void *opaque)
|
||||
{
|
||||
StringProperty *prop = opaque;
|
||||
g_free(prop);
|
||||
free(prop);
|
||||
}
|
||||
|
||||
void object_property_add_str(Object *obj, const char *name,
|
||||
@ -1473,7 +1409,7 @@ void object_property_add_str(Object *obj, const char *name,
|
||||
prop, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
g_free(prop);
|
||||
free(prop);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1513,7 +1449,7 @@ static void property_release_bool(struct uc_struct *uc, Object *obj, const char
|
||||
void *opaque)
|
||||
{
|
||||
BoolProperty *prop = opaque;
|
||||
g_free(prop);
|
||||
free(prop);
|
||||
}
|
||||
|
||||
void object_property_add_bool(struct uc_struct *uc, Object *obj, const char *name,
|
||||
@ -1534,7 +1470,7 @@ void object_property_add_bool(struct uc_struct *uc, Object *obj, const char *nam
|
||||
prop, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
g_free(prop);
|
||||
free(prop);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1638,7 +1574,7 @@ static void property_release_alias(struct uc_struct *uc, Object *obj, const char
|
||||
{
|
||||
AliasProperty *prop = opaque;
|
||||
|
||||
g_free(prop);
|
||||
free(prop);
|
||||
}
|
||||
|
||||
void object_property_add_alias(Object *obj, const char *name,
|
||||
@ -1674,7 +1610,7 @@ void object_property_add_alias(Object *obj, const char *name,
|
||||
prop, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
g_free(prop);
|
||||
free(prop);
|
||||
goto out;
|
||||
}
|
||||
op->resolve = property_resolve_alias;
|
||||
@ -1684,7 +1620,7 @@ void object_property_add_alias(Object *obj, const char *name,
|
||||
&error_abort);
|
||||
|
||||
out:
|
||||
g_free(prop_type);
|
||||
free(prop_type);
|
||||
}
|
||||
|
||||
void object_property_set_description(Object *obj, const char *name,
|
||||
@ -1697,7 +1633,7 @@ void object_property_set_description(Object *obj, const char *name,
|
||||
return;
|
||||
}
|
||||
|
||||
g_free(op->description);
|
||||
free(op->description);
|
||||
op->description = g_strdup(description);
|
||||
}
|
||||
|
||||
|
11
qemu/sparc.h
11
qemu/sparc.h
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_sparc
|
||||
#define object_property_get object_property_get_sparc
|
||||
#define object_property_get_bool object_property_get_bool_sparc
|
||||
#define object_property_get_enum object_property_get_enum_sparc
|
||||
#define object_property_get_int object_property_get_int_sparc
|
||||
#define object_property_get_link object_property_get_link_sparc
|
||||
#define object_property_get_qobject object_property_get_qobject_sparc
|
||||
#define object_property_get_str object_property_get_str_sparc
|
||||
#define object_property_get_type object_property_get_type_sparc
|
||||
#define object_property_get_uint16List object_property_get_uint16List_sparc
|
||||
#define object_property_is_child object_property_is_child_sparc
|
||||
#define object_property_print object_property_print_sparc
|
||||
#define object_property_set object_property_set_sparc
|
||||
#define object_property_set_description object_property_set_description_sparc
|
||||
#define object_property_set_link object_property_set_link_sparc
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_sparc
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_sparc
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_sparc
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_sparc
|
||||
#define qemu_get_ram_block qemu_get_ram_block_sparc
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_sparc
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_sparc
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_sparc
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_sparc
|
||||
#define string_input_visitor_new string_input_visitor_new_sparc
|
||||
#define string_output_append string_output_append_sparc
|
||||
#define string_output_append_range string_output_append_range_sparc
|
||||
#define string_output_get_string string_output_get_string_sparc
|
||||
#define string_output_get_visitor string_output_get_visitor_sparc
|
||||
#define string_output_set string_output_set_sparc
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_sparc
|
||||
#define string_output_visitor_new string_output_visitor_new_sparc
|
||||
#define stristart stristart_sparc
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_sparc
|
||||
#define strpadcpy strpadcpy_sparc
|
||||
|
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_sparc64
|
||||
#define object_property_get object_property_get_sparc64
|
||||
#define object_property_get_bool object_property_get_bool_sparc64
|
||||
#define object_property_get_enum object_property_get_enum_sparc64
|
||||
#define object_property_get_int object_property_get_int_sparc64
|
||||
#define object_property_get_link object_property_get_link_sparc64
|
||||
#define object_property_get_qobject object_property_get_qobject_sparc64
|
||||
#define object_property_get_str object_property_get_str_sparc64
|
||||
#define object_property_get_type object_property_get_type_sparc64
|
||||
#define object_property_get_uint16List object_property_get_uint16List_sparc64
|
||||
#define object_property_is_child object_property_is_child_sparc64
|
||||
#define object_property_print object_property_print_sparc64
|
||||
#define object_property_set object_property_set_sparc64
|
||||
#define object_property_set_description object_property_set_description_sparc64
|
||||
#define object_property_set_link object_property_set_link_sparc64
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_sparc64
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_sparc64
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_sparc64
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_sparc64
|
||||
#define qemu_get_ram_block qemu_get_ram_block_sparc64
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_sparc64
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_sparc64
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_sparc64
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_sparc64
|
||||
#define string_input_visitor_new string_input_visitor_new_sparc64
|
||||
#define string_output_append string_output_append_sparc64
|
||||
#define string_output_append_range string_output_append_range_sparc64
|
||||
#define string_output_get_string string_output_get_string_sparc64
|
||||
#define string_output_get_visitor string_output_get_visitor_sparc64
|
||||
#define string_output_set string_output_set_sparc64
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_sparc64
|
||||
#define string_output_visitor_new string_output_visitor_new_sparc64
|
||||
#define stristart stristart_sparc64
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_sparc64
|
||||
#define strpadcpy strpadcpy_sparc64
|
||||
|
@ -273,7 +273,7 @@ static void arm_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque)
|
||||
cs->env_ptr = &cpu->env;
|
||||
cpu_exec_init(&cpu->env, opaque);
|
||||
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
|
||||
g_free, g_free);
|
||||
free, free);
|
||||
|
||||
#if 0
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
@ -414,7 +414,7 @@ static ObjectClass *arm_cpu_class_by_name(struct uc_struct *uc, const char *cpu_
|
||||
|
||||
typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
|
||||
oc = object_class_by_name(uc, typename);
|
||||
g_free(typename);
|
||||
free(typename);
|
||||
if (!oc || !object_class_dynamic_cast(uc, oc, TYPE_ARM_CPU) ||
|
||||
object_class_is_abstract(oc)) {
|
||||
return NULL;
|
||||
@ -1084,7 +1084,7 @@ static void cpu_register(struct uc_struct *uc, const ARMCPUInfo *info)
|
||||
|
||||
type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
|
||||
type_register(uc, &type_info);
|
||||
g_free((void *)type_info.name);
|
||||
free((void *)type_info.name);
|
||||
}
|
||||
|
||||
void arm_cpu_register_types(void *opaque)
|
||||
|
@ -212,7 +212,7 @@ static void aarch64_cpu_register(struct uc_struct *uc, const ARMCPUInfo *info)
|
||||
|
||||
type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
|
||||
type_register(uc, &type_info);
|
||||
g_free((void *)type_info.name);
|
||||
free((void *)type_info.name);
|
||||
}
|
||||
|
||||
void aarch64_cpu_register_types(void *opaque)
|
||||
|
@ -155,7 +155,7 @@ static void count_cpreg(gpointer key, gpointer opaque)
|
||||
}
|
||||
}
|
||||
|
||||
static gint cpreg_key_compare(gconstpointer a, gconstpointer b)
|
||||
static int32_t cpreg_key_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
uint64_t aidx = cpreg_to_kvm_id(*(uint32_t *)a);
|
||||
uint64_t bidx = cpreg_to_kvm_id(*(uint32_t *)b);
|
||||
@ -3102,7 +3102,7 @@ static void arm_cpu_list_entry(gpointer data, gpointer user_data)
|
||||
name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_ARM_CPU));
|
||||
(*s->cpu_fprintf)(s->file, " %s\n",
|
||||
name);
|
||||
g_free(name);
|
||||
free(name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -23,13 +23,13 @@ void arm64_release(void* ctx)
|
||||
{
|
||||
TCGContext *s = (TCGContext *) ctx;
|
||||
|
||||
g_free(s->tb_ctx.tbs);
|
||||
free(s->tb_ctx.tbs);
|
||||
struct uc_struct* uc = s->uc;
|
||||
ARMCPU* cpu = (ARMCPU*) uc->cpu;
|
||||
g_free(cpu->cpreg_indexes);
|
||||
g_free(cpu->cpreg_values);
|
||||
g_free(cpu->cpreg_vmstate_indexes);
|
||||
g_free(cpu->cpreg_vmstate_values);
|
||||
free(cpu->cpreg_indexes);
|
||||
free(cpu->cpreg_values);
|
||||
free(cpu->cpreg_vmstate_indexes);
|
||||
free(cpu->cpreg_vmstate_values);
|
||||
|
||||
release_common(ctx);
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ void arm_release(void* ctx)
|
||||
{
|
||||
TCGContext *s = (TCGContext *) ctx;
|
||||
|
||||
g_free(s->tb_ctx.tbs);
|
||||
free(s->tb_ctx.tbs);
|
||||
struct uc_struct* uc = s->uc;
|
||||
ARMCPU* cpu = (ARMCPU*) uc->cpu;
|
||||
g_free(cpu->cpreg_indexes);
|
||||
g_free(cpu->cpreg_values);
|
||||
g_free(cpu->cpreg_vmstate_indexes);
|
||||
g_free(cpu->cpreg_vmstate_values);
|
||||
free(cpu->cpreg_indexes);
|
||||
free(cpu->cpreg_values);
|
||||
free(cpu->cpreg_vmstate_indexes);
|
||||
free(cpu->cpreg_vmstate_values);
|
||||
|
||||
release_common(ctx);
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ static ObjectClass *x86_cpu_class_by_name(struct uc_struct *uc, const char *cpu_
|
||||
|
||||
typename = x86_cpu_type_name(cpu_model);
|
||||
oc = object_class_by_name(uc, typename);
|
||||
g_free(typename);
|
||||
free(typename);
|
||||
return oc;
|
||||
}
|
||||
|
||||
@ -1756,7 +1756,7 @@ static void x86_register_cpudef_type(struct uc_struct *uc, X86CPUDefinition *def
|
||||
};
|
||||
|
||||
type_register(uc, &ti);
|
||||
g_free(typename);
|
||||
free(typename);
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
|
@ -1112,7 +1112,7 @@ void do_cpu_init(X86CPU *cpu)
|
||||
memcpy(&env->start_init_save, &save->start_init_save,
|
||||
offsetof(CPUX86State, end_init_save) -
|
||||
offsetof(CPUX86State, start_init_save));
|
||||
g_free(save);
|
||||
free(save);
|
||||
|
||||
apic_init_reset(env->uc, cpu->apic_state);
|
||||
}
|
||||
|
@ -29,21 +29,21 @@ void x86_release(void *ctx)
|
||||
release_common(ctx);
|
||||
|
||||
// arch specific
|
||||
g_free(s->cpu_A0);
|
||||
g_free(s->cpu_T[0]);
|
||||
g_free(s->cpu_T[1]);
|
||||
g_free(s->cpu_tmp0);
|
||||
g_free(s->cpu_tmp4);
|
||||
g_free(s->cpu_cc_srcT);
|
||||
g_free(s->cpu_cc_dst);
|
||||
g_free(s->cpu_cc_src);
|
||||
g_free(s->cpu_cc_src2);
|
||||
free(s->cpu_A0);
|
||||
free(s->cpu_T[0]);
|
||||
free(s->cpu_T[1]);
|
||||
free(s->cpu_tmp0);
|
||||
free(s->cpu_tmp4);
|
||||
free(s->cpu_cc_srcT);
|
||||
free(s->cpu_cc_dst);
|
||||
free(s->cpu_cc_src);
|
||||
free(s->cpu_cc_src2);
|
||||
|
||||
for (i = 0; i < CPU_NB_REGS; ++i) {
|
||||
g_free(s->cpu_regs[i]);
|
||||
free(s->cpu_regs[i]);
|
||||
}
|
||||
|
||||
g_free(s->tb_ctx.tbs);
|
||||
free(s->tb_ctx.tbs);
|
||||
}
|
||||
|
||||
void x86_reg_reset(struct uc_struct *uc)
|
||||
|
@ -74,7 +74,7 @@ static ObjectClass *m68k_cpu_class_by_name(struct uc_struct *uc, const char *cpu
|
||||
|
||||
typename = g_strdup_printf("%s-" TYPE_M68K_CPU, cpu_model);
|
||||
oc = object_class_by_name(uc, typename);
|
||||
g_free(typename);
|
||||
free(typename);
|
||||
if (oc != NULL && (object_class_dynamic_cast(uc, oc, TYPE_M68K_CPU) == NULL ||
|
||||
object_class_is_abstract(oc))) {
|
||||
return NULL;
|
||||
@ -208,7 +208,7 @@ static void register_cpu_type(void *opaque, const M68kCPUInfo *info)
|
||||
|
||||
type_info.name = g_strdup_printf("%s-" TYPE_M68K_CPU, info->name);
|
||||
type_register(opaque, &type_info);
|
||||
g_free((void *)type_info.name);
|
||||
free((void *)type_info.name);
|
||||
}
|
||||
|
||||
void m68k_cpu_register_types(void *opaque)
|
||||
|
@ -22,24 +22,24 @@ void m68k_release(void* ctx)
|
||||
{
|
||||
release_common(ctx);
|
||||
TCGContext *tcg_ctx = (TCGContext *) ctx;
|
||||
g_free(tcg_ctx->tb_ctx.tbs);
|
||||
g_free(tcg_ctx->QREG_PC);
|
||||
g_free(tcg_ctx->QREG_SR);
|
||||
g_free(tcg_ctx->QREG_CC_OP);
|
||||
g_free(tcg_ctx->QREG_CC_DEST);
|
||||
g_free(tcg_ctx->QREG_CC_SRC);
|
||||
g_free(tcg_ctx->QREG_CC_X);
|
||||
g_free(tcg_ctx->QREG_DIV1);
|
||||
g_free(tcg_ctx->QREG_DIV2);
|
||||
g_free(tcg_ctx->QREG_MACSR);
|
||||
g_free(tcg_ctx->QREG_MAC_MASK);
|
||||
free(tcg_ctx->tb_ctx.tbs);
|
||||
free(tcg_ctx->QREG_PC);
|
||||
free(tcg_ctx->QREG_SR);
|
||||
free(tcg_ctx->QREG_CC_OP);
|
||||
free(tcg_ctx->QREG_CC_DEST);
|
||||
free(tcg_ctx->QREG_CC_SRC);
|
||||
free(tcg_ctx->QREG_CC_X);
|
||||
free(tcg_ctx->QREG_DIV1);
|
||||
free(tcg_ctx->QREG_DIV2);
|
||||
free(tcg_ctx->QREG_MACSR);
|
||||
free(tcg_ctx->QREG_MAC_MASK);
|
||||
int i;
|
||||
for (i = 0; i < 8; i++) {
|
||||
g_free(tcg_ctx->cpu_dregs[i]);
|
||||
g_free(tcg_ctx->cpu_aregs[i]);
|
||||
free(tcg_ctx->cpu_dregs[i]);
|
||||
free(tcg_ctx->cpu_aregs[i]);
|
||||
}
|
||||
g_free(tcg_ctx->NULL_QREG);
|
||||
g_free(tcg_ctx->store_dummy);
|
||||
free(tcg_ctx->NULL_QREG);
|
||||
free(tcg_ctx->store_dummy);
|
||||
}
|
||||
|
||||
void m68k_reg_reset(struct uc_struct *uc)
|
||||
|
@ -46,24 +46,24 @@ void mips_release(void *ctx)
|
||||
TCGContext *tcg_ctx = (TCGContext *) ctx;
|
||||
release_common(ctx);
|
||||
MIPSCPU* cpu = MIPS_CPU(tcg_ctx->uc, tcg_ctx->uc->cpu);
|
||||
g_free(cpu->env.tlb);
|
||||
g_free(cpu->env.mvp);
|
||||
free(cpu->env.tlb);
|
||||
free(cpu->env.mvp);
|
||||
|
||||
for (i = 0; i < MIPS_DSP_ACC; i++) {
|
||||
g_free(tcg_ctx->cpu_HI[i]);
|
||||
g_free(tcg_ctx->cpu_LO[i]);
|
||||
free(tcg_ctx->cpu_HI[i]);
|
||||
free(tcg_ctx->cpu_LO[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
g_free(tcg_ctx->cpu_gpr[i]);
|
||||
free(tcg_ctx->cpu_gpr[i]);
|
||||
}
|
||||
|
||||
g_free(tcg_ctx->cpu_PC);
|
||||
g_free(tcg_ctx->btarget);
|
||||
g_free(tcg_ctx->bcond);
|
||||
g_free(tcg_ctx->cpu_dspctrl);
|
||||
free(tcg_ctx->cpu_PC);
|
||||
free(tcg_ctx->btarget);
|
||||
free(tcg_ctx->bcond);
|
||||
free(tcg_ctx->cpu_dspctrl);
|
||||
|
||||
g_free(tcg_ctx->tb_ctx.tbs);
|
||||
free(tcg_ctx->tb_ctx.tbs);
|
||||
}
|
||||
|
||||
void mips_reg_reset(struct uc_struct *uc)
|
||||
|
@ -100,7 +100,7 @@ static int cpu_sparc_register(struct uc_struct *uc, SPARCCPU *cpu, const char *c
|
||||
Error *err = NULL;
|
||||
|
||||
if (cpu_sparc_find_by_name(def, name) < 0) {
|
||||
g_free(s);
|
||||
free(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ static int cpu_sparc_register(struct uc_struct *uc, SPARCCPU *cpu, const char *c
|
||||
|
||||
featurestr = strtok(NULL, ",");
|
||||
cc->parse_features(CPU(cpu), featurestr, &err);
|
||||
g_free(s);
|
||||
free(s);
|
||||
if (err) {
|
||||
//error_report("%s", error_get_pretty(err));
|
||||
error_free(err);
|
||||
@ -821,7 +821,7 @@ static void sparc_cpu_uninitfn(struct uc_struct *uc, Object *obj, void *opaque)
|
||||
SPARCCPU *cpu = SPARC_CPU(uc, obj);
|
||||
CPUSPARCState *env = &cpu->env;
|
||||
|
||||
g_free(env->def);
|
||||
free(env->def);
|
||||
}
|
||||
|
||||
static void sparc_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *data)
|
||||
|
@ -34,30 +34,30 @@ void sparc_release(void *ctx)
|
||||
int i;
|
||||
TCGContext *tcg_ctx = (TCGContext *) ctx;
|
||||
release_common(ctx);
|
||||
g_free(tcg_ctx->cpu_wim);
|
||||
g_free(tcg_ctx->cpu_cond);
|
||||
g_free(tcg_ctx->cpu_cc_src);
|
||||
g_free(tcg_ctx->cpu_cc_src2);
|
||||
g_free(tcg_ctx->cpu_cc_dst);
|
||||
g_free(tcg_ctx->cpu_fsr);
|
||||
g_free(tcg_ctx->sparc_cpu_pc);
|
||||
g_free(tcg_ctx->cpu_npc);
|
||||
g_free(tcg_ctx->cpu_y);
|
||||
g_free(tcg_ctx->cpu_tbr);
|
||||
free(tcg_ctx->cpu_wim);
|
||||
free(tcg_ctx->cpu_cond);
|
||||
free(tcg_ctx->cpu_cc_src);
|
||||
free(tcg_ctx->cpu_cc_src2);
|
||||
free(tcg_ctx->cpu_cc_dst);
|
||||
free(tcg_ctx->cpu_fsr);
|
||||
free(tcg_ctx->sparc_cpu_pc);
|
||||
free(tcg_ctx->cpu_npc);
|
||||
free(tcg_ctx->cpu_y);
|
||||
free(tcg_ctx->cpu_tbr);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
g_free(tcg_ctx->cpu_gregs[i]);
|
||||
free(tcg_ctx->cpu_gregs[i]);
|
||||
}
|
||||
for (i = 0; i < 32; i++) {
|
||||
g_free(tcg_ctx->cpu_gpr[i]);
|
||||
free(tcg_ctx->cpu_gpr[i]);
|
||||
}
|
||||
|
||||
g_free(tcg_ctx->cpu_PC);
|
||||
g_free(tcg_ctx->btarget);
|
||||
g_free(tcg_ctx->bcond);
|
||||
g_free(tcg_ctx->cpu_dspctrl);
|
||||
free(tcg_ctx->cpu_PC);
|
||||
free(tcg_ctx->btarget);
|
||||
free(tcg_ctx->bcond);
|
||||
free(tcg_ctx->cpu_dspctrl);
|
||||
|
||||
g_free(tcg_ctx->tb_ctx.tbs);
|
||||
free(tcg_ctx->tb_ctx.tbs);
|
||||
}
|
||||
|
||||
void sparc_reg_reset(struct uc_struct *uc)
|
||||
|
@ -299,7 +299,7 @@ void tcg_pool_reset(TCGContext *s)
|
||||
TCGPool *p, *t;
|
||||
for (p = s->pool_first_large; p; p = t) {
|
||||
t = p->next;
|
||||
g_free(p);
|
||||
free(p);
|
||||
}
|
||||
s->pool_first_large = NULL;
|
||||
s->pool_cur = s->pool_end = NULL;
|
||||
|
@ -142,7 +142,7 @@ static void tb_clean_internal(struct uc_struct *uc, int i, void** lp)
|
||||
}
|
||||
tb_clean_internal(uc, i-1, (*lp) + ((0 >> (i * V_L2_BITS)) & (V_L2_SIZE - 1)));
|
||||
if (lp && *lp) {
|
||||
g_free(*lp);
|
||||
free(*lp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -667,7 +667,7 @@ void free_code_gen_buffer(struct uc_struct *uc)
|
||||
{
|
||||
TCGContext *tcg_ctx = uc->tcg_ctx;
|
||||
if (tcg_ctx->code_gen_buffer)
|
||||
g_free(tcg_ctx->code_gen_buffer);
|
||||
free(tcg_ctx->code_gen_buffer);
|
||||
}
|
||||
|
||||
static inline void *alloc_code_gen_buffer(struct uc_struct *uc)
|
||||
@ -792,7 +792,7 @@ void tb_free(struct uc_struct *uc, TranslationBlock *tb)
|
||||
static inline void invalidate_page_bitmap(PageDesc *p)
|
||||
{
|
||||
if (p->code_bitmap) {
|
||||
g_free(p->code_bitmap);
|
||||
free(p->code_bitmap);
|
||||
p->code_bitmap = NULL;
|
||||
}
|
||||
p->code_write_count = 0;
|
||||
|
@ -32,14 +32,14 @@ static void release_common(void *t)
|
||||
|
||||
// Clean TCG.
|
||||
TCGOpDef* def = &s->tcg_op_defs[0];
|
||||
g_free(def->args_ct);
|
||||
g_free(def->sorted_args);
|
||||
g_free(s->tcg_op_defs);
|
||||
free(def->args_ct);
|
||||
free(def->sorted_args);
|
||||
free(s->tcg_op_defs);
|
||||
|
||||
TCGPool *po, *to;
|
||||
for (po = s->pool_first; po; po = to) {
|
||||
to = po->next;
|
||||
g_free(po);
|
||||
free(po);
|
||||
}
|
||||
tcg_pool_reset(s);
|
||||
g_hash_table_destroy(s->helpers);
|
||||
|
@ -67,7 +67,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
|
||||
msg1 = g_strdup_vprintf(fmt, ap);
|
||||
if (os_errno != 0) {
|
||||
err->msg = g_strdup_printf("%s: %s", msg1, strerror(os_errno));
|
||||
g_free(msg1);
|
||||
free(msg1);
|
||||
} else {
|
||||
err->msg = msg1;
|
||||
}
|
||||
@ -110,8 +110,8 @@ void error_set_win32(Error **errp, int win32_err, ErrorClass err_class,
|
||||
char *msg2 = g_win32_error_message(win32_err);
|
||||
err->msg = g_strdup_printf("%s: %s (error: %x)", msg1, msg2,
|
||||
(unsigned)win32_err);
|
||||
g_free(msg2);
|
||||
g_free(msg1);
|
||||
free(msg2);
|
||||
free(msg1);
|
||||
} else {
|
||||
err->msg = msg1;
|
||||
}
|
||||
@ -152,8 +152,8 @@ const char *error_get_pretty(Error *err)
|
||||
void error_free(Error *err)
|
||||
{
|
||||
if (err) {
|
||||
g_free(err->msg);
|
||||
g_free(err);
|
||||
free(err->msg);
|
||||
free(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,6 @@ extern int daemon(int, int);
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
#include "config-host.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include <sys/mman.h>
|
||||
@ -183,13 +181,6 @@ int qemu_pipe(int pipefd[2])
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
qemu_get_local_state_pathname(const char *relative_pathname)
|
||||
{
|
||||
return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR,
|
||||
relative_pathname);
|
||||
}
|
||||
|
||||
void qemu_set_tty_echo(int fd, bool echo)
|
||||
{
|
||||
struct termios tty;
|
||||
|
@ -25,15 +25,9 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* The implementation of g_poll (functions poll_rest, g_poll) at the end of
|
||||
* this file are based on code from GNOME glib-2 and use a different license,
|
||||
* see the license comment there.
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
#define G_OS_WIN32
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include "config-host.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
@ -156,23 +150,6 @@ int qemu_gettimeofday(qemu_timeval *tp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
qemu_get_local_state_pathname(const char *relative_pathname)
|
||||
{
|
||||
HRESULT result;
|
||||
char base_path[MAX_PATH+1] = "";
|
||||
|
||||
result = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL,
|
||||
/* SHGFP_TYPE_CURRENT */ 0, base_path);
|
||||
if (result != S_OK) {
|
||||
/* misconfigured environment */
|
||||
g_critical("CSIDL_COMMON_APPDATA unavailable: %ld", (long)result);
|
||||
abort();
|
||||
}
|
||||
return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", base_path,
|
||||
relative_pathname);
|
||||
}
|
||||
|
||||
void qemu_set_tty_echo(int fd, bool echo)
|
||||
{
|
||||
HANDLE handle = (HANDLE)_get_osfhandle(fd);
|
||||
@ -192,210 +169,6 @@ void qemu_set_tty_echo(int fd, bool echo)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The original implementation of g_poll from glib has a problem on Windows
|
||||
* when using timeouts < 10 ms.
|
||||
*
|
||||
* Whenever g_poll is called with timeout < 10 ms, it does a quick poll instead
|
||||
* of wait. This causes significant performance degradation of QEMU.
|
||||
*
|
||||
* The following code is a copy of the original code from glib/gpoll.c
|
||||
* (glib commit 20f4d1820b8d4d0fc4447188e33efffd6d4a88d8 from 2014-02-19).
|
||||
* Some debug code was removed and the code was reformatted.
|
||||
* All other code modifications are marked with 'QEMU'.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gpoll.c: poll(2) abstraction
|
||||
* Copyright 1998 Owen Taylor
|
||||
* Copyright 2008 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
static int poll_rest(gboolean poll_msgs, HANDLE *handles, gint nhandles,
|
||||
GPollFD *fds, guint nfds, gint timeout)
|
||||
{
|
||||
DWORD ready;
|
||||
GPollFD *f;
|
||||
int recursed_result;
|
||||
|
||||
if (poll_msgs) {
|
||||
/* Wait for either messages or handles
|
||||
* -> Use MsgWaitForMultipleObjectsEx
|
||||
*/
|
||||
ready = MsgWaitForMultipleObjectsEx(nhandles, handles, timeout,
|
||||
QS_ALLINPUT, MWMO_ALERTABLE);
|
||||
|
||||
if (ready == WAIT_FAILED) {
|
||||
gchar *emsg = g_win32_error_message(GetLastError());
|
||||
g_warning("MsgWaitForMultipleObjectsEx failed: %s", emsg);
|
||||
g_free(emsg);
|
||||
}
|
||||
} else if (nhandles == 0) {
|
||||
/* No handles to wait for, just the timeout */
|
||||
if (timeout == INFINITE) {
|
||||
ready = WAIT_FAILED;
|
||||
} else {
|
||||
SleepEx(timeout, TRUE);
|
||||
ready = WAIT_TIMEOUT;
|
||||
}
|
||||
} else {
|
||||
/* Wait for just handles
|
||||
* -> Use WaitForMultipleObjectsEx
|
||||
*/
|
||||
ready =
|
||||
WaitForMultipleObjectsEx(nhandles, handles, FALSE, timeout, TRUE);
|
||||
if (ready == WAIT_FAILED) {
|
||||
gchar *emsg = g_win32_error_message(GetLastError());
|
||||
g_warning("WaitForMultipleObjectsEx failed: %s", emsg);
|
||||
g_free(emsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (ready == WAIT_FAILED) {
|
||||
return -1;
|
||||
} else if (ready == WAIT_TIMEOUT || ready == WAIT_IO_COMPLETION) {
|
||||
return 0;
|
||||
} else if (poll_msgs && ready == WAIT_OBJECT_0 + nhandles) {
|
||||
for (f = fds; f < &fds[nfds]; ++f) {
|
||||
if (f->fd == G_WIN32_MSG_HANDLE && f->events & G_IO_IN) {
|
||||
f->revents |= G_IO_IN;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have a timeout, or no handles to poll, be satisfied
|
||||
* with just noticing we have messages waiting.
|
||||
*/
|
||||
if (timeout != 0 || nhandles == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If no timeout and handles to poll, recurse to poll them,
|
||||
* too.
|
||||
*/
|
||||
recursed_result = poll_rest(FALSE, handles, nhandles, fds, nfds, 0);
|
||||
return (recursed_result == -1) ? -1 : 1 + recursed_result;
|
||||
} else if (/* QEMU: removed the following unneeded statement which causes
|
||||
* a compiler warning: ready >= WAIT_OBJECT_0 && */
|
||||
ready < WAIT_OBJECT_0 + nhandles) {
|
||||
for (f = fds; f < &fds[nfds]; ++f) {
|
||||
if ((HANDLE) f->fd == handles[ready - WAIT_OBJECT_0]) {
|
||||
f->revents = f->events;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no timeout and polling several handles, recurse to poll
|
||||
* the rest of them.
|
||||
*/
|
||||
if (timeout == 0 && nhandles > 1) {
|
||||
/* Remove the handle that fired */
|
||||
int i;
|
||||
if (ready < nhandles - 1) {
|
||||
for (i = ready - WAIT_OBJECT_0 + 1; i < nhandles; i++) {
|
||||
handles[i-1] = handles[i];
|
||||
}
|
||||
}
|
||||
nhandles--;
|
||||
recursed_result = poll_rest(FALSE, handles, nhandles, fds, nfds, 0);
|
||||
return (recursed_result == -1) ? -1 : 1 + recursed_result;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gint g_poll(GPollFD *fds, guint nfds, gint timeout)
|
||||
{
|
||||
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
|
||||
gboolean poll_msgs = FALSE;
|
||||
GPollFD *f;
|
||||
gint nhandles = 0;
|
||||
int retval;
|
||||
|
||||
for (f = fds; f < &fds[nfds]; ++f) {
|
||||
if (f->fd == G_WIN32_MSG_HANDLE && (f->events & G_IO_IN)) {
|
||||
poll_msgs = TRUE;
|
||||
} else if (f->fd > 0) {
|
||||
/* Don't add the same handle several times into the array, as
|
||||
* docs say that is not allowed, even if it actually does seem
|
||||
* to work.
|
||||
*/
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < nhandles; i++) {
|
||||
if (handles[i] == (HANDLE) f->fd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == nhandles) {
|
||||
if (nhandles == MAXIMUM_WAIT_OBJECTS) {
|
||||
g_warning("Too many handles to wait for!\n");
|
||||
break;
|
||||
} else {
|
||||
handles[nhandles++] = (HANDLE) f->fd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (f = fds; f < &fds[nfds]; ++f) {
|
||||
f->revents = 0;
|
||||
}
|
||||
|
||||
if (timeout == -1) {
|
||||
timeout = INFINITE;
|
||||
}
|
||||
|
||||
/* Polling for several things? */
|
||||
if (nhandles > 1 || (nhandles > 0 && poll_msgs)) {
|
||||
/* First check if one or several of them are immediately
|
||||
* available
|
||||
*/
|
||||
retval = poll_rest(poll_msgs, handles, nhandles, fds, nfds, 0);
|
||||
|
||||
/* If not, and we have a significant timeout, poll again with
|
||||
* timeout then. Note that this will return indication for only
|
||||
* one event, or only for messages. We ignore timeouts less than
|
||||
* ten milliseconds as they are mostly pointless on Windows, the
|
||||
* MsgWaitForMultipleObjectsEx() call will timeout right away
|
||||
* anyway.
|
||||
*
|
||||
* Modification for QEMU: replaced timeout >= 10 by timeout > 0.
|
||||
*/
|
||||
if (retval == 0 && (timeout == INFINITE || timeout > 0)) {
|
||||
retval = poll_rest(poll_msgs, handles, nhandles,
|
||||
fds, nfds, timeout);
|
||||
}
|
||||
} else {
|
||||
/* Just polling for one thing, so no need to check first if
|
||||
* available immediately
|
||||
*/
|
||||
retval = poll_rest(poll_msgs, handles, nhandles, fds, nfds, timeout);
|
||||
}
|
||||
|
||||
if (retval == -1) {
|
||||
for (f = fds; f < &fds[nfds]; ++f) {
|
||||
f->revents = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
size_t getpagesize(void)
|
||||
{
|
||||
SYSTEM_INFO system_info;
|
||||
|
@ -288,9 +288,9 @@ QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name)
|
||||
static void qemu_opt_del(QemuOpt *opt)
|
||||
{
|
||||
QTAILQ_REMOVE(&opt->opts->head, opt, next);
|
||||
g_free(opt->name);
|
||||
g_free(opt->str);
|
||||
g_free(opt);
|
||||
free(opt->name);
|
||||
free(opt->str);
|
||||
free(opt);
|
||||
}
|
||||
|
||||
/* qemu_opt_set allows many settings for the same option.
|
||||
@ -327,7 +327,7 @@ const char *qemu_opt_get(QemuOpts *opts, const char *name)
|
||||
|
||||
/* Get a known option (or its default) and remove it from the list
|
||||
* all in one action. Return a malloced string of the option value.
|
||||
* Result must be freed by caller with g_free().
|
||||
* Result must be freed by caller with free().
|
||||
*/
|
||||
char *qemu_opt_get_del(QemuOpts *opts, const char *name)
|
||||
{
|
||||
@ -576,7 +576,7 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)
|
||||
opt->desc = find_desc_by_name(desc, name);
|
||||
if (!opt->desc && !opts_accepts_any(opts)) {
|
||||
qerror_report(QERR_INVALID_PARAMETER, name);
|
||||
g_free(opt);
|
||||
free(opt);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -598,7 +598,7 @@ int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val)
|
||||
opt->desc = find_desc_by_name(desc, name);
|
||||
if (!opt->desc && !opts_accepts_any(opts)) {
|
||||
qerror_report(QERR_INVALID_PARAMETER, name);
|
||||
g_free(opt);
|
||||
free(opt);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -698,7 +698,7 @@ const char *qemu_opts_id(QemuOpts *opts)
|
||||
return opts->id;
|
||||
}
|
||||
|
||||
/* The id string will be g_free()d by qemu_opts_del */
|
||||
/* The id string will be free()d by qemu_opts_del */
|
||||
void qemu_opts_set_id(QemuOpts *opts, char *id)
|
||||
{
|
||||
opts->id = id;
|
||||
@ -719,8 +719,8 @@ void qemu_opts_del(QemuOpts *opts)
|
||||
qemu_opt_del(opt);
|
||||
}
|
||||
QTAILQ_REMOVE(&opts->list->head, opts, next);
|
||||
g_free(opts->id);
|
||||
g_free(opts);
|
||||
free(opts->id);
|
||||
free(opts);
|
||||
}
|
||||
|
||||
void qemu_opts_print(QemuOpts *opts)
|
||||
@ -1064,7 +1064,7 @@ static size_t count_opts_list(QemuOptsList *list)
|
||||
|
||||
void qemu_opts_free(QemuOptsList *list)
|
||||
{
|
||||
g_free(list);
|
||||
free(list);
|
||||
}
|
||||
|
||||
/* Realloc dst option list and append options from an option list (list)
|
||||
|
@ -277,7 +277,7 @@ static unsigned __stdcall win32_start_routine(void *arg)
|
||||
|
||||
if (data->mode == QEMU_THREAD_DETACHED) {
|
||||
data->uc->qemu_thread_data = NULL;
|
||||
g_free(data);
|
||||
free(data);
|
||||
data = NULL;
|
||||
}
|
||||
qemu_thread_exit(data->uc, start_routine(thread_arg));
|
||||
@ -323,7 +323,7 @@ void *qemu_thread_join(QemuThread *thread)
|
||||
ret = data->ret;
|
||||
assert(data->mode != QEMU_THREAD_DETACHED);
|
||||
DeleteCriticalSection(&data->cs);
|
||||
g_free(data);
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -168,5 +168,5 @@ void qemu_register_machine(struct uc_struct *uc, QEMUMachine *m, const char *typ
|
||||
ti.class_init = machine_class_init;
|
||||
|
||||
type_register(uc, &ti);
|
||||
g_free(name);
|
||||
free(name);
|
||||
}
|
||||
|
@ -2179,15 +2179,12 @@
|
||||
#define object_property_find object_property_find_x86_64
|
||||
#define object_property_get object_property_get_x86_64
|
||||
#define object_property_get_bool object_property_get_bool_x86_64
|
||||
#define object_property_get_enum object_property_get_enum_x86_64
|
||||
#define object_property_get_int object_property_get_int_x86_64
|
||||
#define object_property_get_link object_property_get_link_x86_64
|
||||
#define object_property_get_qobject object_property_get_qobject_x86_64
|
||||
#define object_property_get_str object_property_get_str_x86_64
|
||||
#define object_property_get_type object_property_get_type_x86_64
|
||||
#define object_property_get_uint16List object_property_get_uint16List_x86_64
|
||||
#define object_property_is_child object_property_is_child_x86_64
|
||||
#define object_property_print object_property_print_x86_64
|
||||
#define object_property_set object_property_set_x86_64
|
||||
#define object_property_set_description object_property_set_description_x86_64
|
||||
#define object_property_set_link object_property_set_link_x86_64
|
||||
@ -2427,7 +2424,6 @@
|
||||
#define qemu_get_cpu qemu_get_cpu_x86_64
|
||||
#define qemu_get_guest_memory_mapping qemu_get_guest_memory_mapping_x86_64
|
||||
#define qemu_get_guest_simple_memory_mapping qemu_get_guest_simple_memory_mapping_x86_64
|
||||
#define qemu_get_local_state_pathname qemu_get_local_state_pathname_x86_64
|
||||
#define qemu_get_ram_block qemu_get_ram_block_x86_64
|
||||
#define qemu_get_ram_block_host_ptr qemu_get_ram_block_host_ptr_x86_64
|
||||
#define qemu_get_ram_fd qemu_get_ram_fd_x86_64
|
||||
@ -2716,13 +2712,6 @@
|
||||
#define string_input_get_visitor string_input_get_visitor_x86_64
|
||||
#define string_input_visitor_cleanup string_input_visitor_cleanup_x86_64
|
||||
#define string_input_visitor_new string_input_visitor_new_x86_64
|
||||
#define string_output_append string_output_append_x86_64
|
||||
#define string_output_append_range string_output_append_range_x86_64
|
||||
#define string_output_get_string string_output_get_string_x86_64
|
||||
#define string_output_get_visitor string_output_get_visitor_x86_64
|
||||
#define string_output_set string_output_set_x86_64
|
||||
#define string_output_visitor_cleanup string_output_visitor_cleanup_x86_64
|
||||
#define string_output_visitor_new string_output_visitor_new_x86_64
|
||||
#define stristart stristart_x86_64
|
||||
#define strongarm_cp_reginfo strongarm_cp_reginfo_x86_64
|
||||
#define strpadcpy strpadcpy_x86_64
|
||||
|
@ -5,11 +5,6 @@ include ../config.mk
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
|
||||
# Find GLIB
|
||||
ifndef GLIB
|
||||
GLIB = $(shell pkg-config --libs glib-2.0)
|
||||
endif
|
||||
|
||||
LIBDIR = ..
|
||||
BIN_EXT =
|
||||
AR_EXT = a
|
||||
@ -18,8 +13,8 @@ AR_EXT = a
|
||||
V ?= 0
|
||||
|
||||
CFLAGS += -Wall -Werror -I../include
|
||||
LDFLAGS += -L$(LIBDIR) -lunicorn -lpthread -lm $(GLIB)
|
||||
LDLIBS += -lpthread -lunicorn -lm $(GLIB)
|
||||
LDFLAGS += -L$(LIBDIR) -lunicorn -lpthread -lm
|
||||
LDLIBS += -lpthread -lunicorn -lm
|
||||
|
||||
ifneq ($(CROSS),)
|
||||
CC = $(CROSS)gcc
|
||||
|
@ -1,5 +1,5 @@
|
||||
CFLAGS += -Wall -Werror -I../../include
|
||||
LDLIBS += -L../../ $(shell pkg-config --libs glib-2.0) -lpthread -lm -lunicorn
|
||||
LDLIBS += -L../../ -lpthread -lm -lunicorn
|
||||
|
||||
EXECUTE_VARS = LD_LIBRARY_PATH=../../cmocka/src:../../ DYLD_LIBRARY_PATH=../../
|
||||
|
||||
|
18
uc.c
18
uc.c
@ -28,10 +28,10 @@
|
||||
static void free_table(gpointer key, gpointer value, gpointer data)
|
||||
{
|
||||
TypeInfo *ti = (TypeInfo*) value;
|
||||
g_free((void*) ti->class);
|
||||
g_free((void*) ti->name);
|
||||
g_free((void*) ti->parent);
|
||||
g_free((void*) ti);
|
||||
free((void*) ti->class);
|
||||
free((void*) ti->name);
|
||||
free((void*) ti->parent);
|
||||
free((void*) ti);
|
||||
}
|
||||
|
||||
UNICORN_EXPORT
|
||||
@ -287,12 +287,12 @@ uc_err uc_close(uc_engine *uc)
|
||||
// Cleanup internally.
|
||||
if (uc->release)
|
||||
uc->release(uc->tcg_ctx);
|
||||
g_free(uc->tcg_ctx);
|
||||
free(uc->tcg_ctx);
|
||||
|
||||
// Cleanup CPU.
|
||||
g_free(uc->cpu->tcg_as_listener);
|
||||
g_free(uc->cpu->thread);
|
||||
g_free(uc->cpu->halt_cond);
|
||||
free(uc->cpu->tcg_as_listener);
|
||||
free(uc->cpu->thread);
|
||||
free(uc->cpu->halt_cond);
|
||||
|
||||
// Cleanup all objects.
|
||||
OBJECT(uc->machine_state->accelerator)->ref = 1;
|
||||
@ -309,7 +309,7 @@ uc_err uc_close(uc_engine *uc)
|
||||
object_unref(uc, OBJECT(uc->root));
|
||||
|
||||
// System memory.
|
||||
g_free(uc->system_memory);
|
||||
free(uc->system_memory);
|
||||
|
||||
// Thread relateds.
|
||||
if (uc->qemu_thread_data)
|
||||
|
Loading…
Reference in New Issue
Block a user