DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
To: dev@dpdk.org
Cc: thomas.monjalon@6wind.com
Subject: [dpdk-dev] [PATCH 1/2] eal: add stailq safe iterator macro
Date: Fri, 22 Jul 2016 17:01:17 +0100	[thread overview]
Message-ID: <1469203278-91363-1-git-send-email-sergio.gonzalez.monroy@intel.com> (raw)

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

             reply	other threads:[~2016-07-22 16:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-22 16:01 Sergio Gonzalez Monroy [this message]
2016-07-22 16:01 ` [dpdk-dev] [PATCH 2/2] mempool: fix unsafe tailq element removal Sergio Gonzalez Monroy
2016-07-25 16:30   ` Olivier Matz
2016-07-25 19:54     ` [dpdk-dev] [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 ` [dpdk-dev] [PATCH 1/2] eal: add stailq safe iterator macro Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1469203278-91363-1-git-send-email-sergio.gonzalez.monroy@intel.com \
    --to=sergio.gonzalez.monroy@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).