diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-04-18 13:30:03 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-04-18 13:30:03 -0700 |
commit | 392c9aff947a41e7e0da0b1a9612e174cfa956a7 (patch) | |
tree | ae45404b07da46490c6dcd0a09b82fd3a3dcf2e3 /src/coro.c | |
parent | 1d188c4f816fce8728fdffaa7ad6ef205ca05abd (diff) |
test: added prime sieve test of coroutines
Diffstat (limited to 'src/coro.c')
-rw-r--r-- | src/coro.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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); |