Skip to content

Commit

Permalink
Merge pull request #205 from markjdb/master
Browse files Browse the repository at this point in the history
ck_queue: add CK_*_FOREACH_FROM
  • Loading branch information
cognet authored Feb 18, 2023
2 parents abb97b7 + 74366be commit 50299b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/ck_queue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
.Nm CK_LIST_ENTRY ,
.Nm CK_LIST_FIRST ,
.Nm CK_LIST_FOREACH ,
.Nm CK_LIST_FOREACH_FROM ,
.Nm CK_LIST_FOREACH_SAFE ,
.Nm CK_LIST_HEAD ,
.Nm CK_LIST_HEAD_INITIALIZER ,
Expand All @@ -46,6 +47,7 @@
.Nm CK_SLIST_ENTRY ,
.Nm CK_SLIST_FIRST ,
.Nm CK_SLIST_FOREACH ,
.Nm CK_SLIST_FOREACH_FROM ,
.Nm CK_SLIST_FOREACH_PREVPTR ,
.Nm CK_SLIST_FOREACH_SAFE ,
.Nm CK_SLIST_HEAD ,
Expand All @@ -64,6 +66,7 @@
.Nm CK_STAILQ_ENTRY ,
.Nm CK_STAILQ_FIRST ,
.Nm CK_STAILQ_FOREACH ,
.Nm CK_STAILQ_FOREACH_FROM ,
.Nm CK_STAILQ_FOREACH_SAFE ,
.Nm CK_STAILQ_HEAD ,
.Nm CK_STAILQ_HEAD_INITIALIZER ,
Expand All @@ -86,6 +89,7 @@ Concurrency Kit (libck, \-lck)
.Fn CK_LIST_ENTRY
.Fn CK_LIST_FIRST
.Fn CK_LIST_FOREACH
.Fn CK_LIST_FOREACH_FROM
.Fn CK_LIST_FOREACH_SAFE
.Fn CK_LIST_HEAD
.Fn CK_LIST_HEAD_INITIALIZER
Expand All @@ -101,6 +105,7 @@ Concurrency Kit (libck, \-lck)
.Fn CK_SLIST_ENTRY
.Fn CK_SLIST_FIRST
.Fn CK_SLIST_FOREACH
.Fn CK_SLIST_FOREACH_FROM
.Fn CK_SLIST_FOREACH_PREVPTR
.Fn CK_SLIST_FOREACH_SAFE
.Fn CK_SLIST_HEAD
Expand All @@ -119,6 +124,7 @@ Concurrency Kit (libck, \-lck)
.Fn CK_STAILQ_ENTRY
.Fn CK_STAILQ_FIRST
.Fn CK_STAILQ_FOREACH
.Fn CK_STAILQ_FOREACH_FROM
.Fn CK_STAILQ_FOREACH_SAFE
.Fn CK_STAILQ_HEAD
.Fn CK_STAILQ_HEAD_INITIALIZER
Expand Down
15 changes: 15 additions & 0 deletions include/ck_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down Expand Up @@ -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) = \
Expand Down Expand Up @@ -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); \
Expand Down

0 comments on commit 50299b7

Please sign in to comment.