From 03113da787fb1617a9c460b9ce012c9efe3c7838 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 15 Apr 2025 01:53:37 -0600 Subject: libmisc: Tidy linkedlist.h --- libcr_ipc/mutex.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libcr_ipc/mutex.c') diff --git a/libcr_ipc/mutex.c b/libcr_ipc/mutex.c index b0ebe05..4a87a58 100644 --- a/libcr_ipc/mutex.c +++ b/libcr_ipc/mutex.c @@ -5,6 +5,7 @@ */ #include /* for cid_t, cr_* */ +#include #define IMPLEMENTATION_FOR_LIBCR_IPC_MUTEX_H YES #include -- cgit v1.2.3-2-g168b From 32a1b710b40ce9d53cd0a7bc0c183da87e07f397 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 15 Apr 2025 08:41:54 -0600 Subject: libmisc: Rework linkedlist to be non-intrusive --- libcr_ipc/mutex.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libcr_ipc/mutex.c') diff --git a/libcr_ipc/mutex.c b/libcr_ipc/mutex.c index 4a87a58..1b4e626 100644 --- a/libcr_ipc/mutex.c +++ b/libcr_ipc/mutex.c @@ -11,9 +11,9 @@ #include struct cr_mutex_waiter { - lm_sll_node; cid_t cid; }; +SLIST_DECLARE_NODE(_cr_mutex_waiter_list, struct cr_mutex_waiter); void cr_mutex_lock(cr_mutex_t *mu) { assert(mu); @@ -22,10 +22,10 @@ void cr_mutex_lock(cr_mutex_t *mu) { if (!mu->locked) /* non-blocking fast-path */ mu->locked = true; else { /* blocking slow-path */ - struct cr_mutex_waiter self = { + struct _cr_mutex_waiter_list_node self = { .val = { .cid = cr_getcid(), - }; - lm_sll_push_to_rear(&mu->waiters, &self); + }}; + slist_push_to_rear(&mu->waiters, &self); cr_pause_and_yield(); } assert(mu->locked); @@ -37,8 +37,8 @@ void cr_mutex_unlock(cr_mutex_t *mu) { assert(mu->locked); if (mu->waiters.front) { - cr_unpause(lm_sll_node_cast(struct cr_mutex_waiter, mu->waiters.front)->cid); - lm_sll_pop_from_front(&mu->waiters); + cr_unpause(mu->waiters.front->val.cid); + slist_pop_from_front(&mu->waiters); } else mu->locked = false; } -- cgit v1.2.3-2-g168b