From 797a77fcc8655a641630758dc4022f215008f23b Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 20 Apr 2025 12:45:42 -0600 Subject: libmisc: log.h: Add a "log_" prefix to errorf/infof/debugf --- libcr/coroutine.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'libcr/coroutine.c') diff --git a/libcr/coroutine.c b/libcr/coroutine.c index bf44219..2c605fc 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -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); -- cgit v1.2.3-2-g168b From 39d8fd2161d0a505c5b25add023aad833714b980 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 22 Apr 2025 15:06:50 -0600 Subject: Use C23 This gives us: - [[maybe_unused]] instead of [[gnu::unused]] - bool/true/false are predefined, so no need for --- libcr/coroutine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcr/coroutine.c') diff --git a/libcr/coroutine.c b/libcr/coroutine.c index 2c605fc..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 -- cgit v1.2.3-2-g168b