diff options
Diffstat (limited to 'include/libtf/list.h')
-rw-r--r-- | include/libtf/list.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/include/libtf/list.h b/include/libtf/list.h index 22b76a8..f75a0be 100644 --- a/include/libtf/list.h +++ b/include/libtf/list.h @@ -142,7 +142,7 @@ static inline void tf_list_add_tail(struct tf_list_node *new, struct tf_list_hea tf_list_add_before(new, &head->node); } -static inline void __tf_list_del(struct tf_list_node * prev, struct tf_list_node *next) +static inline void __tf_list_del(struct tf_list_node *prev, struct tf_list_node *next) { next->prev = prev; prev->next = next; @@ -155,6 +155,14 @@ static inline void tf_list_del(struct tf_list_node *entry) entry->prev = NULL; } +static inline struct tf_list_node *tf_list_pop(struct tf_list_head *head) +{ + struct tf_list_node *n; + n = head->node.next; + tf_list_del(n); + return n; +} + static inline int tf_list_hashed(const struct tf_list_node *n) { return n->next != n && n->next != NULL; @@ -165,6 +173,29 @@ static inline int tf_list_empty(const struct tf_list_head *h) return !tf_list_hashed(&h->node); } +static inline void __tf_list_splice(const struct tf_list_head *list, + struct tf_list_node *prev, + struct tf_list_node *next) +{ + struct tf_list_node *first = list->node.next; + struct tf_list_node *last = list->node.prev; + + first->prev = prev; + prev->next = first; + + last->next = next; + next->prev = last; +} + +static inline void tf_list_splice_tail(struct tf_list_head *src, + struct tf_list_head *dst) +{ + if (!tf_list_empty(src)) { + __tf_list_splice(src, dst->node.prev, &dst->node); + tf_list_init_head(src); + } +} + #define tf_list_next(ptr, type, member) \ (tf_list_hashed(ptr) ? container_of((ptr)->next,type,member) : NULL) |