Browse Source

[list] Add list_check_contains()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
df58a19015
1 changed files with 19 additions and 0 deletions
  1. 19
    0
      src/include/ipxe/list.h

+ 19
- 0
src/include/ipxe/list.h View File

212
 	      pos = tmp,						      \
212
 	      pos = tmp,						      \
213
 	      tmp = list_entry ( tmp->member.next, typeof ( *tmp ), member ) )
213
 	      tmp = list_entry ( tmp->member.next, typeof ( *tmp ), member ) )
214
 
214
 
215
+/**
216
+ * Check list contains a specified entry
217
+ *
218
+ * @v entry		Entry
219
+ * @v head		List head
220
+ * @v member		Name of list field within iterator's type
221
+ */
222
+#define list_check_contains( entry, head, member ) do {		\
223
+	if ( ASSERTING ) {					\
224
+		typeof ( entry ) tmp;				\
225
+		int found = 0;					\
226
+		list_for_each_entry ( tmp, head, member ) {	\
227
+			if ( tmp == entry )			\
228
+				found = 1;			\
229
+		}						\
230
+		assert ( found );				\
231
+	}							\
232
+	} while ( 0 )
233
+
215
 #endif /* _IPXE_LIST_H */
234
 #endif /* _IPXE_LIST_H */

Loading…
Cancel
Save