From 52eb34af7be585c411a9a9ab39f0bea1d19e7d32 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 18 Sep 2024 00:53:51 -0600 Subject: fix? --- coroutine.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'coroutine.c') diff --git a/coroutine.c b/coroutine.c index fe6f5be..9e0920d 100644 --- a/coroutine.c +++ b/coroutine.c @@ -95,10 +95,7 @@ cid_t coroutine_add(cr_fn_t fn, void *args) { if (!setjmp(coroutine_add_env)) { /* point=a */ /* run until cr_begin() */ call_with_stack(coroutine_table[child-1].stack + (STACK_GROWS_DOWNWARD ? coroutine_table[child-1].stack_size : 0), fn, args); - /* cr_begin() calls longjmp(point=a); if fn returns - * then that means it didn't call cr_begin(), which is - * wrong. */ - assert(false); + assert(false); /* should cr_begin() instead of returning */ } assert(coroutine_table[child-1].state == CR_RUNNABLE); assert(parent == 0 || coroutine_table[parent-1].state == CR_RUNNING); @@ -113,12 +110,12 @@ void coroutine_main(void) { if (coroutine_running == 1) ran = false; if (coroutine_table[coroutine_running-1].state == CR_RUNNABLE) { + printf("running %zu...\n", coroutine_running); ran = true; coroutine_table[coroutine_running-1].state = CR_RUNNING; if (!setjmp(coroutine_main_env)) { /* point=b */ longjmp(coroutine_table[coroutine_running-1].env, 1); /* jump to point=c */ - /* Consider returning to be the same as cr_exit(). */ - coroutine_table[coroutine_running-1].state = CR_NONE; + assert(false); /* should cr_exit() instead of returning */ } if (coroutine_table[coroutine_running-1].state == CR_NONE) { free(coroutine_table[coroutine_running-1].stack); -- cgit v1.2.3-2-g168b