Mercurial > hvf > hvf-old
changeset 532:c9988df57ecf
include: added tail versions of list_splice and list_last_entry
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Tue, 26 Apr 2011 14:00:24 -0400 |
parents | 055987394405 |
children | a332c4f679c7 |
files | include/list.h |
diffstat | 1 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/include/list.h Tue Apr 26 09:35:33 2011 -0400 +++ b/include/list.h Tue Apr 26 14:00:24 2011 -0400 @@ -223,6 +223,17 @@ } /** + * list_splice_tail - join two lists + * @list: the new list to add. + * @head: the place to add it before in the first list. + */ +static inline void list_splice_tail(struct list_head *list, struct list_head *head) +{ + if (!list_empty(list)) + __list_splice(list, head->prev); +} + +/** * 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. @@ -239,6 +250,22 @@ } /** + * list_splice_tail_init - join two lists and reinitialise the emptied list. + * @list: the new list to add. + * @head: the place to add it before 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(list, head->prev); + 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. @@ -259,6 +286,17 @@ list_entry((ptr)->next, type, member) /** + * list_last_entry - get the last element from a list + * @ptr: the list head to take the element from. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + * + * Note, that list is expected to be not empty. + */ +#define list_last_entry(ptr, type, member) \ + list_entry((ptr)->prev, type, member) + +/** * list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list.