git: 79fafc09740a - main - queue.h: Define {LIST,TAILQ}_REMOVE_HEAD
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 20 Aug 2023 05:05:40 UTC
The branch main has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=79fafc09740ad508b40e909dc898cbac2d4f67c4
commit 79fafc09740ad508b40e909dc898cbac2d4f67c4
Author: Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2023-07-17 23:42:50 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2023-08-20 05:04:55 +0000
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
---
sys/sys/queue.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index 8e91ebf7949d..47d85121e317 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -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); \