aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Lieven <pl@kamp.de>2016-09-27 11:58:43 +0200
committerKevin Wolf <kwolf@redhat.com>2016-09-29 14:13:39 +0200
commitddba15919bd51b45d0d1425cc2de0c0c0bae3877 (patch)
tree3f7b2d9f2b239141553ca1a3bf5c840e5b4e67e3 /util
parent8adcd6fb6d14ff7fbb47179384dcddbd6dfd95a3 (diff)
downloadqemu-ddba15919bd51b45d0d1425cc2de0c0c0bae3877.zip
qemu-ddba15919bd51b45d0d1425cc2de0c0c0bae3877.tar.gz
qemu-ddba15919bd51b45d0d1425cc2de0c0c0bae3877.tar.bz2
coroutine-ucontext: use helper for allocating stack memory
Signed-off-by: Peter Lieven <pl@kamp.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/coroutine-ucontext.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c
index 31254ab..6621f3f 100644
--- a/util/coroutine-ucontext.c
+++ b/util/coroutine-ucontext.c
@@ -34,6 +34,7 @@
typedef struct {
Coroutine base;
void *stack;
+ size_t stack_size;
sigjmp_buf env;
#ifdef CONFIG_VALGRIND_H
@@ -82,7 +83,6 @@ static void coroutine_trampoline(int i0, int i1)
Coroutine *qemu_coroutine_new(void)
{
- const size_t stack_size = COROUTINE_STACK_SIZE;
CoroutineUContext *co;
ucontext_t old_uc, uc;
sigjmp_buf old_env;
@@ -101,17 +101,18 @@ Coroutine *qemu_coroutine_new(void)
}
co = g_malloc0(sizeof(*co));
- co->stack = g_malloc(stack_size);
+ co->stack_size = COROUTINE_STACK_SIZE;
+ co->stack = qemu_alloc_stack(&co->stack_size);
co->base.entry_arg = &old_env; /* stash away our jmp_buf */
uc.uc_link = &old_uc;
uc.uc_stack.ss_sp = co->stack;
- uc.uc_stack.ss_size = stack_size;
+ uc.uc_stack.ss_size = co->stack_size;
uc.uc_stack.ss_flags = 0;
#ifdef CONFIG_VALGRIND_H
co->valgrind_stack_id =
- VALGRIND_STACK_REGISTER(co->stack, co->stack + stack_size);
+ VALGRIND_STACK_REGISTER(co->stack, co->stack + co->stack_size);
#endif
arg.p = co;
@@ -149,7 +150,7 @@ void qemu_coroutine_delete(Coroutine *co_)
valgrind_stack_deregister(co);
#endif
- g_free(co->stack);
+ qemu_free_stack(co->stack, co->stack_size);
g_free(co);
}