From: Jason Ekstrand Date: Mon, 5 Aug 2019 21:19:06 +0000 (-0500) Subject: util/list: Add a list pair iterator X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aeb95fda541719d5fe9b8fdb531f3370228228d7;p=mesa.git util/list: Add a list pair iterator Reviewed-by: Kenneth Graunke Reviewed-by: Alyssa Rosenzweig Reviewed-by: Eric Anholt Part-of: --- 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_*/