From 5180e693d90b2bbf6dea811511fe3201c3f54c1d Mon Sep 17 00:00:00 2001 From: wnstngs <64602598+wnstngs@users.noreply.github.com> Date: Wed, 7 Oct 2026 21:33:49 +0300 Subject: [PATCH] list: add list definition and drain operation --- kernel-src/include/list.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel-src/include/list.h b/kernel-src/include/list.h index 2f2812bd..6e944417 100644 --- a/kernel-src/include/list.h +++ b/kernel-src/include/list.h @@ -10,6 +10,7 @@ typedef struct _list_node { } list_node_t; #define LIST_INIT_VALUE(NAME) ((list_node_t) {.prev = &(NAME), .next = &(NAME)}) +#define LIST_DEFINE(NAME) list_node_t NAME = LIST_INIT_VALUE(NAME) static inline void list_init(list_node_t *list) { list->prev = list; @@ -73,4 +74,10 @@ static inline list_node_t *list_pop_back(list_node_t *list) { ITER != (LIST); \ ITER = NEXT, NEXT = ITER->next) +#define list_drain_front(LIST, ITER) \ + for (list_node_t *ITER = list_pop_front(LIST); ITER != NULL; ITER = list_pop_front(LIST)) + +#define list_drain_back(LIST, ITER) \ + for (list_node_t *ITER = list_pop_back(LIST); ITER != NULL; ITER = list_pop_back(LIST)) + #endif