summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-03-05 01:22:13 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2013-03-05 01:22:13 +0100
commit3c7956e45acc0b7d73f03bee4daa9805af01f680 (patch)
treefdcadf94c11e82000aa3d798b70a777d390ae238 /src
parentb8f58fea9caed09cfbceea713389a93b02d59d42 (diff)
shl: dlist: add _first/_last helpers
These helpers return the first and last elements respectively. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/shl_dlist.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shl_dlist.h b/src/shl_dlist.h
index c1d4beb..9e30dc5 100644
--- a/src/shl_dlist.h
+++ b/src/shl_dlist.h
@@ -102,6 +102,12 @@ static inline bool shl_dlist_empty(struct shl_dlist *head)
#define shl_dlist_entry(ptr, type, member) \
shl_offsetof((ptr), type, member)
+#define shl_dlist_first(head, type, member) \
+ shl_dlist_entry((head)->next, type, member)
+
+#define shl_dlist_last(head, type, member) \
+ shl_dlist_entry((head)->prev, type, member)
+
#define shl_dlist_for_each(iter, head) \
for (iter = (head)->next; iter != (head); iter = iter->next)