From 392c9aff947a41e7e0da0b1a9612e174cfa956a7 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sat, 18 Apr 2020 13:30:03 -0700 Subject: test: added prime sieve test of coroutines --- src/coro.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/coro.c') 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 // ----------------------------------------------------------------------- -// 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); -- cgit v1.2.1