diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-04 14:09:28 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-04 18:33:50 -0700 |
commit | a7c299d825038237c63cca919aec6de6be69c4db (patch) | |
tree | 4b2ab1dc25b3aeba1bf5e98c6c743ebf832907f4 /libcr/include | |
parent | 65f2a6fb8797385e06e61e13bac7a33d27f2097d (diff) |
libcr: Flesh out cr_cid_info, clarify stack bounds
Diffstat (limited to 'libcr/include')
-rw-r--r-- | libcr/include/libcr/coroutine.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h index eb5828b..756352e 100644 --- a/libcr/include/libcr/coroutine.h +++ b/libcr/include/libcr/coroutine.h @@ -1,6 +1,6 @@ /* libcr/coroutine.h - Simple embeddable coroutine implementation * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -29,6 +29,8 @@ #include <stddef.h> /* for size_t */ #include <stdbool.h> /* for bool */ +#include "config.h" + /* typedefs *******************************************************************/ /** @@ -187,13 +189,25 @@ void cr_assert_in_intrhandler(void); /* answering questions about coroutines ***************************************/ -/* While the following are defined here unconditionally, the - * implementations are #if'd on CONFIG_COROUTINE_MEASURE_STACK. */ +enum coroutine_state { + CR_NONE = 0, /* this slot in the table is empty */ + CR_INITIALIZING, /* running, before cr_begin() */ + CR_RUNNING, /* running, after cr_begin() */ + CR_RUNNABLE, /* not running, but runnable */ + CR_PAUSED, /* not running, and not runnable */ +}; + +const char *coroutine_state_str(enum coroutine_state); struct cr_cid_info { + enum coroutine_state state; + [[gnu::nonstring]] char name[CONFIG_COROUTINE_NAME_LEN]; + +#if CONFIG_COROUTINE_MEASURE_STACK size_t stack_cap; size_t stack_max; size_t stack_cur; +#endif }; void cr_cid_info(cid_t cid, struct cr_cid_info *ret); |