[list] Add list_is_first_entry() and list_is_last_entry()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2018-03-24 21:26:19 +00:00
parent ac4fbd47ae
commit 6be010d919
2 changed files with 43 additions and 0 deletions

View File

@@ -376,6 +376,28 @@ extern void extern_list_splice_tail_init ( struct list_head *list,
member ); \
( ( &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
*