diff options
author | Michael Brown | 2011-05-03 21:02:07 +0200 |
---|---|---|
committer | Michael Brown | 2011-05-03 21:02:07 +0200 |
commit | df58a19015fe6ce8ec8b6624b618d3a2d563356c (patch) | |
tree | 2e0c1f949bbe372b69fbfbc6f1b15078c637a2fa | |
parent | [netdevice] Move high-frequency debug messages to DBGLVL_EXTRA (diff) | |
download | ipxe-df58a19015fe6ce8ec8b6624b618d3a2d563356c.tar.gz ipxe-df58a19015fe6ce8ec8b6624b618d3a2d563356c.tar.xz ipxe-df58a19015fe6ce8ec8b6624b618d3a2d563356c.zip |
[list] Add list_check_contains()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r-- | src/include/ipxe/list.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/include/ipxe/list.h b/src/include/ipxe/list.h index ab4c119d..4905aaa3 100644 --- a/src/include/ipxe/list.h +++ b/src/include/ipxe/list.h @@ -212,4 +212,23 @@ static inline int list_empty ( const struct list_head *list ) { pos = tmp, \ tmp = list_entry ( tmp->member.next, typeof ( *tmp ), member ) ) +/** + * Check list contains a specified entry + * + * @v entry Entry + * @v head List head + * @v member Name of list field within iterator's type + */ +#define list_check_contains( entry, head, member ) do { \ + if ( ASSERTING ) { \ + typeof ( entry ) tmp; \ + int found = 0; \ + list_for_each_entry ( tmp, head, member ) { \ + if ( tmp == entry ) \ + found = 1; \ + } \ + assert ( found ); \ + } \ + } while ( 0 ) + #endif /* _IPXE_LIST_H */ |