mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
queue.h: Define {LIST,TAILQ}_REMOVE_HEAD
The LIST and TAILQ structures have fast _REMOVE macros (since each element has a pointer to the previous element); we implement the _REMOVE_HEAD macros for them by simply finding the first element and then removing it. Reviewed by: jhb, emaste Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D41072
This commit is contained in:
parent
332af8c25d
commit
79fafc0974
|
@ -110,7 +110,7 @@
|
|||
* _INSERT_TAIL - - + +
|
||||
* _CONCAT s s + +
|
||||
* _REMOVE_AFTER + - + -
|
||||
* _REMOVE_HEAD + - + -
|
||||
* _REMOVE_HEAD + + + +
|
||||
* _REMOVE s + s +
|
||||
* _SWAP + + + +
|
||||
*
|
||||
|
@ -595,6 +595,9 @@ struct { \
|
|||
__containerof((elm)->field.le_prev, \
|
||||
QUEUE_TYPEOF(type), field.le_next))
|
||||
|
||||
#define LIST_REMOVE_HEAD(head, field) \
|
||||
LIST_REMOVE(LIST_FIRST(head), field)
|
||||
|
||||
#define LIST_REMOVE(elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.le_next); \
|
||||
QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
|
||||
|
@ -841,6 +844,9 @@ struct { \
|
|||
((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \
|
||||
__containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next))
|
||||
|
||||
#define TAILQ_REMOVE_HEAD(head, field) \
|
||||
TAILQ_REMOVE(head, TAILQ_FIRST(head), field)
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
|
||||
QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
|
||||
|
|
Loading…
Reference in a new issue