summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-06-21 09:11:49 +0200
committerTyge Lovset <[email protected]>2023-06-21 09:11:49 +0200
commit08f75cf88252a3a95ee8eb8464295bcd177ec74f (patch)
treeaff109cbeef3487a69a879e0e5b39daf6ead3c19 /include
parentbc6b781548c10935ec6e72e42ece905f46105ec3 (diff)
downloadSTC-modified-08f75cf88252a3a95ee8eb8464295bcd177ec74f.tar.gz
STC-modified-08f75cf88252a3a95ee8eb8464295bcd177ec74f.zip
Fixed cco_switch: emulation of switch inside coroutines.
Diffstat (limited to 'include')
-rw-r--r--include/stc/algo/coroutine.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h
index a2496d25..e0cf5488 100644
--- a/include/stc/algo/coroutine.h
+++ b/include/stc/algo/coroutine.h
@@ -66,9 +66,9 @@ enum {
#define cco_initial(co) ((co)->cco_state == 0)
#define cco_done(co) ((co)->cco_state == cco_state_done)
-/* Always use { } after cco_switch(x), cco_case(val), and cco_default. */
-#define cco_switch(x) for (intmax_t _sw = (intmax_t)(x), _once=1; _once; _once=0)
-#define cco_case(val) if (_sw == (intmax_t)(val))
+/* Emulate switch in coro: always use { } after cco_case(val) and cco_default. */
+#define cco_switch(x) for (long long _sw = (long long)(x), _b=0; !_b; _b=1)
+#define cco_case(val) if (_b |= _sw == (val))
#define cco_default
#define cco_routine(co) \