From a203314647b5c37c7e40230551457f006ff36cd5 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 1 Mar 2023 14:54:36 +0100 Subject: Reverted example moves. --- include/stc/algo/coroutine.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') 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 -- cgit v1.2.3