From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A471EA00C2;
	Sun,  5 Jun 2022 09:51:57 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 97277427F2;
	Sun,  5 Jun 2022 09:51:49 +0200 (CEST)
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by mails.dpdk.org (Postfix) with ESMTP id B96504003F
 for <dev@dpdk.org>; Wed,  1 Jun 2022 12:55:10 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1654080910; x=1685616910;
 h=from:to:cc:subject:date:message-id:mime-version:
 content-transfer-encoding;
 bh=BIXgCPnV1tbFTqYMbsKryt8htDoRRefEL/0uulYLFAU=;
 b=bcZ08wOVkLcM6bGdvdjfxrYJm7gyH78savI1ce5cQLi9t3BBzLuZVLGu
 SuxyOF+21YRNIFQtdEr4A+WjP3Vay4qYlPdjSKJsQnatcjIh+qmXmOOpg
 VSdJ/31yqH6O/q1fVXa5u7G7EwORu+6kzxy+H/UcqtGbSk6W+qMlkHs8w
 eAk+hd9g5xlLQf7kvRl/hb0erc9S+QcW+XLxIqZHY03ggHQdyRSie3DE5
 mtJPOiI6YfuFJVR4zx1rh/Z7XHGl3twVUOBReAzFVgVe2Nih9gKu4gDpe
 qeS6IqAJ02ey1JnpsNcbN2hJ2dtK3R2KDF+Kqw5ZnzF2g7PkPMgENfjqp A==;
X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="275557228"
X-IronPort-AV: E=Sophos;i="5.91,268,1647327600"; d="scan'208";a="275557228"
Received: from orsmga005.jf.intel.com ([10.7.209.41])
 by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 01 Jun 2022 03:55:09 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.91,268,1647327600"; d="scan'208";a="755862778"
Received: from silpixa00399752.ir.intel.com (HELO
 silpixa00399752.ger.corp.intel.com) ([10.237.222.52])
 by orsmga005.jf.intel.com with ESMTP; 01 Jun 2022 03:55:09 -0700
From: Hamza Khan <hamza.khan@intel.com>
To: 
Cc: dev@dpdk.org,
	Hamza Khan <hamza.khan@intel.com>
Subject: [PATCH 1/2] common: add safe version of foreach-list to Linux
Date: Wed,  1 Jun 2022 10:54:54 +0000
Message-Id: <20220601105455.166505-1-hamza.khan@intel.com>
X-Mailer: git-send-email 2.25.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Mailman-Approved-At: Sun, 05 Jun 2022 09:51:46 +0200
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Linux EAL does not have the LIST_FOREACH_SAFE version of the
iterator macros. Add it.

Signed-off-by: Hamza Khan <hamza.khan@intel.com>
---
 lib/eal/linux/include/rte_os.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h
index c72bf5b7e6..00d7714181 100644
--- a/lib/eal/linux/include/rte_os.h
+++ b/lib/eal/linux/include/rte_os.h
@@ -26,6 +26,13 @@ extern "C" {
 #define RTE_STAILQ_HEAD(name, type) STAILQ_HEAD(name, type)
 #define RTE_STAILQ_ENTRY(type) STAILQ_ENTRY(type)
 
+#ifndef LIST_FOREACH_SAFE
+#define	LIST_FOREACH_SAFE(var, head, field, tvar)			\
+	for ((var) = LIST_FIRST((head));				\
+	    (var) && ((tvar) = LIST_NEXT((var), field), 1);		\
+	    (var) = (tvar))
+#endif
+
 #ifdef CPU_SETSIZE /* may require _GNU_SOURCE */
 typedef cpu_set_t rte_cpuset_t;
 #define RTE_HAS_CPUSET
-- 
2.25.1