[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc |
Date: |
Wed, 13 Mar 2013 14:44:28 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 05.03.2013 um 14:53 hat Anthony Liguori geschrieben:
> Signed-off-by: Anthony Liguori <address@hidden>
> --- /dev/null
> +++ b/tests/libqos/malloc.h
> @@ -0,0 +1,26 @@
> +#ifndef LIBQOS_MALLOC_H
> +#define LIBQOS_MALLOC_H
> +
> +#include <stdint.h>
> +#include <sys/types.h>
> +
> +typedef struct QGuestAllocator QGuestAllocator;
> +
> +struct QGuestAllocator
> +{
> + uint64_t (*alloc)(QGuestAllocator *allocator, size_t size);
> + void (*free)(QGuestAllocator *allocator, uint64_t addr);
> +};
> +
> +/* Always returns page aligned values */
> +static inline uint64_t guest_alloc(QGuestAllocator *allocator, size_t size)
> +{
> + return allocator->alloc(allocator, size);
> +}
> +
> +static inline void guest_free(QGuestAllocator *allocator, uint64_t addr)
> +{
> + allocator->alloc(allocator, addr);
> +}
I think the common case is using exactly one global allocator. Maybe
worth convenience macros like in libqtest.h?
Kevin
- [Qemu-devel] [RFC PATCH 0/8] libqos support, Anthony Liguori, 2013/03/05
- [Qemu-devel] [RFC PATCH 7/8] libqos: add fw_cfg-pc, Anthony Liguori, 2013/03/05
- [Qemu-devel] [RFC PATCH 4/8] pci: foreach, Anthony Liguori, 2013/03/05
- [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc, Anthony Liguori, 2013/03/05
- Re: [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc,
Kevin Wolf <=
- [Qemu-devel] [RFC PATCH 2/8] i440fx-test: add test to compare default register values against spec, Anthony Liguori, 2013/03/05
- [Qemu-devel] [RFC PATCH 3/8] i440fx-test: add test for PAM functionality, Anthony Liguori, 2013/03/05
- [Qemu-devel] [RFC PATCH 6/8] libqos: fw_cfg, Anthony Liguori, 2013/03/05
- [Qemu-devel] [RFC PATCH 1/8] qtest: add libqos, Anthony Liguori, 2013/03/05
- Re: [Qemu-devel] [RFC PATCH 1/8] qtest: add libqos, Andreas Färber, 2013/03/13