diff options
author | archie <archie@FreeBSD.org> | 2000-05-01 18:17:14 +0000 |
---|---|---|
committer | archie <archie@FreeBSD.org> | 2000-05-01 18:17:14 +0000 |
commit | 0a725efcf4b081aadadcacda0fb6bb49f018146f (patch) | |
tree | 58f2a4e19191c3f210d192e81a0aae5933e2b884 /sys/sys/queue.h | |
parent | 1a064115daf410d1fb5762fd6cc3b67945394135 (diff) | |
download | FreeBSD-src-0a725efcf4b081aadadcacda0fb6bb49f018146f.zip FreeBSD-src-0a725efcf4b081aadadcacda0fb6bb49f018146f.tar.gz |
Add TAILQ_FOREACH_REVERSE() macro.
Submitted by: Jake Burkholder <jburkhol@home.com>
Diffstat (limited to 'sys/sys/queue.h')
-rw-r--r-- | sys/sys/queue.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h index d20354f..a7ec5da 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -74,7 +74,7 @@ * linked so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before or * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may only be traversed in the forward direction. + * the list. A tail queue may be traversed in either direction. * * A circle queue is headed by a pair of pointers, one to the head of the * list and the other to the tail of the list. The elements are doubly @@ -97,6 +97,7 @@ * _PREV - - - + + * _LAST - - + + + * _FOREACH + + + + + + * _FOREACH_REVERSE - - - + + * _INSERT_HEAD + + + + + * _INSERT_BEFORE - + - + + * _INSERT_AFTER + + + + + @@ -332,6 +333,11 @@ struct { \ #define TAILQ_FOREACH(var, head, field) \ for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field)) +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var); \ + (var) = TAILQ_PREV((var), headname, field)) + #define TAILQ_FIRST(head) ((head)->tqh_first) #define TAILQ_LAST(head, headname) \ |