diff options
author | Michael Brown <mcb30@ipxe.org> | 2012-05-08 10:46:39 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2012-05-08 12:49:01 +0100 |
commit | 6ba7fb7c5cdcdfa6f32dd1a97c3ab235ffe54616 (patch) | |
tree | d8c56e623edd926736a7f6e2faa6902e893bbfce /src/include/ipxe/list.h | |
parent | 8a0331c29b950b5f940dc2157f69b5b7610460c8 (diff) | |
download | ipxe-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/list.h')
-rw-r--r-- | src/include/ipxe/list.h | 13 |
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 |