summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-27 08:17:08 +0100
committerTyge Løvset <[email protected]>2023-02-27 08:17:08 +0100
commit75b57e30c8dd7a0598ae80b703faceb07908c3ed (patch)
treebe66be657879d8720be9e6eab2cd7c688e722fa4 /include/stc
parent1871ee8e9b4ca4edde387be973035c259fc9191f (diff)
downloadSTC-modified-75b57e30c8dd7a0598ae80b703faceb07908c3ed.tar.gz
STC-modified-75b57e30c8dd7a0598ae80b703faceb07908c3ed.zip
Simplified coroutine.h a bit and modified coroutines.c
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/algo/coroutine.h20
1 files changed, 2 insertions, 18 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h
index 7ea53a0c..66b54366 100644
--- a/include/stc/algo/coroutine.h
+++ b/include/stc/algo/coroutine.h
@@ -61,15 +61,14 @@ int main(void) {
#include <stc/ccommon.h>
#define cco_begin(c) \
- int *_state = &(c)->cco_state, _nodyn; \
+ int *_state = &(c)->cco_state; \
switch (*_state) { \
case 0:
#define cco_end() \
*_state = 0; break; \
default: assert(!"missing cco_final: or illegal state"); \
- } \
- *_state *= -1; (void)_nodyn
+ }
#define cco_yield(retval) \
do { \
@@ -88,19 +87,4 @@ int main(void) {
#define cco_alive(c) ((c) && (c)->cco_state > 0)
#define cco_stop(c) ((c)->cco_state = (c)->cco_state ? -1 : -2, c)
-// ---------------------------------------------------------------
-
-#define cco_begin_dyn(cp) \
- if (!*(cp)) *(cp) = malloc(sizeof **(cp)), (*(cp))->cco_state = 0; \
- int* _state = &(*(cp))->cco_state, _dyn; \
- switch (*_state) { \
- case 0:
-
-#define cco_end_dyn(cp) \
- *_state = 0; break; \
- default: assert(!"missing cco_final: or illegal state"); \
- } \
- *_state *= -1; (void)_dyn; \
- free(*(cp)); *(cp) = NULL
-
#endif