summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKarel Zak2018-12-07 11:37:24 +0100
committerKarel Zak2018-12-07 12:33:34 +0100
commit7ca122ba843db03d734fdc3f63cfca98a3817fdf (patch)
tree16d7bd97ef252e02c51bdca95c2c81cfaa81a260 /include
parentlibsmartcols: split print.c into print.c, put.c and print-api.c (diff)
downloadkernel-qcow2-util-linux-7ca122ba843db03d734fdc3f63cfca98a3817fdf.tar.gz
kernel-qcow2-util-linux-7ca122ba843db03d734fdc3f63cfca98a3817fdf.tar.xz
kernel-qcow2-util-linux-7ca122ba843db03d734fdc3f63cfca98a3817fdf.zip
include/list: add list_entry_is_first() and list_count_entries()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/list.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/list.h b/include/list.h
index f3ffc7985..96c84e572 100644
--- a/include/list.h
+++ b/include/list.h
@@ -137,6 +137,16 @@ _INLINE_ int list_entry_is_last(struct list_head *entry, struct list_head *head)
}
/**
+ * 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: the new list to add.
* @head: the place to add it in the first list.
@@ -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); \
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
/*