Any objections to adding this to the LIST structure?
I needed this a bounch of times and I think it makes sense in a *doubly*
linked list.
Index: sys/sys/queue.h
===================================================================
RCS file: /cvs/src/sys/sys/queue.h,v
retrieving revision 1.32
diff -u -p -r1.32 queue.h
--- sys/sys/queue.h 30 Apr 2007 18:42:34 -0000 1.32
+++ sys/sys/queue.h 2 Jun 2011 15:51:44 -0000
@@ -185,6 +185,7 @@ struct {
\
#define LIST_END(head) NULL
#define LIST_EMPTY(head) (LIST_FIRST(head) ==
LIST_END(head))
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
+#define LIST_PREV(elm, field) (*((elm)->field.le_prev))
#define LIST_FOREACH(var, head, field) \
for((var) = LIST_FIRST(head); \
Index: share/man/man3/queue.3
===================================================================
RCS file: /cvs/src/share/man/man3/queue.3,v
retrieving revision 1.49
diff -u -p -r1.49 queue.3
--- share/man/man3/queue.3 1 Mar 2009 10:28:55 -0000 1.49
+++ share/man/man3/queue.3 2 Jun 2011 15:51:44 -0000
@@ -54,6 +54,7 @@
.Nm LIST_HEAD_INITIALIZER ,
.Nm LIST_FIRST ,
.Nm LIST_NEXT ,
+.Nm LIST_PREV ,
.Nm LIST_END ,
.Nm LIST_EMPTY ,
.Nm LIST_FOREACH ,
@@ -150,6 +151,8 @@
.Ft "struct TYPE *"
.Fn LIST_NEXT "struct TYPE *listelm" "LIST_ENTRY NAME"
.Ft "struct TYPE *"
+.Fn LIST_PREV "struct TYPE *listelm" "LIST_ENTRY NAME"
+.Ft "struct TYPE *"
.Fn LIST_END "LIST_HEAD *head"
.Ft int
.Fn LIST_EMPTY "LIST_HEAD *head"
@@ -598,6 +601,11 @@ macro inserts the new element
.Fa elm
before the element
.Fa listelm .
+.Pp
+The
+.Fn LIST_PREV
+macro returns the previous entry from element
+.Fa elm .
.Pp
The
.Fn LIST_REMOVE
Index: share/man/man3/Makefile
===================================================================
RCS file: /cvs/src/share/man/man3/Makefile,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile
--- share/man/man3/Makefile 18 Feb 2010 18:28:18 -0000 1.21
+++ share/man/man3/Makefile 2 Jun 2011 15:51:44 -0000
@@ -21,7 +21,7 @@ MLINKS+=queue.3 SLIST_ENTRY.3 queue.3 SL
queue.3 SLIST_REMOVE.3
MLINKS+=queue.3 LIST_ENTRY.3 queue.3 LIST_HEAD.3 \
queue.3 LIST_HEAD_INITIALIZER.3 queue.3 LIST_FIRST.3 \
- queue.3 LIST_NEXT.3 queue.3 LIST_END.3 \
+ queue.3 LIST_NEXT.3 queue.3 LIST_END.3 queue.3 LIST_PREV.3\
queue.3 LIST_EMPTY.3 queue.3 LIST_FOREACH.3 \
queue.3 LIST_INIT.3 \
queue.3 LIST_INSERT_AFTER.3 queue.3 LIST_INSERT_BEFORE.3 \