From 5dab625d981e0039a5d874f5d8a6f795472785bc Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Fri, 21 Feb 2025 09:02:22 -0700 Subject: Make use of the generated stack.c --- libcr/include/libcr/coroutine.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libcr/include') diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h index 756352e..2505782 100644 --- a/libcr/include/libcr/coroutine.h +++ b/libcr/include/libcr/coroutine.h @@ -29,8 +29,14 @@ #include /* for size_t */ #include /* for bool */ +/* Configuration **************************************************************/ + #include "config.h" +#ifndef CONFIG_COROUTINE_MEASURE_STACK + #error config.h must define CONFIG_COROUTINE_MEASURE_STACK (bool) +#endif + /* typedefs *******************************************************************/ /** @@ -91,8 +97,16 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, const char *name, cr_fn_t /** * Like coroutine_add_with_stack_size(), but uses a default stack size so * you don't need to think about it. + * + * Either define CONFIG_COROUTINE_STACK_SIZE_DEFAULT to use for all + * coroutines, or CONFIG_COROUTINE_STACK_SIZE_{fn} for each COROUTINE + * function. */ -cid_t coroutine_add(const char *name, cr_fn_t fn, void *args); +#ifdef CONFIG_COROUTINE_STACK_SIZE_DEFAULT +#define coroutine_add(name, fn, args) coroutine_add_with_stack_size(CONFIG_COROUTINE_STACK_SIZE_DEFAULT, name, fn, args) +#else +#define coroutine_add(name, fn, args) coroutine_add_with_stack_size(CONFIG_COROUTINE_STACK_SIZE_##fn, name, fn, args) +#endif /** * The main scheduler loop. Returns if all coroutines exit. -- cgit v1.2.3-2-g168b