From aeb95fda541719d5fe9b8fdb531f3370228228d7 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 5 Aug 2019 16:19:06 -0500 Subject: [PATCH] util/list: Add a list pair iterator Reviewed-by: Kenneth Graunke Reviewed-by: Alyssa Rosenzweig Reviewed-by: Eric Anholt Part-of: --- src/util/list.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/list.h b/src/util/list.h index 8a18c4b0d8d..17800e4ed4e 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -246,4 +246,11 @@ static inline void list_validate(const struct list_head *list) &pos->member != (head); \ pos = LIST_ENTRY(type, pos->member.prev, member)) +#define list_pair_for_each_entry(type, pos1, pos2, head1, head2, member) \ + for (type *pos1 = LIST_ENTRY(type, (head1)->next, member), \ + *pos2 = LIST_ENTRY(type, (head2)->next, member); \ + &pos1->member != (head1) && &pos2->member != (head2); \ + pos1 = LIST_ENTRY(type, pos1->member.next, member), \ + pos2 = LIST_ENTRY(type, pos2->member.next, member)) + #endif /*_UTIL_LIST_H_*/ -- 2.30.2