include/list: add list_entry_is_first() and list_count_entries()
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
3bb882be44
commit
7ca122ba84
|
@ -136,6 +136,16 @@ _INLINE_ int list_entry_is_last(struct list_head *entry, struct list_head *head)
|
||||||
return head->prev == entry;
|
return head->prev == entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_entry_is_first - tests whether is entry first in the list
|
||||||
|
* @entry: the entry to test.
|
||||||
|
* @head: the list to test.
|
||||||
|
*/
|
||||||
|
_INLINE_ int list_entry_is_first(struct list_head *entry, struct list_head *head)
|
||||||
|
{
|
||||||
|
return head->next == entry;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list_splice - join two lists
|
* list_splice - join two lists
|
||||||
* @list: the new list to add.
|
* @list: the new list to add.
|
||||||
|
@ -198,6 +208,17 @@ _INLINE_ void list_splice(struct list_head *list, struct list_head *head)
|
||||||
for (pos = (head)->next, pnext = pos->next; pos != (head); \
|
for (pos = (head)->next, pnext = pos->next; pos != (head); \
|
||||||
pos = pnext, pnext = pos->next)
|
pos = pnext, pnext = pos->next)
|
||||||
|
|
||||||
|
_INLINE_ size_t list_count_entries(struct list_head *head)
|
||||||
|
{
|
||||||
|
struct list_head *pos;
|
||||||
|
size_t ct = 0;
|
||||||
|
|
||||||
|
list_for_each(pos, head)
|
||||||
|
ct++;
|
||||||
|
|
||||||
|
return ct;
|
||||||
|
}
|
||||||
|
|
||||||
#define MAX_LIST_LENGTH_BITS 20
|
#define MAX_LIST_LENGTH_BITS 20
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue