Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-08-19 09:47:04 +0300
committerFelix Fietkau <nbd@nbd.name>2021-08-19 09:56:59 +0300
commitd716ac4bc4236031d4c3cc1ed362b502e20e3787 (patch)
treebd04e232506785e302d937911c285187dc6b5c1e
parentb14c4688612c05c78ce984d7bde633bce8703b1e (diff)
list.h: add a few missing iterator macros
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--list.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/list.h b/list.h
index 8e61e47..a2cb241 100644
--- a/list.h
+++ b/list.h
@@ -112,6 +112,8 @@ list_del_init(struct list_head *entry)
#define list_entry(ptr, type, field) container_of(ptr, type, field)
#define list_first_entry(ptr, type, field) list_entry((ptr)->next, type, field)
#define list_last_entry(ptr, type, field) list_entry((ptr)->prev, type, field)
+#define list_next_entry(pos, member) list_entry((pos)->member.next, typeof(*(pos)), member)
+#define list_entry_is_h(p, h, field) (&p->field == (h))
#define list_for_each(p, head) \
for (p = (head)->next; p != (head); p = p->next)
@@ -123,6 +125,16 @@ list_del_init(struct list_head *entry)
for (p = list_first_entry(h, __typeof__(*p), field); &p->field != (h); \
p = list_entry(p->field.next, __typeof__(*p), field))
+#define list_for_each_entry_continue(p, h, field) \
+ for (p = list_next_entry(p, field); \
+ !list_entry_is_h(p, h, field); \
+ p = list_next_entry(p, field))
+
+#define list_for_each_entry_continue_reverse(p, h, field) \
+ for (p = list_prev_entry(p, field); \
+ !list_entry_is_h(p, h, field); \
+ p = list_prev_entry(p, field))
+
#define list_for_each_entry_safe(p, n, h, field) \
for (p = list_first_entry(h, __typeof__(*p), field), \
n = list_entry(p->field.next, __typeof__(*p), field); &p->field != (h);\