Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C coroutines

Name: Anonymous 2019-02-08 10:27

#ifndef COROUTINE_H
#define COROUTINE_H

#include <stdlib.h>

/*
* `scr' macros for static coroutines.
*/

#define scrBegin static int scrLine = 0; switch(scrLine) { case 0:;
#define scrFinish(z) } return (z)
#define scrFinishV } return

#define scrReturn(z) \
do {\
scrLine=__LINE__;\
return (z); case __LINE__:;\
} while (0)
#define scrReturnV \
do {\
scrLine=__LINE__;\
return; case __LINE__:;\
} while (0)

/*
* `ccr' macros for re-entrant coroutines.
*/

#define ccrContParam void **ccrParam

#define ccrBeginContext struct ccrContextTag { int ccrLine
#define ccrEndContext(x) } *x = (struct ccrContextTag *)*ccrParam

#define ccrBegin(x) if(!x) {x= *ccrParam=malloc(sizeof(*x)); x->ccrLine=0;}\
if (x) switch(x->ccrLine) { case 0:;
#define ccrFinish(z) } free(*ccrParam); *ccrParam=0; return (z)
#define ccrFinishV } free(*ccrParam); *ccrParam=0; return

#define ccrReturn(z) \
do {\
((struct ccrContextTag *)*ccrParam)->ccrLine=__LINE__;\
return (z); case __LINE__:;\
} while (0)
#define ccrReturnV \
do {\
((struct ccrContextTag *)*ccrParam)->ccrLine=__LINE__;\
return; case __LINE__:;\
} while (0)

#define ccrStop(z) do{ free(*ccrParam); *ccrParam=0; return (z); }while(0)
#define ccrStopV do{ free(*ccrParam); *ccrParam=0; return; }while(0)

#define ccrContext void *
#define ccrAbort(ctx) do { free (ctx); ctx = 0; } while (0)

#endif /* COROUTINE_H */

Name: Anonymous 2019-02-08 11:03

FREEZE MY ANUS

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List