git: 6286f5df3e4a - stable/14 - sys/queue.h: add STAILQ_REVERSE
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 10 May 2025 19:33:04 UTC
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6286f5df3e4a667e51561d0d9ddb754930d50ef0 commit 6286f5df3e4a667e51561d0d9ddb754930d50ef0 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2025-05-03 08:13:14 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-05-10 18:15:21 +0000 sys/queue.h: add STAILQ_REVERSE (cherry picked from commit e8286eb295165ea1852abe4ae355f85ad1ec3356) --- sys/sys/queue.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/sys/queue.h b/sys/sys/queue.h index 5dabb1a241c2..cfad9822e74a 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -566,6 +566,21 @@ struct { \ (head2)->stqh_last = &STAILQ_FIRST(head2); \ } while (0) +#define STAILQ_REVERSE(head, type, field) do { \ + if (STAILQ_EMPTY(head)) \ + break; \ + QUEUE_TYPEOF(type) *_Var, *_Varp, *_Varn; \ + for (_Var = STAILQ_FIRST(head), _Varp = NULL; \ + _Var != NULL;) { \ + _Varn = STAILQ_NEXT(_Var, field); \ + STAILQ_NEXT(_Var, field) = _Varp; \ + _Varp = _Var; \ + _Var = _Varn; \ + } \ + (head)->stqh_last = &STAILQ_NEXT(STAILQ_FIRST(head), field); \ + (head)->stqh_first = _Varp; \ +} while (0) + #define STAILQ_END(head) NULL