From 6ba7fb7c5cdcdfa6f32dd1a97c3ab235ffe54616 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 8 May 2012 10:46:39 +0100 Subject: [list] Add list_last_entry() Signed-off-by: Michael Brown --- src/include/ipxe/list.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/include') diff --git a/src/include/ipxe/list.h b/src/include/ipxe/list.h index 4daf12b2e..b14a83d70 100644 --- a/src/include/ipxe/list.h +++ b/src/include/ipxe/list.h @@ -324,6 +324,19 @@ static inline void list_splice_tail_init ( struct list_head *list, ( type * ) NULL : \ 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 * -- cgit v1.2.3-55-g7522