From d3c93c2cbb9ffe83a162d32b1021eb24ec703a9c Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 28 Feb 2023 08:52:37 +0100 Subject: Renamed cco_coroutine => overloaded cco_yield(coro, ctx, retval). --- include/stc/algo/coroutine.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h index 395a19cb..89ac9a35 100644 --- a/include/stc/algo/coroutine.h +++ b/include/stc/algo/coroutine.h @@ -79,18 +79,19 @@ enum { } \ return retval -#define cco_yield(retval) \ +#define cco_return \ do { \ - *_state = __LINE__; return retval; \ - case __LINE__:; \ + *_state = cco_state_final; goto cco_finish; \ } while (0) -#define cco_return \ +#define cco_yield(...) c_MACRO_OVERLOAD(cco_yield, __VA_ARGS__) +#define cco_yield_1(retval) \ do { \ - *_state = cco_state_final; goto cco_finish; \ + *_state = __LINE__; return retval; \ + case __LINE__:; \ } while (0) -#define cco_coroutine(corocall, ctx, retval) \ +#define cco_yield_3(corocall, ctx, retval) \ do { \ *_state = __LINE__; \ c_PASTE(cco, __LINE__): corocall; if (cco_alive(ctx)) return retval; \ -- cgit v1.2.3