Linux Audio

Check our new training course

Loading...
v6.2
  1#ifndef INTERNAL_IO_SLIST_H
  2#define INTERNAL_IO_SLIST_H
  3
  4#include <linux/io_uring_types.h>
  5
 
 
 
  6#define wq_list_for_each(pos, prv, head)			\
  7	for (pos = (head)->first, prv = NULL; pos; prv = pos, pos = (pos)->next)
  8
  9#define wq_list_for_each_resume(pos, prv)			\
 10	for (; pos; prv = pos, pos = (pos)->next)
 11
 12#define wq_list_empty(list)	(READ_ONCE((list)->first) == NULL)
 13
 14#define INIT_WQ_LIST(list)	do {				\
 15	(list)->first = NULL;					\
 16} while (0)
 17
 18static 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)
 21{
 22	struct io_wq_work_node *next = pos->next;
 23
 24	pos->next = node;
 25	node->next = next;
 26	if (!next)
 27		list->last = node;
 28}
 29
 30/**
 31 * wq_list_merge - merge the second list to the first one.
 32 * @list0: the first list
 33 * @list1: the second list
 34 * Return the first node after mergence.
 35 */
 36static inline struct io_wq_work_node *wq_list_merge(struct io_wq_work_list *list0,
 37						    struct io_wq_work_list *list1)
 38{
 39	struct io_wq_work_node *ret;
 40
 41	if (!list0->first) {
 42		ret = list1->first;
 43	} else {
 44		ret = list0->first;
 45		list0->last->next = list1->first;
 46	}
 47	INIT_WQ_LIST(list0);
 48	INIT_WQ_LIST(list1);
 49	return ret;
 50}
 51
 52static inline void wq_list_add_tail(struct io_wq_work_node *node,
 53				    struct io_wq_work_list *list)
 54{
 55	node->next = NULL;
 56	if (!list->first) {
 57		list->last = node;
 58		WRITE_ONCE(list->first, node);
 59	} else {
 60		list->last->next = node;
 61		list->last = node;
 62	}
 63}
 64
 65static inline void wq_list_add_head(struct io_wq_work_node *node,
 66				    struct io_wq_work_list *list)
 67{
 68	node->next = list->first;
 69	if (!node->next)
 70		list->last = node;
 71	WRITE_ONCE(list->first, node);
 72}
 73
 74static inline void wq_list_cut(struct io_wq_work_list *list,
 75			       struct io_wq_work_node *last,
 76			       struct io_wq_work_node *prev)
 77{
 78	/* first in the list, if prev==NULL */
 79	if (!prev)
 80		WRITE_ONCE(list->first, last->next);
 81	else
 82		prev->next = last->next;
 83
 84	if (last == list->last)
 85		list->last = prev;
 86	last->next = NULL;
 87}
 88
 89static inline void __wq_list_splice(struct io_wq_work_list *list,
 90				    struct io_wq_work_node *to)
 91{
 92	list->last->next = to->next;
 93	to->next = list->first;
 94	INIT_WQ_LIST(list);
 95}
 96
 97static inline bool wq_list_splice(struct io_wq_work_list *list,
 98				  struct io_wq_work_node *to)
 99{
100	if (!wq_list_empty(list)) {
101		__wq_list_splice(list, to);
102		return true;
103	}
104	return false;
105}
106
107static inline void wq_stack_add_head(struct io_wq_work_node *node,
108				     struct io_wq_work_node *stack)
109{
110	node->next = stack->next;
111	stack->next = node;
112}
113
114static inline void wq_list_del(struct io_wq_work_list *list,
115			       struct io_wq_work_node *node,
116			       struct io_wq_work_node *prev)
117{
118	wq_list_cut(list, node, prev);
119}
120
121static inline
122struct io_wq_work_node *wq_stack_extract(struct io_wq_work_node *stack)
123{
124	struct io_wq_work_node *node = stack->next;
125
126	stack->next = node->next;
127	return node;
128}
129
130static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
131{
132	if (!work->list.next)
133		return NULL;
134
135	return container_of(work->list.next, struct io_wq_work, list);
136}
137
138#endif // 
v6.13.7
  1#ifndef INTERNAL_IO_SLIST_H
  2#define INTERNAL_IO_SLIST_H
  3
  4#include <linux/io_uring_types.h>
  5
  6#define __wq_list_for_each(pos, head)				\
  7	for (pos = (head)->first; pos; pos = (pos)->next)
  8
  9#define wq_list_for_each(pos, prv, head)			\
 10	for (pos = (head)->first, prv = NULL; pos; prv = pos, pos = (pos)->next)
 11
 12#define wq_list_for_each_resume(pos, prv)			\
 13	for (; pos; prv = pos, pos = (pos)->next)
 14
 15#define wq_list_empty(list)	(READ_ONCE((list)->first) == NULL)
 16
 17#define INIT_WQ_LIST(list)	do {				\
 18	(list)->first = NULL;					\
 19} while (0)
 20
 21static inline void wq_list_add_after(struct io_wq_work_node *node,
 22				     struct io_wq_work_node *pos,
 23				     struct io_wq_work_list *list)
 24{
 25	struct io_wq_work_node *next = pos->next;
 26
 27	pos->next = node;
 28	node->next = next;
 29	if (!next)
 30		list->last = node;
 31}
 32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 33static inline void wq_list_add_tail(struct io_wq_work_node *node,
 34				    struct io_wq_work_list *list)
 35{
 36	node->next = NULL;
 37	if (!list->first) {
 38		list->last = node;
 39		WRITE_ONCE(list->first, node);
 40	} else {
 41		list->last->next = node;
 42		list->last = node;
 43	}
 44}
 45
 46static inline void wq_list_add_head(struct io_wq_work_node *node,
 47				    struct io_wq_work_list *list)
 48{
 49	node->next = list->first;
 50	if (!node->next)
 51		list->last = node;
 52	WRITE_ONCE(list->first, node);
 53}
 54
 55static inline void wq_list_cut(struct io_wq_work_list *list,
 56			       struct io_wq_work_node *last,
 57			       struct io_wq_work_node *prev)
 58{
 59	/* first in the list, if prev==NULL */
 60	if (!prev)
 61		WRITE_ONCE(list->first, last->next);
 62	else
 63		prev->next = last->next;
 64
 65	if (last == list->last)
 66		list->last = prev;
 67	last->next = NULL;
 68}
 69
 70static inline void __wq_list_splice(struct io_wq_work_list *list,
 71				    struct io_wq_work_node *to)
 72{
 73	list->last->next = to->next;
 74	to->next = list->first;
 75	INIT_WQ_LIST(list);
 76}
 77
 78static inline bool wq_list_splice(struct io_wq_work_list *list,
 79				  struct io_wq_work_node *to)
 80{
 81	if (!wq_list_empty(list)) {
 82		__wq_list_splice(list, to);
 83		return true;
 84	}
 85	return false;
 86}
 87
 88static inline void wq_stack_add_head(struct io_wq_work_node *node,
 89				     struct io_wq_work_node *stack)
 90{
 91	node->next = stack->next;
 92	stack->next = node;
 93}
 94
 95static inline void wq_list_del(struct io_wq_work_list *list,
 96			       struct io_wq_work_node *node,
 97			       struct io_wq_work_node *prev)
 98{
 99	wq_list_cut(list, node, prev);
100}
101
102static inline
103struct io_wq_work_node *wq_stack_extract(struct io_wq_work_node *stack)
104{
105	struct io_wq_work_node *node = stack->next;
106
107	stack->next = node->next;
108	return node;
109}
110
111static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
112{
113	if (!work->list.next)
114		return NULL;
115
116	return container_of(work->list.next, struct io_wq_work, list);
117}
118
119#endif // INTERNAL_IO_SLIST_H