lists: add list splice tail
PATCH 1/6 lists: add list splice tail
Add a list_splice_tail variant of list_splice.
Patch-by Peter Zijlstra <[email protected]>
Signed-off-by Con Kolivas <[email protected]>
--- include/linux/list.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
include/linux/list.h +42 -0
@@ -332,6 +332,20 @@ static inline void __list_splice(struct at->prev = last; } +static inline void __list_splice_tail (struct list_head *list, +struct list_head *head) +{ +struct list_head *first = list->next; +struct list_head *last = list->prev; +struct list_head *at = head->prev; + + first->prev = at; + at->next = first; + + last->next = head; + head->prev = last; +} +/** * list_splice - join two lists * @list: the new list to add.
@@ -344,6 +358,18 @@ static inline void list_splice(struct li }/** +* list_splice_tail - join two lists at one's tail +* @list: the new list to add. +* @head: the place to add it in the first list. +*/ +static inline void list_splice_tail (struct list_head *list, +struct list_head *head) +{ +if (!list_empty (list)) +__list_splice_tail (list, head); +} + +/** * list_splice_init - join two lists and reinitialise the emptied list. * @list: the new list to add. * @head: the place to add it in the first list.
@@ -360,6 +386,22 @@ static inline void list_splice_init(stru }/** +* list_splice_init - join two lists at one's tail and reinitialise emptied +* @list: the new list to add. +* @head: the place to add it in the first list. +* +* The list at @list is reinitialised +*/ +static inline void list_splice_tail_init (struct list_head *list, +struct list_head *head) +{ +if (!list_empty (list)) { +__list_splice_tail (list, head); +INIT_LIST_HEAD (list); + } +} + +/** * list_entry - get the struct for this entry * @ptr: the &struct list_head pointer. * @type: the type of the struct this is embedded in.
Signature · 1 line
-ck
Quoted 5 lines · Con Kolivas
Add a
list_splice_tailvariant oflist_splice.Patch-by Peter Zijlstra <[email protected]>Signed-off-by Con Kolivas <[email protected]>
Acked-by Balbir Singh <[email protected]>
I had the same exact patch in my memcontrol at
http://lkml.org/lkml/2007/2/24/68 (see the last
two functions).
Signature · 4 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL
Quoted 4 lines · Con Kolivas
Add a
list_splice_tailvariant oflist_splice.Patch-by Peter Zijlstra <[email protected]>Signed-off-by Con Kolivas <[email protected]>
...
include/linux/list.h static inline void list_splice_init(stru · line 389
Quoted 5 lines
include/linux/list.h +1
-0@@ -360,6 +386,22 @@ static inline void list_splice_init(stru }/** +* list_splice_init - join two lists at one's tail and reinitialise emptied
You should update the comment to match the function.
-- Gerald
Quoted 7 lines
include/linux/list.h +7
-0+* @list: the new list to add. +* @head: the place to add it in the first list. +* +* The list at @list is reinitialised +*/ +static inline void list_splice_tail_init (struct list_head *list, +struct list_head *head)
Quoted 8 lines · Gerald Britton
Quoted 4 lines · Con Kolivas
Add a
list_splice_tailvariant oflist_splice.Patch-by Peter Zijlstra <[email protected]>Signed-off-by Con Kolivas <[email protected]>...
Quoted 8 lines
Quoted 6 lines
(quoted diff) +1
-0@@ -360,6 +386,22 @@ static inline void list_splice_init(stru } /** + * list_splice_init - join two lists at one's tail and reinitialiseemptied
You should update the comment to match the function.
Doh! Thanks. I'll fix it in the split out patches I have on my web site for now.
Signature · 1 line
-ck