aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJingbo Xu <jefflexu@linux.alibaba.com>2023-09-13 20:02:56 +0800
committerGao Xiang <hsiangkao@linux.alibaba.com>2023-09-14 17:45:11 +0800
commit18ad066c56fc046a75d4263360688286117fbe38 (patch)
tree838eab1e7e19dde1a16b0256e05185982945c306
parentd59a8ea390758feb17f31639ad3ca72fcdc54e49 (diff)
downloaderofs-utils-18ad066c56fc046a75d4263360688286117fbe38.tar.gz
erofs-utils: lib: add list_splice_tail() helper
Add list_splice_tail() helper. Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20230913120304.15741-2-jefflexu@linux.alibaba.com
-rw-r--r--include/erofs/list.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/erofs/list.h b/include/erofs/list.h
index 3f5da1a..d7a9fee 100644
--- a/include/erofs/list.h
+++ b/include/erofs/list.h
@@ -70,6 +70,26 @@ static inline int list_empty(struct list_head *head)
return head->next == head;
}
+static inline void __list_splice(struct list_head *list,
+ struct list_head *prev, struct list_head *next)
+{
+ struct list_head *first = list->next;
+ struct list_head *last = list->prev;
+
+ first->prev = prev;
+ prev->next = first;
+
+ last->next = next;
+ next->prev = last;
+}
+
+static inline void list_splice_tail(struct list_head *list,
+ struct list_head *head)
+{
+ if (!list_empty(list))
+ __list_splice(list, head->prev, head);
+}
+
#define list_entry(ptr, type, member) container_of(ptr, type, member)
#define list_first_entry(ptr, type, member) \