1 #ifndef INTERNAL_IO_SLIST_H
2 #define INTERNAL_IO_SLIST_H
4 #include <linux/io_uring_types.h>
6 #define wq_list_for_each(pos, prv, head) \
7 for (pos = (head)->first, prv = NULL; pos; prv = pos, pos = (pos)->next)
9 #define wq_list_for_each_resume(pos, prv) \
10 for (; pos; prv = pos, pos = (pos)->next)
12 #define wq_list_empty(list) (READ_ONCE((list)->first) == NULL)
14 #define INIT_WQ_LIST(list) do { \
15 (list)->first = NULL; \
18 static inline void wq_list_add_after(struct io_wq_work_node *node,
19 struct io_wq_work_node *pos,
20 struct io_wq_work_list *list)
22 struct io_wq_work_node *next = pos->next;
30 static inline void wq_list_add_tail(struct io_wq_work_node *node,
31 struct io_wq_work_list *list)
36 WRITE_ONCE(list->first, node);
38 list->last->next = node;
43 static inline void wq_list_add_head(struct io_wq_work_node *node,
44 struct io_wq_work_list *list)
46 node->next = list->first;
49 WRITE_ONCE(list->first, node);
52 static inline void wq_list_cut(struct io_wq_work_list *list,
53 struct io_wq_work_node *last,
54 struct io_wq_work_node *prev)
56 /* first in the list, if prev==NULL */
58 WRITE_ONCE(list->first, last->next);
60 prev->next = last->next;
62 if (last == list->last)
67 static inline void __wq_list_splice(struct io_wq_work_list *list,
68 struct io_wq_work_node *to)
70 list->last->next = to->next;
71 to->next = list->first;
75 static inline bool wq_list_splice(struct io_wq_work_list *list,
76 struct io_wq_work_node *to)
78 if (!wq_list_empty(list)) {
79 __wq_list_splice(list, to);
85 static inline void wq_stack_add_head(struct io_wq_work_node *node,
86 struct io_wq_work_node *stack)
88 node->next = stack->next;
92 static inline void wq_list_del(struct io_wq_work_list *list,
93 struct io_wq_work_node *node,
94 struct io_wq_work_node *prev)
96 wq_list_cut(list, node, prev);
100 struct io_wq_work_node *wq_stack_extract(struct io_wq_work_node *stack)
102 struct io_wq_work_node *node = stack->next;
104 stack->next = node->next;
108 static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
110 if (!work->list.next)
113 return container_of(work->list.next, struct io_wq_work, list);
116 #endif // INTERNAL_IO_SLIST_H