50 #define MBG_KLIST_INIT(name) { &(name), &(name) } 52 #define MBG_KLIST_DECLARE(name) \ 53 struct mbg_klist_head name = MBG_KLIST_INIT(name) 55 #define mbg_klist_for_each(head, pos) \ 56 for (pos = (head)->next; pos != (head); pos = pos->next) 58 #define mbg_klist_for_each_safe(head, pos, n) \ 59 for (pos = (head)->next, n = (pos)->next; \ 61 pos = n, n = pos->next) 63 #define mbg_klist_for_each_rev(head, pos) \ 64 for (pos = (head)->prev; pos != (head); pos = pos->prev) 66 #define mbg_klist_for_each_rev_safe(head, pos, n) \ 67 for (pos = (head)->prev, n = (pos)->prev; \ 69 pos = n, n = pos->prev) 71 #define mbg_klist_nth_item(head, pos, n) \ 74 for (pos = (head)->next, i = 0; i < n; pos = pos->next, ++i); \ 77 #define mbg_klist_entry(ptr, type, member) \ 78 mbg_container_of(ptr, type, member) 80 #define mbg_klist_first_entry(ptr, type, member) \ 81 mbg_klist_entry((ptr)->next, type, member) 83 #define mbg_klist_last_entry(ptr, type, member) \ 84 mbg_klist_entry((ptr)->prev, type, member) 88 #if defined( __GNUC__ ) || defined( __clang__ ) // "typeof" supported 90 #define mbg_klist_next_entry(pos, member) \ 91 mbg_klist_entry((pos)->member.next, typeof(*pos), member) 93 #define mbg_klist_prev_entry(pos, member) \ 94 mbg_klist_entry((pos)->member.prev, typeof(*pos), member) 96 #define mbg_klist_for_each_entry(head, pos, member) \ 97 for (pos = mbg_klist_first_entry(head, typeof(*pos), member); \ 98 &pos->member != (head); \ 99 pos = mbg_klist_next_entry(pos, member)) 101 #define mbg_klist_for_each_entry_rev(head, pos, member) \ 102 for (pos = mbg_klist_last_entry(head, typeof(*pos), member); \ 103 &pos->member != (head); \ 104 pos = mbg_klist_prev_entry(pos, member)) 106 #define mbg_klist_for_each_entry_safe(head, pos, n, member) \ 107 for (pos = mbg_klist_first_entry(head, typeof(*pos), member), \ 108 n = mbg_klist_next_entry(pos, member); \ 109 &pos->member != (head); \ 110 pos = n, n = mbg_klist_next_entry(pos, member)) 112 #define mbg_klist_for_each_entry_rev_safe(head, pos, n, member) \ 113 for (pos = mbg_klist_last_entry(head, typeof(*pos), member), \ 114 n = mbg_klist_prev_entry(pos, member); \ 115 &pos->member != (head); \ 116 pos = n, n = mbg_klist_prev_entry(pos, member)) 222 return ( ( item->
prev == head ) ? 1 : 0 );
229 return ( ( item->
next == head ) ? 1 : 0 );
236 return ( ( head->
next == head ) ? 1 : 0 );
static __mbg_inline void mbg_klist_append_list(struct mbg_klist_head *head, const struct mbg_klist_head *list)
static __mbg_inline int mbg_klist_is_empty(const struct mbg_klist_head *head)
static __mbg_inline void __mbg_klist_add_item(struct mbg_klist_head *item, struct mbg_klist_head *prev, struct mbg_klist_head *next)
static __mbg_inline void mbg_klist_move_append_item(struct mbg_klist_head *head, struct mbg_klist_head *item)
static __mbg_inline void mbg_klist_append_item(struct mbg_klist_head *head, struct mbg_klist_head *item)
static __mbg_inline void mbg_klist_replace_item(struct mbg_klist_head *old, struct mbg_klist_head *item)
static __mbg_inline void mbg_klist_append_list_init(struct mbg_klist_head *head, struct mbg_klist_head *list)
static __mbg_inline void mbg_klist_init(struct mbg_klist_head *head)
static __mbg_inline int mbg_klist_is_first(const struct mbg_klist_head *head, const struct mbg_klist_head *item)
struct mbg_klist_head * next
static __mbg_inline int mbg_klist_is_last(const struct mbg_klist_head *head, const struct mbg_klist_head *item)
static __mbg_inline void mbg_klist_replace_item_init(struct mbg_klist_head *old, struct mbg_klist_head *item)
static __mbg_inline void mbg_klist_prepend_item(struct mbg_klist_head *head, struct mbg_klist_head *item)
void mbg_klist_sort(void *priv, struct mbg_klist_head *head, int(*cmp)(void *priv, struct mbg_klist_head *a, struct mbg_klist_head *b))
Sort a list.
static __mbg_inline void mbg_klist_move_prepend_item(struct mbg_klist_head *head, struct mbg_klist_head *item)
struct mbg_klist_head * prev
static __mbg_inline void mbg_klist_prepend_list(struct mbg_klist_head *head, const struct mbg_klist_head *list)
static __mbg_inline void mbg_klist_delete_item_init(struct mbg_klist_head *item)
static __mbg_inline void mbg_klist_delete_item(struct mbg_klist_head *item)
static __mbg_inline void __mbg_klist_delete_item(struct mbg_klist_head *prev, struct mbg_klist_head *next)
static __mbg_inline void __mbg_klist_add_list(const struct mbg_klist_head *list, struct mbg_klist_head *prev, struct mbg_klist_head *next)
static __mbg_inline void mbg_klist_prepend_list_init(struct mbg_klist_head *head, struct mbg_klist_head *list)