All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] eal: add stailq safe iterator macro
@ 2016-07-22 16:01 Sergio Gonzalez Monroy
  2016-07-22 16:01 ` [PATCH 2/2] mempool: fix unsafe tailq element removal Sergio Gonzalez Monroy
  2016-07-22 16:16 ` [PATCH 1/2] eal: add stailq safe iterator macro Thomas Monjalon
  0 siblings, 2 replies; 7+ messages in thread
From: Sergio Gonzalez Monroy @ 2016-07-22 16:01 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon

Removing/freeing elements elements within a STAILQ_FOREACH loop
is not safe. FreeBSD defines STAILQ_FOREACH_SAFE macro, which permits
these operations safely.

This patch defines this macro for Linux systems, where it is not defined.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---

NOTE: This patch is based on top of:
	http://dpdk.org/dev/patchwork/patch/14995/

 lib/librte_eal/common/include/rte_tailq.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h
index cc3c0f1..bba2835 100644
--- a/lib/librte_eal/common/include/rte_tailq.h
+++ b/lib/librte_eal/common/include/rte_tailq.h
@@ -163,6 +163,13 @@ void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \
 	    (var) = (tvar))
 #endif
 
+#ifndef SLIST_FOREACH_SAFE
+#define SLIST_FOREACH_SAFE(var, head, field, tvar)                      \
+	for ((var) = SLIST_FIRST((head));                               \
+	    (var) && ((tvar) = SLIST_NEXT((var), field), 1);            \
+	    (var) = (tvar))
+#endif
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-25 20:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-22 16:01 [PATCH 1/2] eal: add stailq safe iterator macro Sergio Gonzalez Monroy
2016-07-22 16:01 ` [PATCH 2/2] mempool: fix unsafe tailq element removal Sergio Gonzalez Monroy
2016-07-25 16:30   ` Olivier Matz
2016-07-25 19:54     ` [PATCH v2] mempool: fix unsafe removal from list by callback Thomas Monjalon
2016-07-25 20:09       ` Olivier Matz
2016-07-25 20:21         ` Thomas Monjalon
2016-07-22 16:16 ` [PATCH 1/2] eal: add stailq safe iterator macro Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.