VSF Documented
llist.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_LLIST_H__
2#define __VSF_LINUX_LLIST_H__
3
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10struct llist_node {
12};
13
14struct llist_head {
16};
17
18#define LLIST_HEAD_INIT(name) { NULL }
19#define LLIST_HEAD(name) struct llist_head name = LLIST_HEAD_INIT(name)
20
21static inline void init_llist_head(struct llist_head *list)
22{
23 list->first = NULL;
24}
25
26#define llist_entry(p, t, m) vsf_container_of(p, t, m)
27#define llist_for_each(pos, node) \
28 for ((pos) = (node); pos; (pos) = (pos)->next)
29#define llist_for_each_safe(pos, n, node) \
30 for ((pos) = (node); (pos) && ((n) = (pos)->next, true); (pos) = (n))
31#define llist_for_each_entry(pos, node, member) \
32 for ((pos) = llist_entry((node), typeof(*(pos)), member); \
33 member_address_is_nonnull(pos, member); \
34 (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))
35#define llist_for_each_entry_safe(pos, n, node, member) \
36 for (pos = llist_entry((node), typeof(*pos), member); \
37 member_address_is_nonnull(pos, member) && \
38 (n = llist_entry(pos->member.next, typeof(*n), member), true); \
39 pos = n)
40
41static inline bool llist_empty(const struct llist_head *head)
42{
43 return head->first == NULL;
44}
45
46static inline struct llist_node * llist_next(struct llist_node *node)
47{
48 return node->next;
49}
50
51#ifdef __cplusplus
52}
53#endif
54
55#endif
#define NULL
Definition stddef.h:52
Definition llist.h:14
struct llist_node * first
Definition llist.h:15
Definition llist.h:10
struct llist_node * next
Definition llist.h:11
uint16_t head
Definition vsf_queue.h:632