qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: paul@codesourcery.com, aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH 2/2] linux-user: Use qemu-malloc.c.
Date: Fri, 21 May 2010 10:37:52 -0700	[thread overview]
Message-ID: <1274463472-17353-3-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <AANLkTim4-lT__IuYnRWkcniN8keX_y9COZCFIPf1Grcy@mail.gmail.com>

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>
---
 Makefile.target   |    3 ++-
 linux-user/mmap.c |   52 ----------------------------------------------------
 2 files changed, 2 insertions(+), 53 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index a22484e..93ee085 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)
 {
-- 
1.7.0.1

      parent reply	other threads:[~2010-05-21 17:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-14 21:52 [Qemu-devel] [PATCH] virtio-blk: Avoid zeroing every request structure Stefan Hajnoczi
2010-05-16 13:25 ` Christoph Hellwig
2010-05-16 15:01   ` Stefan Hajnoczi
2010-05-18  9:36 ` Kevin Wolf
2010-05-18 15:46 ` Jes Sorensen
2010-05-18 16:26   ` Alexander Graf
2010-05-18 16:29     ` Anthony Liguori
2010-05-18 16:31       ` Alexander Graf
2010-05-29 13:07         ` Jamie Lokier
2010-05-18 16:37 ` Corentin Chary
2010-05-18 19:02   ` Stefan Hajnoczi
2010-05-18 19:55     ` Corentin Chary
2010-05-18 20:43       ` Stefan Hajnoczi
2010-05-21 11:17         ` Stefan Hajnoczi
2010-05-21 17:37           ` [Qemu-devel] [PATCH 0/2] Tidy qemu_malloc Richard Henderson
2010-05-28 22:08             ` Aurelien Jarno
2010-05-21 17:37           ` [Qemu-devel] [PATCH 1/2] Use calloc in qemu_mallocz Richard Henderson
2010-05-21 17:37           ` Richard Henderson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274463472-17353-3-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=aurelien@aurel32.net \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).