Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cc: extend queue module
Browse files Browse the repository at this point in the history
- add function to reinit tailq which supports pointer arithmetics
michalbiesek committed Jul 2, 2019

Verified

This commit was signed with the committer’s verified signature.
0x2142 Matt Schmitz
1 parent 4e4fa90 commit 095a027
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions deps/ccommon/include/cc_queue.h
Original file line number Diff line number Diff line change
@@ -127,6 +127,7 @@ extern "C" {
* _INSERT_TAIL - - + + +
* _REMOVE_HEAD + - + - -
* _REMOVE + + + + +
* _REINIT - - - + -
*
*/

@@ -691,6 +692,23 @@ struct { \
(head2)->tqh_last = &(head2)->tqh_first; \
} while (0)

#define TAILQ_REINIT(head, var, field, offset) do { \
TAILQ_FIRST((head)) = var; \
TAILQ_FOREACH(var, head, field) { \
if ((TAILQ_NEXT((var), field)) != NULL) { \
TAILQ_NEXT((var), field) = \
(void *)((char *)(TAILQ_NEXT((var), field)) + (offset));\
} \
if ((var) == TAILQ_FIRST(head)) { \
(var)->field.tqe_prev = &TAILQ_FIRST(head); \
} else { \
(var)->field.tqe_prev = \
(void *)((char *)((var)->field.tqe_prev) + (offset)); \
} \
(head)->tqh_last = &TAILQ_NEXT((var), field); \
} \
} while (0)

/*
* Circular queue declarations.
*/

0 comments on commit 095a027

Please sign in to comment.