diff options
Diffstat (limited to 'include/stc')
| -rw-r--r-- | include/stc/algo/coroutine.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h index 84be4a4e..6d502988 100644 --- a/include/stc/algo/coroutine.h +++ b/include/stc/algo/coroutine.h @@ -50,7 +50,7 @@ int main(void) { { printf("%d %d\n", it.x, it.y); // example of early stop: - if (++n == 20) (void)cco_stop(&it); // signal to stop at next + if (++n == 20) cco_stop(&it); // signal to stop at next } return 0; } @@ -98,6 +98,9 @@ enum { goto _cco_final_ #define cco_stop(ctx) \ - (cco_alive(ctx) ? ((ctx)->cco_state = cco_state_final) : 0, ctx) + do { \ + int* _state = &(ctx)->cco_state; \ + if (*_state > 0) *_state = cco_state_final; \ + } while (0) #endif |
