aboutsummaryrefslogtreecommitdiffstats
path: root/lib/librte_eal/common/include/rte_tailq.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/librte_eal/common/include/rte_tailq.h')
-rw-r--r--lib/librte_eal/common/include/rte_tailq.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h
index 4a686e68..cc3c0f1d 100644
--- a/lib/librte_eal/common/include/rte_tailq.h
+++ b/lib/librte_eal/common/include/rte_tailq.h
@@ -155,6 +155,14 @@ void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \
rte_panic("Cannot initialize tailq: %s\n", t.name); \
}
+/* This macro permits both remove and free var within the loop safely.*/
+#ifndef TAILQ_FOREACH_SAFE
+#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = TAILQ_FIRST((head)); \
+ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
+ (var) = (tvar))
+#endif
+
#ifdef __cplusplus
}
#endif