]> xenbits.xensource.com Git - unikraft/libs/libgo.git/commitdiff
Use uk_posix_memalign() for stack allocation
authorSimon Kuenzer <simon.kuenzer@neclab.eu>
Fri, 7 Feb 2020 14:36:33 +0000 (15:36 +0100)
committerSimon Kuenzer <simon.kuenzer@neclab.eu>
Fri, 7 Feb 2020 15:34:30 +0000 (16:34 +0100)
Recent changes in Unikraft modified uk_palloc()'s signature and
guarantees: allocation sizes are given with the number of pages and
the returned memory is not necessarily aligned to the size.
By using uk_posix_memalign() we restore our assumptions in the code.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
glue.c

diff --git a/glue.c b/glue.c
index 94a96b9ddb080a05a44594cae2b6abb279205751..44d2e08436aa57b2aa8d0243fd13ad1da7e21c76 100644 (file)
--- a/glue.c
+++ b/glue.c
@@ -187,7 +187,10 @@ void makecontext1 (ucontext_t *__ucp, void (*__func) (void), int __argc, ...)
 void *alloc_stack()
 {
        struct uk_sched *sched = uk_sched_get_default();
-       void *stack = uk_palloc(sched->allocator, __STACK_SIZE_PAGE_ORDER);
+       void *stack;
+
+       uk_posix_memalign(sched->allocator,
+                         &stack, __STACK_SIZE, __STACK_SIZE);
        if (stack == NULL)
                printf("error allocating stack\n");
        return stack;