summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-07 23:43:12 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-08 08:27:23 -0700
commitca4de2716c6fa4772228e8e8e051ef09c69907e2 (patch)
tree375f92c64117801e4e3baa50c530b3cad380c651
parent22579175678b3aa4e96b2e1a0082f4804b754299 (diff)
libcr: Centralize the structure of plat_jmp_buf
-rw-r--r--libcr/coroutine.c7
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