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 5A2BF43E97;
	Thu, 18 Apr 2024 01:42:05 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3618C402E3;
	Thu, 18 Apr 2024 01:42:04 +0200 (CEST)
Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182])
 by mails.dpdk.org (Postfix) with ESMTP id BDA7040272
 for <dev@dpdk.org>; Thu, 18 Apr 2024 01:42:02 +0200 (CEST)
Received: by linux.microsoft.com (Postfix, from userid 1086)
 id EF75220FD4CB; Wed, 17 Apr 2024 16:42:01 -0700 (PDT)
DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EF75220FD4CB
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;
 s=default; t=1713397321;
 bh=VX1JW+TCNJFvDGb5Nd5z00eVBNn2wuTDEyeJ3OyqkYs=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=dg6CDCE7atTW+pi65MhG1OiHGMjqDOWYW9IcFMQJ8XB6n+pG6D92o02Sudul6AK9k
 shbc7Vj7wp6HUtVsJ6iDkB+dQR6sW5E56s66SaB/3MleBk2is/2SXTLb9XoQCGaU6y
 3ESl8/C62aIRgHEjvEBT6hpDvy1c3mlrZcvpLI+4=
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: =?UTF-8?q?Morten=20Br=C3=B8rup?= <mb@smartsharesystems.com>,
 Akhil Goyal <gakhil@marvell.com>, Aman Singh <aman.deep.singh@intel.com>,
 Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
 Bruce Richardson <bruce.richardson@intel.com>,
 Chengwen Feng <fengchengwen@huawei.com>,
 Dariusz Sosnowski <dsosnowski@nvidia.com>,
 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
 Fan Zhang <fanzhang.oss@gmail.com>, Ferruh Yigit <ferruh.yigit@amd.com>,
 Harry van Haaren <harry.van.haaren@intel.com>,
 Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,
 Jiayu Hu <hujiayu.hu@foxmail.com>, Jingjing Wu <jingjing.wu@intel.com>,
 Kevin Laatz <kevin.laatz@intel.com>,
 Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
 Matan Azrad <matan@nvidia.com>, Ori Kam <orika@nvidia.com>,
 Pallavi Kadam <pallavi.kadam@intel.com>,
 Reshma Pattan <reshma.pattan@intel.com>,
 Sameh Gobriel <sameh.gobriel@intel.com>,
 Suanming Mou <suanmingm@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>,
 Tyler Retzlaff <roretzla@linux.microsoft.com>,
 Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
 Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
 Volodymyr Fialko <vfialko@marvell.com>,
 Yipeng Wang <yipeng1.wang@intel.com>, Yuying Zhang <Yuying.Zhang@intel.com>
Subject: [PATCH 02/16] hash: remove use of VLAs for Windows built code
Date: Wed, 17 Apr 2024 16:41:45 -0700
Message-Id: <1713397319-26135-3-git-send-email-roretzla@linux.microsoft.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com>
References: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com>
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

MSVC does not support VLAs, replace VLAs with standard C arrays
or alloca(). alloca() is available for all toolchain/platform
combinations officially supported by DPDK.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 lib/hash/rte_thash.c       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf9464..bd2ff08 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -2359,7 +2359,7 @@ struct rte_hash *
 			(num_keys > RTE_HASH_LOOKUP_BULK_MAX) ||
 			(hit_mask == NULL)), -EINVAL);
 
-	int32_t positions[num_keys];
+	int32_t *positions = alloca(sizeof(int32_t) * num_keys);
 
 	__rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data);
 
@@ -2475,7 +2475,7 @@ struct rte_hash *
 			(num_keys > RTE_HASH_LOOKUP_BULK_MAX) ||
 			(hit_mask == NULL)), -EINVAL);
 
-	int32_t positions[num_keys];
+	int32_t *positions = alloca(sizeof(int32_t) * num_keys);
 
 	__rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys,
 			positions, hit_mask, data);
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 68f653f..633e211 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -771,7 +771,7 @@ struct rte_thash_subtuple_helper *
 	uint32_t desired_value,	unsigned int attempts,
 	rte_thash_check_tuple_t fn, void *userdata)
 {
-	uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)];
+	uint32_t *tmp_tuple = alloca(tuple_len);
 	unsigned int i, j, ret = 0;
 	uint32_t hash, adj_bits;
 	const uint8_t *hash_key;
-- 
1.8.3.1