summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown2018-03-24 22:26:19 +0100
committerMichael Brown2018-03-24 22:32:06 +0100
commit6be010d9199df96deb3c120c19a5bd4591d9c596 (patch)
tree9295f0b459c5b41c0d532555074555f4f06b130e /src/include/ipxe
parent[tls] Ensure received data list is initialised before calling tls_free() (diff)
downloadipxe-6be010d9199df96deb3c120c19a5bd4591d9c596.tar.gz
ipxe-6be010d9199df96deb3c120c19a5bd4591d9c596.tar.xz
ipxe-6be010d9199df96deb3c120c19a5bd4591d9c596.zip
[list] Add list_is_first_entry() and list_is_last_entry()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/list.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/include/ipxe/list.h b/src/include/ipxe/list.h
index 274fb64c..8de25498 100644
--- a/src/include/ipxe/list.h
+++ b/src/include/ipxe/list.h
@@ -377,6 +377,28 @@ extern void extern_list_splice_tail_init ( struct list_head *list,
( ( &prev->member == (head) ) ? NULL : prev ); } )
/**
+ * Test if entry is first in a list
+ *
+ * @v entry List entry
+ * @v head List head
+ * @v member Name of list field within iterator's type
+ * @ret is_first Entry is first in the list
+ */
+#define list_is_first_entry( entry, head, member ) \
+ ( (head)->next == &(entry)->member )
+
+/**
+ * Test if entry is last in a list
+ *
+ * @v entry List entry
+ * @v head List head
+ * @v member Name of list field within iterator's type
+ * @ret is_last Entry is last in the list
+ */
+#define list_is_last_entry( entry, head, member ) \
+ ( (head)->prev == &(entry)->member )
+
+/**
* Iterate over a list
*
* @v pos Iterator