From 0360ef3a038c8c3f6f252fdc8f1b91e4cbdd4e39 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 13 Nov 2024 15:23:42 -0700 Subject: libcr: Start to add coroutine names --- libcr/coroutine.c | 12 +++++++----- libcr/include/libcr/coroutine.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'libcr') diff --git a/libcr/coroutine.c b/libcr/coroutine.c index 49146f1..205d0bb 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -405,7 +405,9 @@ static inline void assert_cid(cid_t cid) { /* coroutine_add() ************************************************************/ -cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args) { +cid_t coroutine_add_with_stack_size(size_t stack_size, + const char __attribute__((unused)) *name, + cr_fn_t fn, void *args) { static cid_t last_created = 0; cid_t parent = coroutine_running; @@ -413,8 +415,8 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args) { assert_cid_state(parent, state == CR_RUNNING); assert(stack_size); assert(fn); - debugf("coroutine_add_with_stack_size(%zu, %p, %p)...\n", - stack_size, fn, args); + debugf("coroutine_add_with_stack_size(%zu, \"%s\", %p, %p)...\n", + stack_size, name, fn, args); cid_t child; { @@ -470,9 +472,9 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args) { return child; } -cid_t coroutine_add(cr_fn_t fn, void *args) { +cid_t coroutine_add(const char *name, cr_fn_t fn, void *args) { return coroutine_add_with_stack_size( - CONFIG_COROUTINE_DEFAULT_STACK_SIZE, fn, args); + CONFIG_COROUTINE_DEFAULT_STACK_SIZE, name, fn, args); } /* coroutine_main() ***********************************************************/ diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h index d673fb6..95f9ba0 100644 --- a/libcr/include/libcr/coroutine.h +++ b/libcr/include/libcr/coroutine.h @@ -84,13 +84,13 @@ typedef void (*cr_fn_t)(void *args); * Returns the cid of the newly-created coroutine. May return 0 if * there are already COROUTINE_NUM active coroutines. */ -cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args); +cid_t coroutine_add_with_stack_size(size_t stack_size, const char *name, cr_fn_t fn, void *args); /** * Like coroutine_add_with_stack_size(), but uses a default stack size so * you don't need to think about it. */ -cid_t coroutine_add(cr_fn_t fn, void *args); +cid_t coroutine_add(const char *name, cr_fn_t fn, void *args); /** * The main scheduler loop. -- cgit v1.2.3-2-g168b