Skip to content

Commit

Permalink
queue: add QTAILQ_REMOVE_SEVERAL
Browse files Browse the repository at this point in the history
This is faster than removing elements one by one.

Will gain a user soon.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
cota authored and stsquad committed Oct 28, 2019
1 parent 5c5d69b commit 050ec8c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/qemu/queue.h
Expand Up @@ -420,6 +420,16 @@ union { \
(elm)->field.tqe_circ.tql_prev = NULL; \
} while (/*CONSTCOND*/0)

/* remove @left, @right and all elements in between from @head */
#define QTAILQ_REMOVE_SEVERAL(head, left, right, field) do { \
if (((right)->field.tqe_next) != NULL) \
(right)->field.tqe_next->field.tqe_circ.tql_prev = \
(left)->field.tqe_circ.tql_prev; \
else \
(head)->tqh_circ.tql_prev = (left)->field.tqe_circ.tql_prev; \
(left)->field.tqe_circ.tql_prev->tql_next = (right)->field.tqe_next; \
} while (/*CONSTCOND*/0)

#define QTAILQ_FOREACH(var, head, field) \
for ((var) = ((head)->tqh_first); \
(var); \
Expand Down

0 comments on commit 050ec8c

Please sign in to comment.