summaryrefslogtreecommitdiff
path: root/libcr
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-26 19:51:52 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-06 11:50:46 -0600
commit1cf085ae086a43f18af550fdcfd4d3e57ccb0918 (patch)
tree42abde5f3b34b239bb95e84200ea16ad4a4c562d /libcr
parent0fec22d4106ff6f80296d1511eec7a82160c2245 (diff)
parenta83c95e9f46ef695a55fc7a6911e11846da9903c (diff)
Merge branch 'lukeshu/misc'
Diffstat (limited to 'libcr')
-rw-r--r--libcr/coroutine.c36
-rw-r--r--libcr/include/libcr/coroutine.h1
2 files changed, 18 insertions, 19 deletions
diff --git a/libcr/coroutine.c b/libcr/coroutine.c
index bf44219..cf63122 100644
--- a/libcr/coroutine.c
+++ b/libcr/coroutine.c
@@ -349,7 +349,7 @@ static_assert(CONFIG_COROUTINE_NUM > 1);
uintptr_t sp;
#endif
} cr_plat_jmp_buf;
- static void _cr_plat_setjmp_pre(cr_plat_jmp_buf *env [[gnu::unused]]) {
+ static void _cr_plat_setjmp_pre(cr_plat_jmp_buf *env [[maybe_unused]]) {
#if CONFIG_COROUTINE_MEASURE_STACK
env->sp = cr_plat_get_sp();
#endif
@@ -556,8 +556,8 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
assert_cid_state(parent, state == CR_RUNNING);
assert(stack_size);
assert(fn);
- debugf("coroutine_add_with_stack_size(%zu, \"%s\", %p, %p)...",
- stack_size, name, fn, args);
+ log_debugf("coroutine_add_with_stack_size(%zu, \"%s\", %p, %p)...",
+ stack_size, name, fn, args);
if (!coroutine_initialized) {
cr_plat_init();
@@ -567,7 +567,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
cid_t child = coroutine_allocate_cid();
if (!child)
return 0;
- debugf("...child=%zu", child);
+ log_debugf("...child=%zu", child);
/* 1. state *************************************************/
coroutine_table[child-1].state = CR_INITIALIZING;
@@ -580,13 +580,13 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
/* 3. stack *************************************************/
coroutine_table[child-1].stack_size = stack_size + 2*CR_STACK_GUARD_SIZE;
- infof("allocing \"%s\" stack with size %zu+2*%zu=%zu",
- name, stack_size, CR_STACK_GUARD_SIZE, coroutine_table[child-1].stack_size);
+ log_infof("allocing \"%s\" stack with size %zu+2*%zu=%zu",
+ name, stack_size, CR_STACK_GUARD_SIZE, coroutine_table[child-1].stack_size);
coroutine_table[child-1].stack =
aligned_alloc(CR_PLAT_STACK_ALIGNMENT, coroutine_table[child-1].stack_size);
- infof("... done, stack is [0x%p,0x%p)",
- coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE,
- coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE + stack_size);
+ log_infof("... done, stack is [0x%p,0x%p)",
+ coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE,
+ coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE + stack_size);
#if CONFIG_COROUTINE_MEASURE_STACK || CONFIG_COROUTINE_PROTECT_STACK
for (size_t i = 0; i < coroutine_table[child-1].stack_size; i++)
((uint8_t *)coroutine_table[child-1].stack)[i] =
@@ -608,8 +608,8 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
+ stack_size
#endif
;
- debugf("...stack =%p", coroutine_table[child-1].stack);
- debugf("...stack_base=%p", stack_base);
+ log_debugf("...stack =%p", coroutine_table[child-1].stack);
+ log_debugf("...stack_base=%p", stack_base);
/* run until cr_begin() */
cr_plat_call_with_stack(stack_base, fn, args);
assert_notreached("should cr_begin() instead of returning");
@@ -630,7 +630,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size,
/* coroutine_main() ***********************************************************/
void coroutine_main(void) {
- debugf("coroutine_main()");
+ log_debugf("coroutine_main()");
if (!coroutine_initialized) {
cr_plat_init();
coroutine_initialized = true;
@@ -675,7 +675,7 @@ void coroutine_main(void) {
/* cr_*() *********************************************************************/
void cr_begin(void) {
- debugf("cid=%zu: cr_begin()", coroutine_running);
+ log_debugf("cid=%zu: cr_begin()", coroutine_running);
assert_cid_state(coroutine_running, state == CR_INITIALIZING);
bool saved = cr_save_and_disable_interrupts();
@@ -707,7 +707,7 @@ static inline void _cr_yield() {
}
void cr_yield(void) {
- debugf("cid=%zu: cr_yield()", coroutine_running);
+ log_debugf("cid=%zu: cr_yield()", coroutine_running);
assert(!cr_plat_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
@@ -719,7 +719,7 @@ void cr_yield(void) {
}
void cr_pause_and_yield(void) {
- debugf("cid=%zu: cr_pause_and_yield()", coroutine_running);
+ log_debugf("cid=%zu: cr_pause_and_yield()", coroutine_running);
assert(!cr_plat_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
@@ -730,7 +730,7 @@ void cr_pause_and_yield(void) {
}
[[noreturn]] void cr_exit(void) {
- debugf("cid=%zu: cr_exit()", coroutine_running);
+ log_debugf("cid=%zu: cr_exit()", coroutine_running);
assert(!cr_plat_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
@@ -747,7 +747,7 @@ static void _cr_unpause(cid_t cid) {
}
void cr_unpause(cid_t cid) {
- debugf("cr_unpause(%zu)", cid);
+ log_debugf("cr_unpause(%zu)", cid);
assert(!cr_plat_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
@@ -757,7 +757,7 @@ void cr_unpause(cid_t cid) {
}
void cr_unpause_from_intrhandler(cid_t cid) {
- debugf("cr_unpause_from_intrhandler(%zu)", cid);
+ log_debugf("cr_unpause_from_intrhandler(%zu)", cid);
assert(cr_plat_is_in_intrhandler());
_cr_unpause(cid);
diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h
index 2505782..f72dc96 100644
--- a/libcr/include/libcr/coroutine.h
+++ b/libcr/include/libcr/coroutine.h
@@ -27,7 +27,6 @@
#define _LIBCR_COROUTINE_H_
#include <stddef.h> /* for size_t */
-#include <stdbool.h> /* for bool */
/* Configuration **************************************************************/