[patch] hwpmc [4/13]

Aggelos Economopoulos aoiko at cc.ece.ntua.gr
Sat Nov 24 13:17:44 PST 2007


Add safe iterator for STAILQ. Required for hwpmc, freebsd firewire code,
other imports will probably need it in the future. Freebsd names these
macros as "_SAFE".

Obtained-from: FreeBSD

Index: sys/queue.h
===================================================================
retrieving revision 1.8
diff -u -p -r1.8 queue.h
--- sys/queue.h
+++ sys/queue.h
@@ -103,7 +103,7 @@
  * _PREV		-	-	-	+	+
  * _LAST		-	-	+	+	+
  * _FOREACH		+	+	+	+	+
- * _FOREACH_MUTABLE	-	+	-	+	-
+ * _FOREACH_MUTABLE	-	+	+	+	-
  * _FOREACH_REVERSE	-	-	-	+	+
  * _INSERT_HEAD		+	+	+	+	+
  * _INSERT_BEFORE	-	+	-	+	+
@@ -215,6 +215,11 @@ struct {								\
 	   (var);							\
 	   (var) = STAILQ_NEXT((var), field))
 
+#define	STAILQ_FOREACH_MUTABLE(var, head, field, nvar)			\
+	for((var) = STAILQ_FIRST((head));				\
+	   (var) && ((nvar) = STAILQ_NEXT((var), field), 1);		\
+	   (var) = (nvar))
+
 #define	STAILQ_INIT(head) do {						\
 	STAILQ_FIRST((head)) = NULL;					\
 	(head)->stqh_last = &STAILQ_FIRST((head));			\





More information about the Submit mailing list