list.h: Add macros for reverse iteration.

This commit is contained in:
Dan Hipschman 2007-06-05 18:48:21 -07:00 committed by Alexandre Julliard
parent a2deafcc3f
commit 6cf8e6bd77

View File

@ -196,6 +196,30 @@ static inline void list_move_head( struct list *dst, struct list *src )
(cursor) = (cursor2), \
(cursor2) = LIST_ENTRY((cursor)->field.next, type, field))
/* iterate through the list in reverse order */
#define LIST_FOR_EACH_REV(cursor,list) \
for ((cursor) = (list)->prev; (cursor) != (list); (cursor) = (cursor)->prev)
/* iterate through the list in reverse order, with safety against removal */
#define LIST_FOR_EACH_SAFE_REV(cursor, cursor2, list) \
for ((cursor) = (list)->prev, (cursor2) = (cursor)->prev; \
(cursor) != (list); \
(cursor) = (cursor2), (cursor2) = (cursor)->prev)
/* iterate through the list in reverse order using a list entry */
#define LIST_FOR_EACH_ENTRY_REV(elem, list, type, field) \
for ((elem) = LIST_ENTRY((list)->prev, type, field); \
&(elem)->field != (list); \
(elem) = LIST_ENTRY((elem)->field.prev, type, field))
/* iterate through the list in reverse order using a list entry, with safety against removal */
#define LIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, list, type, field) \
for ((cursor) = LIST_ENTRY((list)->prev, type, field), \
(cursor2) = LIST_ENTRY((cursor)->field.prev, type, field); \
&(cursor)->field != (list); \
(cursor) = (cursor2), \
(cursor2) = LIST_ENTRY((cursor)->field.prev, type, field))
/* macros for statically initialized lists */
#define LIST_INIT(list) { &(list), &(list) }