diff options
Diffstat (limited to 'coroutine.c')
-rw-r--r-- | coroutine.c | 9 |
1 files changed, 3 insertions, 6 deletions
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); |