csnip  0.1
coro.h
Go to the documentation of this file.
1 #ifndef CSNIP_CORO_H
2 #define CSNIP_CORO_H
3 
66 #include <assert.h>
67 
84 #define CSNIP_CORO_START(pc) \
85  assert(pc != -1); \
86  switch(pc) { \
87  case 0: ;
88 
94 #define CSNIP_CORO_END(pc) \
95  break; \
96  default: \
97  assert(0); \
98  } \
99  pc = -1; \
100 
126 #define csnip_coro_Yield(pc, label, r) \
127  do { \
128  pc = label; \
129  return r; \
130  case label: ; \
131  } while(0)
132 
144 #define csnip_coro_Return(pc, r) \
145  do { \
146  pc = -1; \
147  return r; \
148  } while(0)
149 
152 #endif /* CSNIP_CORO_H */
153 
154 #if defined(CSNIP_SHORT_NAMES) && !defined(CSNIP_CORO_HAVE_SHORT_NAMES)
155 #define CORO_START CSNIP_CORO_START
156 #define CORO_END CSNIP_CORO_END
157 #define coro_Yield csnip_coro_Yield
158 #define coro_Return csnip_coro_Return
159 #endif /* CSNIP_SHORT_NAMES && !CSNIP_CORO_HAVE_SHORT_NAMES */