diff options
author | Michael Brown | 2016-08-31 16:05:22 +0200 |
---|---|---|
committer | Michael Brown | 2016-08-31 16:06:36 +0200 |
commit | 161c80af5bacf52a9f488551361c25be601eabb9 (patch) | |
tree | 03930a2f5121bfed2a9436c47998ce385eca2f90 /src/include | |
parent | [crypto] Generalise X.509 "valid" field to a "flags" field (diff) | |
download | ipxe-161c80af5bacf52a9f488551361c25be601eabb9.tar.gz ipxe-161c80af5bacf52a9f488551361c25be601eabb9.tar.xz ipxe-161c80af5bacf52a9f488551361c25be601eabb9.zip |
[list] Add list_next_entry() and list_prev_entry()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ipxe/list.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/include/ipxe/list.h b/src/include/ipxe/list.h index 6a9b76f9..274fb64c 100644 --- a/src/include/ipxe/list.h +++ b/src/include/ipxe/list.h @@ -349,6 +349,34 @@ extern void extern_list_splice_tail_init ( struct list_head *list, list_entry ( (list)->prev, type, member ) ) /** + * Get the container of the next entry in a list + * + * @v pos Current list entry + * @v head List head + * @v member Name of list field within iterator's type + * @ret next Next list entry, or NULL at end of list + */ +#define list_next_entry( pos, head, member ) ( { \ + typeof (pos) next = list_entry ( (pos)->member.next, \ + typeof ( *(pos) ), \ + member ); \ + ( ( &next->member == (head) ) ? NULL : next ); } ) + +/** + * Get the container of the previous entry in a list + * + * @v pos Current list entry + * @v head List head + * @v member Name of list field within iterator's type + * @ret next Next list entry, or NULL at end of list + */ +#define list_prev_entry( pos, head, member ) ( { \ + typeof (pos) prev = list_entry ( (pos)->member.prev, \ + typeof ( *(pos) ), \ + member ); \ + ( ( &prev->member == (head) ) ? NULL : prev ); } ) + +/** * Iterate over a list * * @v pos Iterator |