From ca4de2716c6fa4772228e8e8e051ef09c69907e2 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sat, 7 Dec 2024 23:43:12 -0700 Subject: libcr: Centralize the structure of plat_jmp_buf --- libcr/coroutine.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libcr/coroutine.c b/libcr/coroutine.c index b4306d9..996262e 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -339,6 +339,9 @@ env->sp = cr_plat_get_sp(); #endif } + #if CONFIG_COROUTINE_MEASURE_STACK + static uintptr_t cr_plat_setjmp_get_sp(cr_plat_jmp_buf *env) { return env->sp; } + #endif /* cr_plat_setjmp *NEEDS* to be a preprocessor macro rather * than a real function, because [[gnu::returns_twice]] * doesn't work. @@ -741,9 +744,9 @@ void cr_cid_info(cid_t cid, struct cr_cid_info *ret) { if (cid == coroutine_running) sp = cr_plat_get_sp(); else if (coroutine_table[cid-1].state == CR_RUNNING) - sp = coroutine_add_env.sp; + sp = cr_plat_setjmp_get_sp(&coroutine_add_env); else - sp = coroutine_table[cid-1].env.sp; + sp = cr_plat_setjmp_get_sp(&coroutine_table[cid-1].env); assert(sp); uintptr_t sb = (uintptr_t)coroutine_table[cid-1].stack; #if CR_PLAT_STACK_GROWS_DOWNWARD -- cgit v1.2.3-2-g168b