summaryrefslogtreecommitdiffstats
path: root/lib/list/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/list/list.h')
-rw-r--r--lib/list/list.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/list/list.h b/lib/list/list.h
index cd9cd10..97fb615 100644
--- a/lib/list/list.h
+++ b/lib/list/list.h
@@ -40,6 +40,14 @@ struct list {
#define list_for_each_entry_continue(_list, _pos, _member) \
for (; _pos; _pos = list_next_entry(_list, _pos, _member))
+#define list_for_each_entry_safe(_list, _pos, _tmp, _member) \
+ for (_pos = container_of((_list)->head.next, typeof(*_pos), _member), \
+ _tmp = container_of(_pos->_member.next, typeof(*_pos), \
+ _member); \
+ &_pos->_member != &(_list)->head; \
+ _pos = _tmp, \
+ _tmp = list_entry(_tmp->_member.next, typeof(*_pos), \
+ _member, _list))
#define DEFINE_LIST(_list) struct list _list = { \
.head = { \
OpenPOWER on IntegriCloud