Date: Sat, 25 Feb 2023 15:34:14 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 6f48a4acbeb8 - main - ck_queue: add CK_*_FOREACH_FROM Message-ID: <202302251534.31PFYEST080928@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6f48a4acbeb86ebbef90290ad73ea6be83507aa9 commit 6f48a4acbeb86ebbef90290ad73ea6be83507aa9 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-02-25 15:21:19 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2023-02-25 15:34:06 +0000 ck_queue: add CK_*_FOREACH_FROM This is a variant of CK_*_FOREACH from FreeBSD queue.h which starts iteration at the specified item. If the item pointer is NULL, iteration starts from the beginning of the list. Upstream commit 74366be35a6f4635f248a3c62d2d23245a4eb0f4. MFC after: 2 weeks Sponsored by: Klara, Inc. --- sys/contrib/ck/include/ck_queue.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/contrib/ck/include/ck_queue.h b/sys/contrib/ck/include/ck_queue.h index fd38d8a583fa..3472b0e40ad9 100644 --- a/sys/contrib/ck/include/ck_queue.h +++ b/sys/contrib/ck/include/ck_queue.h @@ -153,6 +153,11 @@ struct { \ (var); \ (var) = CK_SLIST_NEXT((var), field)) +#define CK_SLIST_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) != NULL ? (var) : CK_SLIST_FIRST((head))); \ + (var); \ + (var) = CK_SLIST_NEXT((var), field)) + #define CK_SLIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = CK_SLIST_FIRST(head); \ (var) && ((tvar) = CK_SLIST_NEXT(var, field), 1); \ @@ -262,6 +267,11 @@ struct { \ (var); \ (var) = CK_STAILQ_NEXT((var), field)) +#define CK_STAILQ_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) != NULL ? (var) : CK_STAILQ_FIRST((head))); \ + (var); \ + (var) = CK_STAILQ_NEXT((var), field)) + #define CK_STAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = CK_STAILQ_FIRST((head)); \ (var) && ((tvar) = \ @@ -374,6 +384,11 @@ struct { \ (var); \ (var) = CK_LIST_NEXT((var), field)) +#define CK_LIST_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) != NULL ? (var) : CK_LIST_FIRST((head))); \ + (var); \ + (var) = CK_LIST_NEXT((var), field)) + #define CK_LIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = CK_LIST_FIRST((head)); \ (var) && ((tvar) = CK_LIST_NEXT((var), field), 1); \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302251534.31PFYEST080928>