aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-05-08 10:46:39 +0100
committerMichael Brown <mcb30@ipxe.org>2012-05-08 12:49:01 +0100
commit6ba7fb7c5cdcdfa6f32dd1a97c3ab235ffe54616 (patch)
treed8c56e623edd926736a7f6e2faa6902e893bbfce /src/include/ipxe
parent8a0331c29b950b5f940dc2157f69b5b7610460c8 (diff)
downloadipxe-6ba7fb7c5cdcdfa6f32dd1a97c3ab235ffe54616.zip
ipxe-6ba7fb7c5cdcdfa6f32dd1a97c3ab235ffe54616.tar.gz
ipxe-6ba7fb7c5cdcdfa6f32dd1a97c3ab235ffe54616.tar.bz2
[list] Add list_last_entry()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/list.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/include/ipxe/list.h b/src/include/ipxe/list.h
index 4daf12b..b14a83d 100644
--- a/src/include/ipxe/list.h
+++ b/src/include/ipxe/list.h
@@ -325,6 +325,19 @@ static inline void list_splice_tail_init ( struct list_head *list,
list_entry ( (list)->next, type, member ) )
/**
+ * Get the container of the last entry in a list
+ *
+ * @v list List head
+ * @v type Containing type
+ * @v member Name of list field within containing type
+ * @ret first First list entry, or NULL
+ */
+#define list_last_entry( list, type, member ) \
+ ( list_empty ( (list) ) ? \
+ ( type * ) NULL : \
+ list_entry ( (list)->prev, type, member ) )
+
+/**
* Iterate over a list
*
* @v pos Iterator