diff options
Diffstat (limited to 'libcr/coroutine.c')
-rw-r--r-- | libcr/coroutine.c | 7 |
1 files 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 |