diff options
author | Richard Henderson <rth@twiddle.net> | 2010-05-21 10:37:52 -0700 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2010-05-28 23:27:19 +0200 |
commit | 680c877af48cf5f2fb4586f34c13fd21ce33bfec (patch) | |
tree | d9a91ece81718eb21ee799ea6ecbf543b521f3e9 | |
parent | 50401022d8fbdcdaf84d28e7b813ee94c2d47325 (diff) | |
download | hqemu-680c877af48cf5f2fb4586f34c13fd21ce33bfec.zip hqemu-680c877af48cf5f2fb4586f34c13fd21ce33bfec.tar.gz |
linux-user: Use qemu-malloc.c.
Since we're no longer setting PAGE_RESERVED, there's no need to
implement qemu_malloc via mmap.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
-rw-r--r-- | Makefile.target | 3 | ||||
-rw-r--r-- | linux-user/mmap.c | 52 |
2 files changed, 2 insertions, 53 deletions
diff --git a/Makefile.target b/Makefile.target index fda5bf3..d06c679 100644 --- a/Makefile.target +++ b/Makefile.target @@ -85,7 +85,8 @@ $(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \ - elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o + elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o \ + qemu-malloc.o obj-$(TARGET_HAS_BFLT) += flatload.o diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 9c062e7..fd315aa 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -77,58 +77,6 @@ void mmap_unlock(void) } #endif -void *qemu_vmalloc(size_t size) -{ - void *p; - - mmap_lock(); - /* Use map and mark the pages as used. */ - p = mmap(NULL, size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - mmap_unlock(); - return p; -} - -void *qemu_malloc(size_t size) -{ - char * p; - size += 16; - p = qemu_vmalloc(size); - *(size_t *)p = size; - return p + 16; -} - -/* We use map, which is always zero initialized. */ -void * qemu_mallocz(size_t size) -{ - return qemu_malloc(size); -} - -void qemu_free(void *ptr) -{ - /* FIXME: We should unmark the reserved pages here. However this gets - complicated when one target page spans multiple host pages, so we - don't bother. */ - size_t *p; - p = (size_t *)((char *)ptr - 16); - munmap(p, *p); -} - -void *qemu_realloc(void *ptr, size_t size) -{ - size_t old_size, copy; - void *new_ptr; - - if (!ptr) - return qemu_malloc(size); - old_size = *(size_t *)((char *)ptr - 16); - copy = old_size < size ? old_size : size; - new_ptr = qemu_malloc(size); - memcpy(new_ptr, ptr, copy); - qemu_free(ptr); - return new_ptr; -} - /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int prot) { |