17#include "xtc_export.h"
32typedef intptr_t (*xtc_coro_fn)(
void *arg);
52XTC_API
int xtc_async(xtc_loop_t *loop, xtc_coro_fn fn,
void *arg,
53 xtc_task_t **out_task);
63XTC_API
int xtc_await(xtc_task_t *t, intptr_t *result);
70XTC_API
void xtc_yield(
void);
83XTC_API
void xtc_yield_set_budget(xtc_loop_t *loop, int64_t budget_ns);
84XTC_API
int xtc_yield_check(
void);
85XTC_API
int xtc_yield_if_due(
void);
86XTC_API uint64_t xtc_yield_due_count(
const xtc_loop_t *loop);
92XTC_API
size_t xtc_stack_size(
void);
93XTC_API
int xtc_set_stack_size(
size_t bytes);
121XTC_API
int xtc_stack_reclaim_enable(
size_t keep_bytes);
122XTC_API
void xtc_stack_reclaim_disable(
void);
123XTC_API
int xtc_stack_reclaim_enabled(
void);
124XTC_API uint64_t xtc_stack_reclaim_count(
void);
136#define XTC_COOP_REGION
143typedef struct xtc_pt {
147#define XTC_PT_THREAD(...) char __VA_ARGS__
148#define XTC_PT_INIT(pt) ((pt)->lc = 0)
149#define XTC_PT_BEGIN(pt) switch ((pt)->lc) { case 0:
150#define XTC_PT_END(pt) } (pt)->lc = 0; return 2
151#define XTC_PT_YIELD(pt) do { \
152 (pt)->lc = __LINE__; return 0 ; \
153 case __LINE__:; } while (0)
154#define XTC_PT_WAIT_UNTIL(pt, c) do { \
155 (pt)->lc = __LINE__; case __LINE__: \
156 if (!(c)) return 0; } while (0)
159#define XTC_PT_YIELDED 0