aboutsummaryrefslogtreecommitdiff
path: root/src/coro.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-04-18 13:30:03 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-04-18 13:30:03 -0700
commit392c9aff947a41e7e0da0b1a9612e174cfa956a7 (patch)
treeae45404b07da46490c6dcd0a09b82fd3a3dcf2e3 /src/coro.c
parent1d188c4f816fce8728fdffaa7ad6ef205ca05abd (diff)
test: added prime sieve test of coroutines
Diffstat (limited to 'src/coro.c')
-rw-r--r--src/coro.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/coro.c b/src/coro.c
index 82ef4f4..af0a359 100644
--- a/src/coro.c
+++ b/src/coro.c
@@ -1,11 +1,20 @@
#include <u.h>
// -----------------------------------------------------------------------
-// Assembly routines.
+// Assembly routines
extern void _newcoro(coro *co, uintptr (*func)(coro*, uintptr), void *stk);
extern uintptr _coroyield(coro *co, uintptr arg);
+// -----------------------------------------------------------------------
+// Globals
+
+// static thread_local coro *CONTEXT;
+
+// -----------------------------------------------------------------------
+// C interface
+
+/* Co-routine context */
struct coro
{
void* sp;
@@ -17,9 +26,7 @@ struct coro
coro*
coro·new(uintptr stk, uintptr (*func)(coro*, uintptr))
{
- if (!func)
- return nil;
-
+ if (!func) return nil;
if (stk == 0) stk = 8192;
byte *block = malloc(stk);