From: David Herrmann Date: Mon, 8 Oct 2012 15:15:42 +0000 (+0200) Subject: shl: dlist: add macros for iterating lists in reverse order X-Git-Tag: kmscon-7~383 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1c972f7d955c9382f4b0d5b366ea6c95be24b32;p=platform%2Fupstream%2Fkmscon.git shl: dlist: add macros for iterating lists in reverse order These macros do the same as the already available macros but in reversed order. This is useful when list-order is important. Signed-off-by: David Herrmann --- diff --git a/src/shl_dlist.h b/src/shl_dlist.h index 17ca8b3..8887f7f 100644 --- a/src/shl_dlist.h +++ b/src/shl_dlist.h @@ -109,4 +109,11 @@ static inline bool shl_dlist_empty(struct shl_dlist *head) for (iter = (head)->next, tmp = iter->next; iter != (head); \ iter = tmp, tmp = iter->next) +#define shl_dlist_for_each_reverse(iter, head) \ + for (iter = (head)->prev; iter != (head); iter = iter->prev) + +#define shl_dlist_for_each_reverse_safe(iter, tmp, head) \ + for (iter = (head)->prev, tmp = iter->prev; iter != (head); \ + iter = tmp, tmp = iter->prev) + #endif /* SHL_DLIST_H */