summaryrefslogtreecommitdiffhomepage
path: root/include/stc/algo/coroutine.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/stc/algo/coroutine.h')
-rw-r--r--include/stc/algo/coroutine.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h
index c3f36ac2..78dc80c6 100644
--- a/include/stc/algo/coroutine.h
+++ b/include/stc/algo/coroutine.h
@@ -76,9 +76,13 @@ enum {
*_state = cco_state_done; \
return ret
+#define cco(co) \
+ for (int *_state = &(co)->cco_state, _once=1; _once; *_state = cco_state_done, _once=0) \
+ _begin: switch (*_state) case 0:
+
#define cco_yield(ret) \
do { \
- *_state = __LINE__; return ret; \
+ *_state = __LINE__; return ret; goto _begin; \
case __LINE__:; \
} while (0)