diff options
| author | Tyge Løvset <[email protected]> | 2023-02-25 12:50:08 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-02-25 12:50:08 +0100 |
| commit | 40f184e52b2903b7ff1caed5c104b9d84e2f0d52 (patch) | |
| tree | e86173271a84df0b8cbbcd1a7096bbb7fa2bbcbd | |
| parent | 12a64923057aea6d09f541356bb5d9c929816b82 (diff) | |
| download | STC-modified-40f184e52b2903b7ff1caed5c104b9d84e2f0d52.tar.gz STC-modified-40f184e52b2903b7ff1caed5c104b9d84e2f0d52.zip | |
Some clever adjustment to coroutine state.
| -rw-r--r-- | include/stc/algo/coroutine.h | 4 | ||||
| -rw-r--r-- | misc/examples/coread.c | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h index b7ed895f..2ac17744 100644 --- a/include/stc/algo/coroutine.h +++ b/include/stc/algo/coroutine.h @@ -66,9 +66,9 @@ int main(void) { case 0: #define cco_end() \ - break; \ + *_state = 0; break; \ default: assert(!"missing cco_final: or illegal state"); \ - } *_state = -2 + } *_state *= -1 #define cco_yield(retval) \ do { \ diff --git a/misc/examples/coread.c b/misc/examples/coread.c index a9381db8..89e06b71 100644 --- a/misc/examples/coread.c +++ b/misc/examples/coread.c @@ -37,4 +37,5 @@ int main(void) { // stop after 15 lines: if (n == 15) cco_stop(&z); } + printf("state %d\n", z.cco_state); } |
