DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 00/10] enable "app" to be compiled with MSVC
@ 2025-02-11 22:01 Andre Muezerie
  2025-02-11 22:01 ` [PATCH 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
                   ` (11 more replies)
  0 siblings, 12 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:01 UTC (permalink / raw)
  Cc: dev, Andre Muezerie

This series fixes many issues that prevent the "app" directory
from being compiled with MSVC.

Andre Muezerie (10):
  eal: add workaround for __builtin_constant_p
  test_alarm: avoid warning about different qualifiers
  test-pmd: fix printf format string mismatch
  test-pmd: do explicit 64-bit shift to avoid implicit conversion
  test-pmd: avoid undefined behavior
  test-pmd: avoid non-constant initializer
  test-pmd: don't return value from void function
  test-pmd: declare lcore_count atomic when using C11 memory model
  test: add workaround for __builtin_constant_p in test_memcpy_perf
  app: enable app directory to be compiled with MSVC

 app/meson.build                     |   4 --
 app/test-pmd/cmdline.c              |  19 +++--
 app/test-pmd/cmdline_flow.c         |  22 +++---
 app/test-pmd/csumonly.c             |  12 ++--
 app/test-pmd/meson.build            |   4 +-
 app/test-pmd/testpmd.c              |   2 +-
 app/test-pmd/util.c                 |   2 +-
 app/test/test_alarm.c               |  12 ++--
 app/test/test_memcpy_perf.c         | 106 ++++++++++++++--------------
 app/test/test_ring_perf.c           |   6 +-
 lib/eal/include/generic/rte_pause.h |   2 +-
 lib/eal/include/rte_common.h        |  12 ++++
 12 files changed, 114 insertions(+), 89 deletions(-)

--
2.47.2.vfs.0.1


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

* [PATCH 01/10] eal: add workaround for __builtin_constant_p
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
@ 2025-02-11 22:01 ` Andre Muezerie
  2025-02-11 22:09   ` Stephen Hemminger
  2025-02-12  0:59   ` fengchengwen
  2025-02-11 22:01 ` [PATCH 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
                   ` (10 subsequent siblings)
  11 siblings, 2 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:01 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Andre Muezerie

There's no MSVC equivalent for compiler extension __builtin_constant_p.
EAL already had __rte_constant which was used as a first attempt to
workaround __builtin_constant_p when using MSVC. However, there are
pieces of code that would benefit from being able to provide a default
value to be used instead of it being always 0 like how it was done by
__rte_constant.

A new macro is added here allowing such default to be provided by the
caller.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/eal/include/generic/rte_pause.h |  2 +-
 lib/eal/include/rte_common.h        | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/eal/include/generic/rte_pause.h b/lib/eal/include/generic/rte_pause.h
index 968c0886d3..57e13807ea 100644
--- a/lib/eal/include/generic/rte_pause.h
+++ b/lib/eal/include/generic/rte_pause.h
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
  *  rte_memory_order_acquire and rte_memory_order_relaxed.
  */
 #define RTE_WAIT_UNTIL_MASKED(addr, mask, cond, expected, memorder) do { \
-	RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder));               \
+	RTE_BUILD_BUG_ON(!__rte_constant_with_default(memorder, 1));     \
 	RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire &&       \
 		(memorder) != rte_memory_order_relaxed);                 \
 	typeof(*(addr)) expected_value = (expected);                     \
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 3f77b7624e..6bdce70551 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -50,6 +50,18 @@ extern "C" {
 #define __rte_constant(e) __extension__(__builtin_constant_p(e))
 #endif
 
+/**
+ * Determine if an expression's value is constant at compile time.
+ * All compilers except MSVC will return 1 if the first argument is a
+ * compile-time constant, and 0 otherwise. MSVC will just return the second
+ * argument as a default value.
+ */
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_constant_with_default(e, def) def
+#else
+#define __rte_constant_with_default(e, def) __extension__(__builtin_constant_p(e))
+#endif
+
 /*
  * RTE_TOOLCHAIN_GCC is defined if the target is built with GCC,
  * while a host application (like pmdinfogen) may have another compiler.
-- 
2.47.2.vfs.0.1


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

* [PATCH 02/10] test_alarm: avoid warning about different qualifiers
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
  2025-02-11 22:01 ` [PATCH 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
@ 2025-02-11 22:01 ` Andre Muezerie
  2025-02-12  0:59   ` fengchengwen
  2025-02-11 22:01 ` [PATCH 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:01 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Andre Muezerie

Compiling with MSVC results in the warning below:

app/test/test_alarm.c(54): warning C4090: 'function':
    different '_Atomic' qualifiers

The fix is to use a macro to explicitly drop the qualifier.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_alarm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/test_alarm.c b/app/test/test_alarm.c
index 9ed8c6f72c..6445f713fe 100644
--- a/app/test/test_alarm.c
+++ b/app/test/test_alarm.c
@@ -51,12 +51,12 @@ test_alarm(void)
 			 "Expected rte_eal_alarm_cancel to fail with null callback parameter");
 
 	/* check if can set a alarm for one second */
-	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(US_PER_SEC, test_alarm_callback, &triggered),
-			    "Setting one second alarm failed");
+	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(US_PER_SEC, test_alarm_callback,
+			    RTE_PTR_UNQUAL(&triggered)), "Setting one second alarm failed");
 
 	/* set a longer alarm that will be canceled. */
-	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(10 * US_PER_SEC, test_alarm_callback, &later),
-			    "Setting ten second alarm failed");
+	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(10 * US_PER_SEC, test_alarm_callback,
+			    RTE_PTR_UNQUAL(&later)), "Setting ten second alarm failed");
 
 	/* wait for alarm to happen */
 	while (rte_atomic_load_explicit(&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)
 	TEST_ASSERT(!rte_atomic_load_explicit(&later, rte_memory_order_acquire),
 		    "Only one alarm should have fired.");
 
-	ret = rte_eal_alarm_cancel(test_alarm_callback, &triggered);
+	ret = rte_eal_alarm_cancel(test_alarm_callback, RTE_PTR_UNQUAL(&triggered));
 	TEST_ASSERT(ret == 0 && rte_errno == ENOENT,
 		    "Canceling alarm after run ret %d: %s", ret, rte_strerror(rte_errno));
 
-	ret = rte_eal_alarm_cancel(test_alarm_callback, &later);
+	ret = rte_eal_alarm_cancel(test_alarm_callback, RTE_PTR_UNQUAL(&later));
 	TEST_ASSERT(ret == 1, "Canceling ten second alarm failed %d: %s",
 		    ret, rte_strerror(rte_errno));
 
-- 
2.47.2.vfs.0.1


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

* [PATCH 03/10] test-pmd: fix printf format string mismatch
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
  2025-02-11 22:01 ` [PATCH 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
  2025-02-11 22:01 ` [PATCH 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
@ 2025-02-11 22:01 ` Andre Muezerie
  2025-02-11 22:10   ` Stephen Hemminger
  2025-02-12  1:01   ` fengchengwen
  2025-02-11 22:02 ` [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
                   ` (8 subsequent siblings)
  11 siblings, 2 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:01 UTC (permalink / raw)
  To: Aman Singh; +Cc: dev, Andre Muezerie

Compiling with MSVC results in warnings like the one below:

app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
    '%d' requires an argument of type 'int',
    but variadic argument 1 has type 'uint64_t'

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test-pmd/csumonly.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d77a140641..6ad9e2a7e9 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				info.l2_len, rte_be_to_cpu_16(info.ethertype),
 				info.l3_len, info.l4_proto, info.l4_len, buf);
 			if (rx_ol_flags & RTE_MBUF_F_RX_LRO)
-				printf("rx: m->lro_segsz=%u\n", m->tso_segsz);
+				printf("rx: m->lro_segsz=%d\n", (int)m->tso_segsz);
 			if (info.is_tunnel == 1)
 				printf("rx: outer_l2_len=%d outer_ethertype=%x "
 					"outer_l3_len=%d\n", info.outer_l2_len,
@@ -1084,7 +1084,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				info.tso_segsz != 0)
 				printf("tx: m->l2_len=%d m->l3_len=%d "
 					"m->l4_len=%d\n",
-					m->l2_len, m->l3_len, m->l4_len);
+					(int)m->l2_len, (int)m->l3_len, (int)m->l4_len);
 			if (info.is_tunnel == 1) {
 				if ((tx_offloads &
 				    RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
@@ -1093,17 +1093,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				    (tx_ol_flags & RTE_MBUF_F_TX_OUTER_IPV6))
 					printf("tx: m->outer_l2_len=%d "
 						"m->outer_l3_len=%d\n",
-						m->outer_l2_len,
-						m->outer_l3_len);
+						(int)m->outer_l2_len,
+						(int)m->outer_l3_len);
 				if (info.tunnel_tso_segsz != 0 &&
 						(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
 							RTE_MBUF_F_TX_UDP_SEG)))
 					printf("tx: m->tso_segsz=%d\n",
-						m->tso_segsz);
+						(int)m->tso_segsz);
 			} else if (info.tso_segsz != 0 &&
 					(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
 						RTE_MBUF_F_TX_UDP_SEG)))
-				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
+				printf("tx: m->tso_segsz=%d\n", (int)m->tso_segsz);
 			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
 			printf("tx: flags=%s", buf);
 			printf("\n");
-- 
2.47.2.vfs.0.1


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

* [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (2 preceding siblings ...)
  2025-02-11 22:01 ` [PATCH 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
@ 2025-02-11 22:02 ` Andre Muezerie
  2025-02-12  1:03   ` fengchengwen
  2025-02-11 22:02 ` [PATCH 05/10] test-pmd: avoid undefined behavior Andre Muezerie
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:02 UTC (permalink / raw)
  To: Aman Singh; +Cc: dev, Andre Muezerie

Compiling with MSVC results in warnings like the one below:

app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
    implicitly converted to 64 bits (was 64-bit shift intended?)

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test-pmd/cmdline.c | 4 ++--
 app/test-pmd/testpmd.c | 2 +-
 app/test-pmd/util.c    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 86d763b66a..2afcf916c0 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result,
 	}
 	old_port_flags = ports[res->port_id].mbuf_dynf;
 	if (!strcmp(res->value, "set")) {
-		ports[res->port_id].mbuf_dynf |= 1UL << flag;
+		ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
 		if (old_port_flags == 0)
 			add_tx_dynf_callback(res->port_id);
 	} else {
-		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
+		ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
 		if (ports[res->port_id].mbuf_dynf == 0)
 			remove_tx_dynf_callback(res->port_id);
 	}
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0520aba0db..0a5b999c3a 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,
 		for (i = 0; i < vmdq_rx_conf->nb_pool_maps; i++) {
 			vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i];
 			vmdq_rx_conf->pool_map[i].pools =
-				1 << (i % vmdq_rx_conf->nb_queue_pools);
+				RTE_BIT64(i % vmdq_rx_conf->nb_queue_pools);
 		}
 		for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
 			vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 5fa05fad16..3934831b19 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
 				MKDUMPSTR(print_buf, buf_size, cur_len,
 					  " - dynf %s: %d",
 					  dynf_names[dynf_index],
-					  !!(ol_flags & (1UL << dynf_index)));
+					  !!(ol_flags & RTE_BIT64(dynf_index)));
 		}
 		if (mb->packet_type) {
 			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-- 
2.47.2.vfs.0.1


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

* [PATCH 05/10] test-pmd: avoid undefined behavior
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (3 preceding siblings ...)
  2025-02-11 22:02 ` [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
@ 2025-02-11 22:02 ` Andre Muezerie
  2025-02-12  1:04   ` fengchengwen
  2025-02-11 22:02 ` [PATCH 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:02 UTC (permalink / raw)
  To: Aman Singh; +Cc: dev, Andre Muezerie

Compiling with MSVC results in warnings like below:

app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
    directive in function-like macro argument list is undefined behavior

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test-pmd/cmdline.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 2afcf916c0..4f0b0340c8 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -9011,6 +9011,18 @@ static void cmd_dump_parsed(void *parsed_result,
 }
 
 static cmdline_parse_token_string_t cmd_dump_dump =
+#ifdef RTE_EXEC_ENV_WINDOWS
+	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
+		"dump_physmem#"
+		"dump_memzone#"
+		"dump_socket_mem#"
+		"dump_struct_sizes#"
+		"dump_ring#"
+		"dump_mempool#"
+		"dump_devargs#"
+		"dump_lcores#"
+		"dump_log_types");
+#else
 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
 		"dump_physmem#"
 		"dump_memzone#"
@@ -9020,10 +9032,9 @@ static cmdline_parse_token_string_t cmd_dump_dump =
 		"dump_mempool#"
 		"dump_devargs#"
 		"dump_lcores#"
-#ifndef RTE_EXEC_ENV_WINDOWS
 		"dump_trace#"
-#endif
 		"dump_log_types");
+#endif
 
 static cmdline_parse_inst_t cmd_dump = {
 	.f = cmd_dump_parsed,  /* function to call */
-- 
2.47.2.vfs.0.1


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

* [PATCH 06/10] test-pmd: avoid non-constant initializer
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (4 preceding siblings ...)
  2025-02-11 22:02 ` [PATCH 05/10] test-pmd: avoid undefined behavior Andre Muezerie
@ 2025-02-11 22:02 ` Andre Muezerie
  2025-02-12  1:04   ` fengchengwen
  2025-02-11 22:02 ` [PATCH 07/10] test-pmd: don't return value from void function Andre Muezerie
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:02 UTC (permalink / raw)
  To: Ori Kam, Aman Singh; +Cc: dev, Andre Muezerie

Compiling with MSVC results in errors like the one below:

app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
    is not a constant

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test-pmd/cmdline_flow.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index e1720e54d7..24323d8891 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,
 		return -1;
 	/* Parse parameter types. */
 	switch (ctx->curr) {
-		static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
-
 	case ITEM_PARAM_IS:
 		index = 0;
 		objmask = 1;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,
 		/* Modify next token to expect a prefix. */
 		if (ctx->next_num < 2)
 			return -1;
-		ctx->next[ctx->next_num - 2] = prefix;
+		ctx->next[ctx->next_num - 2] = NEXT_ENTRY(COMMON_PREFIX);
 		/* Fall through. */
 	case ITEM_PARAM_MASK:
 		index = 2;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,
 			  const char *str, unsigned int len,
 			  void *buf, unsigned int size)
 {
-	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
 	struct action_rss_data *action_rss_data;
 	unsigned int i;
 
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,
 	/* Repeat token. */
 	if (ctx->next_num == RTE_DIM(ctx->next))
 		return -1;
-	ctx->next[ctx->next_num++] = next;
+	ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_TYPE);
 	if (!ctx->object)
 		return len;
 	action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  const char *str, unsigned int len,
 			  void *buf, unsigned int size)
 {
-	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
 	struct action_rss_data *action_rss_data;
 	const struct arg *arg;
 	int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	/* Repeat token. */
 	if (ctx->next_num == RTE_DIM(ctx->next))
 		return -1;
-	ctx->next[ctx->next_num++] = next;
+	ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_QUEUE);
 end:
 	if (!ctx->object)
 		return len;
-- 
2.47.2.vfs.0.1


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

* [PATCH 07/10] test-pmd: don't return value from void function
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (5 preceding siblings ...)
  2025-02-11 22:02 ` [PATCH 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
@ 2025-02-11 22:02 ` Andre Muezerie
  2025-02-12  1:10   ` fengchengwen
  2025-02-11 22:02 ` [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model Andre Muezerie
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:02 UTC (permalink / raw)
  To: Ori Kam, Aman Singh; +Cc: dev, Andre Muezerie

Compiling with MSVC results in the warning below:

app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
    'void' function returning a value

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test-pmd/cmdline_flow.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 24323d8891..15a18db2c7 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)
 	int gtp_psc = -1; /* GTP PSC option index. */
 	const void *src_spec;
 
-	if (in->command == SET_SAMPLE_ACTIONS)
-		return cmd_set_raw_parsed_sample(in);
+	if (in->command == SET_SAMPLE_ACTIONS) {
+		cmd_set_raw_parsed_sample(in);
+		return;
+	}
 	else if (in->command == SET_IPV6_EXT_PUSH ||
-		 in->command == SET_IPV6_EXT_REMOVE)
-		return cmd_set_ipv6_ext_parsed(in);
+			 in->command == SET_IPV6_EXT_REMOVE) {
+		cmd_set_ipv6_ext_parsed(in);
+		return;
+	}
 	RTE_ASSERT(in->command == SET_RAW_ENCAP ||
 		   in->command == SET_RAW_DECAP);
 	if (in->command == SET_RAW_ENCAP) {
-- 
2.47.2.vfs.0.1


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

* [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (6 preceding siblings ...)
  2025-02-11 22:02 ` [PATCH 07/10] test-pmd: don't return value from void function Andre Muezerie
@ 2025-02-11 22:02 ` Andre Muezerie
  2025-02-11 22:12   ` Stephen Hemminger
  2025-02-12  1:16   ` fengchengwen
  2025-02-11 22:02 ` [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
                   ` (3 subsequent siblings)
  11 siblings, 2 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:02 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Konstantin Ananyev; +Cc: dev, Andre Muezerie

Compiling with MSVC results in the error below:

app/test/test_ring_perf.c(197): error C7712: address argument to atomic
    operation must be a pointer to an atomic integer,
    'volatile unsigned int *' is not valid

The fix is to mark lcore_count as atomic when using C11 memory model.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_ring_perf.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 57cd04a124..3bb7577629 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -34,7 +34,11 @@ struct lcore_pair {
 	unsigned c1, c2;
 };
 
-static volatile unsigned lcore_count = 0;
+#ifdef RTE_USE_C11_MEM_MODEL
+static RTE_ATOMIC(unsigned int) lcore_count;
+#else
+static volatile unsigned int lcore_count;
+#endif
 
 static void
 test_ring_print_test_string(unsigned int api_type, int esize,
-- 
2.47.2.vfs.0.1


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

* [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (7 preceding siblings ...)
  2025-02-11 22:02 ` [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model Andre Muezerie
@ 2025-02-11 22:02 ` Andre Muezerie
  2025-02-11 22:13   ` Stephen Hemminger
  2025-02-18 15:35 ` [PATCH 00/10] enable "app" to be compiled with MSVC David Marchand
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-11 22:02 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Andre Muezerie

There's no MSVC equivalent for compiler extension __builtin_constant_p,
so a workaround is needed.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_memcpy_perf.c | 106 ++++++++++++++++++------------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/app/test/test_memcpy_perf.c b/app/test/test_memcpy_perf.c
index 5c05a84619..6091b6f9dd 100644
--- a/app/test/test_memcpy_perf.c
+++ b/app/test/test_memcpy_perf.c
@@ -167,66 +167,66 @@ do_uncached_write(uint8_t *dst, int is_dst_cached,
  * Run a single memcpy performance test. This is a macro to ensure that if
  * the "size" parameter is a constant it won't be converted to a variable.
  */
-#define SINGLE_PERF_TEST(dst, is_dst_cached, dst_uoffset,                   \
-                         src, is_src_cached, src_uoffset, size)             \
-do {                                                                        \
-    unsigned int iter, t;                                                   \
-    size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE];          \
-    uint64_t start_time, total_time = 0;                                    \
-    uint64_t total_time2 = 0;                                               \
-    for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {    \
-        fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,             \
-                         src_addrs, is_src_cached, src_uoffset);            \
-        start_time = rte_rdtsc();                                           \
-        for (t = 0; t < TEST_BATCH_SIZE; t++)                               \
-            rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size);           \
-        total_time += rte_rdtsc() - start_time;                             \
-    }                                                                       \
-    for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {    \
-        fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,             \
-                         src_addrs, is_src_cached, src_uoffset);            \
-        start_time = rte_rdtsc();                                           \
-        for (t = 0; t < TEST_BATCH_SIZE; t++)                               \
-            memcpy(dst+dst_addrs[t], src+src_addrs[t], size);               \
-        total_time2 += rte_rdtsc() - start_time;                            \
-    }                                                                       \
-    printf("%3.0f -", (double)total_time  / TEST_ITERATIONS);                 \
-    printf("%3.0f",   (double)total_time2 / TEST_ITERATIONS);                 \
-    printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \
+#define SINGLE_PERF_TEST(dst, is_dst_cached, dst_uoffset,                         \
+			 src, is_src_cached, src_uoffset, size)                   \
+do {                                                                              \
+	unsigned int iter, t;                                                     \
+	size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE];            \
+	uint64_t start_time, total_time = 0;                                      \
+	uint64_t total_time2 = 0;                                                 \
+	for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {      \
+		fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,           \
+				 src_addrs, is_src_cached, src_uoffset);          \
+		start_time = rte_rdtsc();                                         \
+		for (t = 0; t < TEST_BATCH_SIZE; t++)                             \
+			rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size);     \
+		total_time += rte_rdtsc() - start_time;                           \
+	}                                                                         \
+	for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {      \
+		fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,           \
+				 src_addrs, is_src_cached, src_uoffset);          \
+		start_time = rte_rdtsc();                                         \
+		for (t = 0; t < TEST_BATCH_SIZE; t++)                             \
+			memcpy(dst+dst_addrs[t], src+src_addrs[t], size);         \
+		total_time2 += rte_rdtsc() - start_time;                          \
+	}                                                                         \
+	printf("%3.0f -", (double)total_time  / TEST_ITERATIONS);                 \
+	printf("%3.0f",   (double)total_time2 / TEST_ITERATIONS);                 \
+	printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \
 } while (0)
 
 /* Run aligned memcpy tests for each cached/uncached permutation */
-#define ALL_PERF_TESTS_FOR_SIZE(n)                                       \
-do {                                                                     \
-    if (__builtin_constant_p(n))                                         \
-        printf("\nC%6u", (unsigned)n);                                   \
-    else                                                                 \
-        printf("\n%7u", (unsigned)n);                                    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n);    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n);    \
+#define ALL_PERF_TESTS_FOR_SIZE(n, def)                                      \
+do {                                                                         \
+	if (__rte_constant_with_default(n, def))                             \
+		printf("\nC%6u", (unsigned int)n);                           \
+	else                                                                 \
+		printf("\n%7u", (unsigned int)n);                            \
+	SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n);    \
+	SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n);    \
 } while (0)
 
 /* Run unaligned memcpy tests for each cached/uncached permutation */
-#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(n)                             \
-do {                                                                     \
-    if (__builtin_constant_p(n))                                         \
-        printf("\nC%6u", (unsigned)n);                                   \
-    else                                                                 \
-        printf("\n%7u", (unsigned)n);                                    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n);    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n);    \
+#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(n, def)                            \
+do {                                                                         \
+	if (__rte_constant_with_default(n, def))                             \
+		printf("\nC%6u", (unsigned int)n);                           \
+	else                                                                 \
+		printf("\n%7u", (unsigned int)n);                            \
+	SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n);    \
+	SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n);    \
 } while (0)
 
 /* Run memcpy tests for constant length */
-#define ALL_PERF_TEST_FOR_CONSTANT                                      \
-do {                                                                    \
-    TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U);         \
-    TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U);      \
-    TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U);    \
+#define ALL_PERF_TEST_FOR_CONSTANT                                                \
+do {                                                                              \
+	TEST_CONSTANT(6U, 1); TEST_CONSTANT(64U, 1); TEST_CONSTANT(128U, 1);      \
+	TEST_CONSTANT(192U, 1); TEST_CONSTANT(256U, 1); TEST_CONSTANT(512U, 1);   \
+	TEST_CONSTANT(768U, 1); TEST_CONSTANT(1024U, 1); TEST_CONSTANT(1536U, 1); \
 } while (0)
 
 /* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void)
 {
 	unsigned i;
 	for (i = 0; i < RTE_DIM(buf_sizes); i++) {
-		ALL_PERF_TESTS_FOR_SIZE((size_t)buf_sizes[i]);
+		ALL_PERF_TESTS_FOR_SIZE(buf_sizes[i], 0);
 	}
 }
 
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void)
 {
 	unsigned i;
 	for (i = 0; i < RTE_DIM(buf_sizes); i++) {
-		ALL_PERF_TESTS_FOR_SIZE_UNALIGNED((size_t)buf_sizes[i]);
+		ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(buf_sizes[i], 0);
 	}
 }
 
-- 
2.47.2.vfs.0.1


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

* Re: [PATCH 01/10] eal: add workaround for __builtin_constant_p
  2025-02-11 22:01 ` [PATCH 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
@ 2025-02-11 22:09   ` Stephen Hemminger
  2025-02-12  0:59   ` fengchengwen
  1 sibling, 0 replies; 64+ messages in thread
From: Stephen Hemminger @ 2025-02-11 22:09 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: Tyler Retzlaff, dev

On Tue, 11 Feb 2025 14:01:57 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

> There's no MSVC equivalent for compiler extension __builtin_constant_p.
> EAL already had __rte_constant which was used as a first attempt to
> workaround __builtin_constant_p when using MSVC. However, there are
> pieces of code that would benefit from being able to provide a default
> value to be used instead of it being always 0 like how it was done by
> __rte_constant.
> 
> A new macro is added here allowing such default to be provided by the
> caller.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>

There is a hack way of determining if expression is constant using sizeof
tricks, maybe that would be ideal solution?

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

* Re: [PATCH 03/10] test-pmd: fix printf format string mismatch
  2025-02-11 22:01 ` [PATCH 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
@ 2025-02-11 22:10   ` Stephen Hemminger
  2025-02-12  1:01   ` fengchengwen
  1 sibling, 0 replies; 64+ messages in thread
From: Stephen Hemminger @ 2025-02-11 22:10 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: Aman Singh, dev

On Tue, 11 Feb 2025 14:01:59 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

> Compiling with MSVC results in warnings like the one below:
> 
> app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
>     '%d' requires an argument of type 'int',
>     but variadic argument 1 has type 'uint64_t'
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---

In general, DPDK code prefers to use inttypes.h which has PRIu64 macro for this.

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

* Re: [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model
  2025-02-11 22:02 ` [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model Andre Muezerie
@ 2025-02-11 22:12   ` Stephen Hemminger
  2025-02-12  1:16     ` Andre Muezerie
  2025-02-12  1:16   ` fengchengwen
  1 sibling, 1 reply; 64+ messages in thread
From: Stephen Hemminger @ 2025-02-11 22:12 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: Honnappa Nagarahalli, Konstantin Ananyev, dev

On Tue, 11 Feb 2025 14:02:04 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

> Compiling with MSVC results in the error below:
> 
> app/test/test_ring_perf.c(197): error C7712: address argument to atomic
>     operation must be a pointer to an atomic integer,
>     'volatile unsigned int *' is not valid
> 
> The fix is to mark lcore_count as atomic when using C11 memory model.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>

Prefer using RTE_ATOMIC() all teh time now.

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

* Re: [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
  2025-02-11 22:02 ` [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
@ 2025-02-11 22:13   ` Stephen Hemminger
  2025-02-12  2:07     ` Andre Muezerie
  0 siblings, 1 reply; 64+ messages in thread
From: Stephen Hemminger @ 2025-02-11 22:13 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: Tyler Retzlaff, dev

On Tue, 11 Feb 2025 14:02:05 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

> There's no MSVC equivalent for compiler extension __builtin_constant_p,
> so a workaround is needed.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>

Prefer that __rte_constant worked on all platforms,
but template code is hard to maintain.

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

* Re: [PATCH 01/10] eal: add workaround for __builtin_constant_p
  2025-02-11 22:01 ` [PATCH 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
  2025-02-11 22:09   ` Stephen Hemminger
@ 2025-02-12  0:59   ` fengchengwen
  1 sibling, 0 replies; 64+ messages in thread
From: fengchengwen @ 2025-02-12  0:59 UTC (permalink / raw)
  To: Andre Muezerie, Tyler Retzlaff; +Cc: dev

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:01, Andre Muezerie wrote:
> There's no MSVC equivalent for compiler extension __builtin_constant_p.
> EAL already had __rte_constant which was used as a first attempt to
> workaround __builtin_constant_p when using MSVC. However, there are
> pieces of code that would benefit from being able to provide a default
> value to be used instead of it being always 0 like how it was done by
> __rte_constant.
> 
> A new macro is added here allowing such default to be provided by the
> caller.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>


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

* Re: [PATCH 02/10] test_alarm: avoid warning about different qualifiers
  2025-02-11 22:01 ` [PATCH 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
@ 2025-02-12  0:59   ` fengchengwen
  0 siblings, 0 replies; 64+ messages in thread
From: fengchengwen @ 2025-02-12  0:59 UTC (permalink / raw)
  To: Andre Muezerie, Tyler Retzlaff; +Cc: dev

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:01, Andre Muezerie wrote:
> Compiling with MSVC results in the warning below:
> 
> app/test/test_alarm.c(54): warning C4090: 'function':
>     different '_Atomic' qualifiers
> 
> The fix is to use a macro to explicitly drop the qualifier.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>


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

* Re: [PATCH 03/10] test-pmd: fix printf format string mismatch
  2025-02-11 22:01 ` [PATCH 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
  2025-02-11 22:10   ` Stephen Hemminger
@ 2025-02-12  1:01   ` fengchengwen
  1 sibling, 0 replies; 64+ messages in thread
From: fengchengwen @ 2025-02-12  1:01 UTC (permalink / raw)
  To: Andre Muezerie, Aman Singh; +Cc: dev

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:01, Andre Muezerie wrote:
> Compiling with MSVC results in warnings like the one below:
> 
> app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
>     '%d' requires an argument of type 'int',
>     but variadic argument 1 has type 'uint64_t'
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>


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

* Re: [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion
  2025-02-11 22:02 ` [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
@ 2025-02-12  1:03   ` fengchengwen
  0 siblings, 0 replies; 64+ messages in thread
From: fengchengwen @ 2025-02-12  1:03 UTC (permalink / raw)
  To: Andre Muezerie, Aman Singh; +Cc: dev

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:02, Andre Muezerie wrote:
> Compiling with MSVC results in warnings like the one below:
> 
> app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
>     implicitly converted to 64 bits (was 64-bit shift intended?)
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>


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

* Re: [PATCH 05/10] test-pmd: avoid undefined behavior
  2025-02-11 22:02 ` [PATCH 05/10] test-pmd: avoid undefined behavior Andre Muezerie
@ 2025-02-12  1:04   ` fengchengwen
  0 siblings, 0 replies; 64+ messages in thread
From: fengchengwen @ 2025-02-12  1:04 UTC (permalink / raw)
  To: Andre Muezerie, Aman Singh; +Cc: dev

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:02, Andre Muezerie wrote:
> Compiling with MSVC results in warnings like below:
> 
> app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
>     directive in function-like macro argument list is undefined behavior
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>


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

* Re: [PATCH 06/10] test-pmd: avoid non-constant initializer
  2025-02-11 22:02 ` [PATCH 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
@ 2025-02-12  1:04   ` fengchengwen
  0 siblings, 0 replies; 64+ messages in thread
From: fengchengwen @ 2025-02-12  1:04 UTC (permalink / raw)
  To: Andre Muezerie, Ori Kam, Aman Singh; +Cc: dev

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:02, Andre Muezerie wrote:
> Compiling with MSVC results in errors like the one below:
> 
> app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
>     is not a constant
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>


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

* Re: [PATCH 07/10] test-pmd: don't return value from void function
  2025-02-11 22:02 ` [PATCH 07/10] test-pmd: don't return value from void function Andre Muezerie
@ 2025-02-12  1:10   ` fengchengwen
  0 siblings, 0 replies; 64+ messages in thread
From: fengchengwen @ 2025-02-12  1:10 UTC (permalink / raw)
  To: Andre Muezerie, Ori Kam, Aman Singh; +Cc: dev

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:02, Andre Muezerie wrote:
> Compiling with MSVC results in the warning below:
> 
> app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
>     'void' function returning a value
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>


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

* Re: [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model
  2025-02-11 22:02 ` [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model Andre Muezerie
  2025-02-11 22:12   ` Stephen Hemminger
@ 2025-02-12  1:16   ` fengchengwen
  1 sibling, 0 replies; 64+ messages in thread
From: fengchengwen @ 2025-02-12  1:16 UTC (permalink / raw)
  To: Andre Muezerie, Honnappa Nagarahalli, Konstantin Ananyev; +Cc: dev

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/2/12 6:02, Andre Muezerie wrote:
> Compiling with MSVC results in the error below:
> 
> app/test/test_ring_perf.c(197): error C7712: address argument to atomic
>     operation must be a pointer to an atomic integer,
>     'volatile unsigned int *' is not valid
> 
> The fix is to mark lcore_count as atomic when using C11 memory model.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>


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

* Re: [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model
  2025-02-11 22:12   ` Stephen Hemminger
@ 2025-02-12  1:16     ` Andre Muezerie
  0 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-12  1:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Honnappa Nagarahalli, Konstantin Ananyev, dev

On Tue, Feb 11, 2025 at 02:12:12PM -0800, Stephen Hemminger wrote:
> On Tue, 11 Feb 2025 14:02:04 -0800
> Andre Muezerie <andremue@linux.microsoft.com> wrote:
> 
> > Compiling with MSVC results in the error below:
> > 
> > app/test/test_ring_perf.c(197): error C7712: address argument to atomic
> >     operation must be a pointer to an atomic integer,
> >     'volatile unsigned int *' is not valid
> > 
> > The fix is to mark lcore_count as atomic when using C11 memory model.
> > 
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> 
> Prefer using RTE_ATOMIC() all teh time now.

You mean even when not explicitly using the C11 model, right?

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

* Re: [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
  2025-02-11 22:13   ` Stephen Hemminger
@ 2025-02-12  2:07     ` Andre Muezerie
  0 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-12  2:07 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Tyler Retzlaff, dev

On Tue, Feb 11, 2025 at 02:13:05PM -0800, Stephen Hemminger wrote:
> On Tue, 11 Feb 2025 14:02:05 -0800
> Andre Muezerie <andremue@linux.microsoft.com> wrote:
> 
> > There's no MSVC equivalent for compiler extension __builtin_constant_p,
> > so a workaround is needed.
> > 
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> 
> Prefer that __rte_constant worked on all platforms,
> but template code is hard to maintain.

I'm not a huge fan of __rte_constant_with_default either. Here are some thoughts about it:

In test_memcpy_perf we could get rid of __builtin_constant_p or similar macros and just use the second argument (def) I'm passing to __rte_constant_with_default as the condition in the if() statement. I only used __rte_constant_with_default to keep the source code practically the same when using non-msvc compilers. But I don't see advantages beyond that, other than not having to pass that second parameter (def), which now we have to anyways.

__rte_constant_with_default is needed though in the first patch of this series, unless we decide to remove that extra check where it is being used.

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

* Re: [PATCH 00/10] enable "app" to be compiled with MSVC
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (8 preceding siblings ...)
  2025-02-11 22:02 ` [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
@ 2025-02-18 15:35 ` David Marchand
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
  11 siblings, 0 replies; 64+ messages in thread
From: David Marchand @ 2025-02-18 15:35 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev

On Tue, Feb 11, 2025 at 11:02 PM Andre Muezerie
<andremue@linux.microsoft.com> wrote:
>
> This series fixes many issues that prevent the "app" directory
> from being compiled with MSVC.
>
> Andre Muezerie (10):
>   eal: add workaround for __builtin_constant_p
>   test_alarm: avoid warning about different qualifiers
>   test-pmd: fix printf format string mismatch
>   test-pmd: do explicit 64-bit shift to avoid implicit conversion
>   test-pmd: avoid undefined behavior
>   test-pmd: avoid non-constant initializer
>   test-pmd: don't return value from void function
>   test-pmd: declare lcore_count atomic when using C11 memory model
>   test: add workaround for __builtin_constant_p in test_memcpy_perf
>   app: enable app directory to be compiled with MSVC
>
>  app/meson.build                     |   4 --
>  app/test-pmd/cmdline.c              |  19 +++--
>  app/test-pmd/cmdline_flow.c         |  22 +++---
>  app/test-pmd/csumonly.c             |  12 ++--
>  app/test-pmd/meson.build            |   4 +-
>  app/test-pmd/testpmd.c              |   2 +-
>  app/test-pmd/util.c                 |   2 +-
>  app/test/test_alarm.c               |  12 ++--
>  app/test/test_memcpy_perf.c         | 106 ++++++++++++++--------------
>  app/test/test_ring_perf.c           |   6 +-
>  lib/eal/include/generic/rte_pause.h |   2 +-
>  lib/eal/include/rte_common.h        |  12 ++++
>  12 files changed, 114 insertions(+), 89 deletions(-)

The last patch of the series was not received on the ml.
This prevents CI from testing it.
Please resubmit the whole series.


Thanks.

-- 
David Marchand


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

* [PATCH v2 00/10] enable "app" to be compiled with MSVC
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (9 preceding siblings ...)
  2025-02-18 15:35 ` [PATCH 00/10] enable "app" to be compiled with MSVC David Marchand
@ 2025-02-18 16:31 ` Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
                     ` (9 more replies)
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
  11 siblings, 10 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:31 UTC (permalink / raw)
  To: andremue; +Cc: dev

v2:
- use lcore_count as atomic always, not only when RTE_USE_C11_MEM_MODEL
  is set.
- use PRIu64 in csumonly.c instead of casting variables to int.

This series fixes many issues that prevent the "app" directory
from being compiled with MSVC.

Andre Muezerie (10):
  eal: add workaround for __builtin_constant_p
  test_alarm: avoid warning about different qualifiers
  test-pmd: fix printf format string mismatch
  test-pmd: do explicit 64-bit shift to avoid implicit conversion
  test-pmd: avoid undefined behavior
  test-pmd: avoid non-constant initializer
  test-pmd: don't return value from void function
  test-pmd: declare lcore_count atomic
  test: add workaround for __builtin_constant_p in test_memcpy_perf
  app: enable app directory to be compiled with MSVC

 app/meson.build                     |   4 --
 app/test-pmd/cmdline.c              |  19 +++--
 app/test-pmd/cmdline_flow.c         |  22 +++---
 app/test-pmd/csumonly.c             |  23 +++---
 app/test-pmd/meson.build            |   4 +-
 app/test-pmd/testpmd.c              |   2 +-
 app/test-pmd/util.c                 |   2 +-
 app/test/test_alarm.c               |  12 ++--
 app/test/test_memcpy_perf.c         | 106 ++++++++++++++--------------
 app/test/test_ring_perf.c           |   6 +-
 lib/eal/include/generic/rte_pause.h |   2 +-
 lib/eal/include/rte_common.h        |  12 ++++
 12 files changed, 116 insertions(+), 98 deletions(-)

--
2.48.1.vfs.0.0


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

* [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 17:12     ` Morten Brørup
  2025-02-18 16:32   ` [PATCH v2 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
                     ` (8 subsequent siblings)
  9 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

There's no MSVC equivalent for compiler extension __builtin_constant_p.
EAL already had __rte_constant which was used as a first attempt to
workaround __builtin_constant_p when using MSVC. However, there are
pieces of code that would benefit from being able to provide a default
value to be used instead of it being always 0 like how it was done by
__rte_constant.

A new macro is added here allowing such default to be provided by the
caller.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/include/generic/rte_pause.h |  2 +-
 lib/eal/include/rte_common.h        | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/eal/include/generic/rte_pause.h b/lib/eal/include/generic/rte_pause.h
index 968c0886d3..57e13807ea 100644
--- a/lib/eal/include/generic/rte_pause.h
+++ b/lib/eal/include/generic/rte_pause.h
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
  *  rte_memory_order_acquire and rte_memory_order_relaxed.
  */
 #define RTE_WAIT_UNTIL_MASKED(addr, mask, cond, expected, memorder) do { \
-	RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder));               \
+	RTE_BUILD_BUG_ON(!__rte_constant_with_default(memorder, 1));     \
 	RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire &&       \
 		(memorder) != rte_memory_order_relaxed);                 \
 	typeof(*(addr)) expected_value = (expected);                     \
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 3f77b7624e..6bdce70551 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -50,6 +50,18 @@ extern "C" {
 #define __rte_constant(e) __extension__(__builtin_constant_p(e))
 #endif
 
+/**
+ * Determine if an expression's value is constant at compile time.
+ * All compilers except MSVC will return 1 if the first argument is a
+ * compile-time constant, and 0 otherwise. MSVC will just return the second
+ * argument as a default value.
+ */
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_constant_with_default(e, def) def
+#else
+#define __rte_constant_with_default(e, def) __extension__(__builtin_constant_p(e))
+#endif
+
 /*
  * RTE_TOOLCHAIN_GCC is defined if the target is built with GCC,
  * while a host application (like pmdinfogen) may have another compiler.
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 02/10] test_alarm: avoid warning about different qualifiers
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
                     ` (7 subsequent siblings)
  9 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in the warning below:

app/test/test_alarm.c(54): warning C4090: 'function':
    different '_Atomic' qualifiers

The fix is to use a macro to explicitly drop the qualifier.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_alarm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/test_alarm.c b/app/test/test_alarm.c
index 9ed8c6f72c..6445f713fe 100644
--- a/app/test/test_alarm.c
+++ b/app/test/test_alarm.c
@@ -51,12 +51,12 @@ test_alarm(void)
 			 "Expected rte_eal_alarm_cancel to fail with null callback parameter");
 
 	/* check if can set a alarm for one second */
-	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(US_PER_SEC, test_alarm_callback, &triggered),
-			    "Setting one second alarm failed");
+	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(US_PER_SEC, test_alarm_callback,
+			    RTE_PTR_UNQUAL(&triggered)), "Setting one second alarm failed");
 
 	/* set a longer alarm that will be canceled. */
-	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(10 * US_PER_SEC, test_alarm_callback, &later),
-			    "Setting ten second alarm failed");
+	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(10 * US_PER_SEC, test_alarm_callback,
+			    RTE_PTR_UNQUAL(&later)), "Setting ten second alarm failed");
 
 	/* wait for alarm to happen */
 	while (rte_atomic_load_explicit(&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)
 	TEST_ASSERT(!rte_atomic_load_explicit(&later, rte_memory_order_acquire),
 		    "Only one alarm should have fired.");
 
-	ret = rte_eal_alarm_cancel(test_alarm_callback, &triggered);
+	ret = rte_eal_alarm_cancel(test_alarm_callback, RTE_PTR_UNQUAL(&triggered));
 	TEST_ASSERT(ret == 0 && rte_errno == ENOENT,
 		    "Canceling alarm after run ret %d: %s", ret, rte_strerror(rte_errno));
 
-	ret = rte_eal_alarm_cancel(test_alarm_callback, &later);
+	ret = rte_eal_alarm_cancel(test_alarm_callback, RTE_PTR_UNQUAL(&later));
 	TEST_ASSERT(ret == 1, "Canceling ten second alarm failed %d: %s",
 		    ret, rte_strerror(rte_errno));
 
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 03/10] test-pmd: fix printf format string mismatch
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:46     ` Bruce Richardson
  2025-02-18 16:32   ` [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
                     ` (6 subsequent siblings)
  9 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in warnings like the one below:

app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
    '%d' requires an argument of type 'int',
    but variadic argument 1 has type 'uint64_t'

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/csumonly.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d77a140641..8de5ad6ad9 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				info.l2_len, rte_be_to_cpu_16(info.ethertype),
 				info.l3_len, info.l4_proto, info.l4_len, buf);
 			if (rx_ol_flags & RTE_MBUF_F_RX_LRO)
-				printf("rx: m->lro_segsz=%u\n", m->tso_segsz);
+				printf("rx: m->lro_segsz=%" PRIu64 "\n", (uint64_t)m->tso_segsz);
 			if (info.is_tunnel == 1)
 				printf("rx: outer_l2_len=%d outer_ethertype=%x "
 					"outer_l3_len=%d\n", info.outer_l2_len,
@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					    RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
 					    RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) ||
 				info.tso_segsz != 0)
-				printf("tx: m->l2_len=%d m->l3_len=%d "
-					"m->l4_len=%d\n",
-					m->l2_len, m->l3_len, m->l4_len);
+				printf("tx: m->l2_len=%" PRIu64 " m->l3_len=%" PRIu64
+					" m->l4_len=%" PRIu64 "\n",
+					(uint64_t)m->l2_len, (uint64_t)m->l3_len,
+					(uint64_t)m->l4_len);
 			if (info.is_tunnel == 1) {
 				if ((tx_offloads &
 				    RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
 				    (tx_offloads &
 				    RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ||
 				    (tx_ol_flags & RTE_MBUF_F_TX_OUTER_IPV6))
-					printf("tx: m->outer_l2_len=%d "
-						"m->outer_l3_len=%d\n",
-						m->outer_l2_len,
-						m->outer_l3_len);
+					printf("tx: m->outer_l2_len=%" PRIu64
+						" m->outer_l3_len=%" PRIu64 "\n",
+						(uint64_t)m->outer_l2_len,
+						(uint64_t)m->outer_l3_len);
 				if (info.tunnel_tso_segsz != 0 &&
 						(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
 							RTE_MBUF_F_TX_UDP_SEG)))
-					printf("tx: m->tso_segsz=%d\n",
-						m->tso_segsz);
+					printf("tx: m->tso_segsz=%" PRIu64 "\n",
+						(uint64_t)m->tso_segsz);
 			} else if (info.tso_segsz != 0 &&
 					(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
 						RTE_MBUF_F_TX_UDP_SEG)))
-				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
+				printf("tx: m->tso_segsz=%" PRIu64 "\n", (uint64_t)m->tso_segsz);
 			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
 			printf("tx: flags=%s", buf);
 			printf("\n");
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
                     ` (2 preceding siblings ...)
  2025-02-18 16:32   ` [PATCH v2 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:47     ` Bruce Richardson
  2025-02-18 16:32   ` [PATCH v2 05/10] test-pmd: avoid undefined behavior Andre Muezerie
                     ` (5 subsequent siblings)
  9 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in warnings like the one below:

app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
    implicitly converted to 64 bits (was 64-bit shift intended?)

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline.c | 4 ++--
 app/test-pmd/testpmd.c | 2 +-
 app/test-pmd/util.c    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 86d763b66a..2afcf916c0 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result,
 	}
 	old_port_flags = ports[res->port_id].mbuf_dynf;
 	if (!strcmp(res->value, "set")) {
-		ports[res->port_id].mbuf_dynf |= 1UL << flag;
+		ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
 		if (old_port_flags == 0)
 			add_tx_dynf_callback(res->port_id);
 	} else {
-		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
+		ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
 		if (ports[res->port_id].mbuf_dynf == 0)
 			remove_tx_dynf_callback(res->port_id);
 	}
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0520aba0db..0a5b999c3a 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,
 		for (i = 0; i < vmdq_rx_conf->nb_pool_maps; i++) {
 			vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i];
 			vmdq_rx_conf->pool_map[i].pools =
-				1 << (i % vmdq_rx_conf->nb_queue_pools);
+				RTE_BIT64(i % vmdq_rx_conf->nb_queue_pools);
 		}
 		for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
 			vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 5fa05fad16..3934831b19 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
 				MKDUMPSTR(print_buf, buf_size, cur_len,
 					  " - dynf %s: %d",
 					  dynf_names[dynf_index],
-					  !!(ol_flags & (1UL << dynf_index)));
+					  !!(ol_flags & RTE_BIT64(dynf_index)));
 		}
 		if (mb->packet_type) {
 			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 05/10] test-pmd: avoid undefined behavior
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
                     ` (3 preceding siblings ...)
  2025-02-18 16:32   ` [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:41     ` Bruce Richardson
  2025-02-18 16:32   ` [PATCH v2 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
                     ` (4 subsequent siblings)
  9 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in warnings like below:

app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
    directive in function-like macro argument list is undefined behavior

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 2afcf916c0..4f0b0340c8 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -9011,6 +9011,18 @@ static void cmd_dump_parsed(void *parsed_result,
 }
 
 static cmdline_parse_token_string_t cmd_dump_dump =
+#ifdef RTE_EXEC_ENV_WINDOWS
+	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
+		"dump_physmem#"
+		"dump_memzone#"
+		"dump_socket_mem#"
+		"dump_struct_sizes#"
+		"dump_ring#"
+		"dump_mempool#"
+		"dump_devargs#"
+		"dump_lcores#"
+		"dump_log_types");
+#else
 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
 		"dump_physmem#"
 		"dump_memzone#"
@@ -9020,10 +9032,9 @@ static cmdline_parse_token_string_t cmd_dump_dump =
 		"dump_mempool#"
 		"dump_devargs#"
 		"dump_lcores#"
-#ifndef RTE_EXEC_ENV_WINDOWS
 		"dump_trace#"
-#endif
 		"dump_log_types");
+#endif
 
 static cmdline_parse_inst_t cmd_dump = {
 	.f = cmd_dump_parsed,  /* function to call */
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 06/10] test-pmd: avoid non-constant initializer
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
                     ` (4 preceding siblings ...)
  2025-02-18 16:32   ` [PATCH v2 05/10] test-pmd: avoid undefined behavior Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 07/10] test-pmd: don't return value from void function Andre Muezerie
                     ` (3 subsequent siblings)
  9 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in errors like the one below:

app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
    is not a constant

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline_flow.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index e1720e54d7..24323d8891 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,
 		return -1;
 	/* Parse parameter types. */
 	switch (ctx->curr) {
-		static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
-
 	case ITEM_PARAM_IS:
 		index = 0;
 		objmask = 1;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,
 		/* Modify next token to expect a prefix. */
 		if (ctx->next_num < 2)
 			return -1;
-		ctx->next[ctx->next_num - 2] = prefix;
+		ctx->next[ctx->next_num - 2] = NEXT_ENTRY(COMMON_PREFIX);
 		/* Fall through. */
 	case ITEM_PARAM_MASK:
 		index = 2;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,
 			  const char *str, unsigned int len,
 			  void *buf, unsigned int size)
 {
-	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
 	struct action_rss_data *action_rss_data;
 	unsigned int i;
 
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,
 	/* Repeat token. */
 	if (ctx->next_num == RTE_DIM(ctx->next))
 		return -1;
-	ctx->next[ctx->next_num++] = next;
+	ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_TYPE);
 	if (!ctx->object)
 		return len;
 	action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  const char *str, unsigned int len,
 			  void *buf, unsigned int size)
 {
-	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
 	struct action_rss_data *action_rss_data;
 	const struct arg *arg;
 	int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	/* Repeat token. */
 	if (ctx->next_num == RTE_DIM(ctx->next))
 		return -1;
-	ctx->next[ctx->next_num++] = next;
+	ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_QUEUE);
 end:
 	if (!ctx->object)
 		return len;
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 07/10] test-pmd: don't return value from void function
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
                     ` (5 preceding siblings ...)
  2025-02-18 16:32   ` [PATCH v2 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:42     ` Bruce Richardson
  2025-02-18 16:32   ` [PATCH v2 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
                     ` (2 subsequent siblings)
  9 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in the warning below:

app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
    'void' function returning a value

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline_flow.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 24323d8891..15a18db2c7 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)
 	int gtp_psc = -1; /* GTP PSC option index. */
 	const void *src_spec;
 
-	if (in->command == SET_SAMPLE_ACTIONS)
-		return cmd_set_raw_parsed_sample(in);
+	if (in->command == SET_SAMPLE_ACTIONS) {
+		cmd_set_raw_parsed_sample(in);
+		return;
+	}
 	else if (in->command == SET_IPV6_EXT_PUSH ||
-		 in->command == SET_IPV6_EXT_REMOVE)
-		return cmd_set_ipv6_ext_parsed(in);
+			 in->command == SET_IPV6_EXT_REMOVE) {
+		cmd_set_ipv6_ext_parsed(in);
+		return;
+	}
 	RTE_ASSERT(in->command == SET_RAW_ENCAP ||
 		   in->command == SET_RAW_DECAP);
 	if (in->command == SET_RAW_ENCAP) {
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 08/10] test-pmd: declare lcore_count atomic
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
                     ` (6 preceding siblings ...)
  2025-02-18 16:32   ` [PATCH v2 07/10] test-pmd: don't return value from void function Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
  9 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in the error below:

app/test/test_ring_perf.c(197): error C7712: address argument to atomic
    operation must be a pointer to an atomic integer,
    'volatile unsigned int *' is not valid

The fix is to mark lcore_count as atomic.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_ring_perf.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 57cd04a124..366e256323 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -34,7 +34,7 @@ struct lcore_pair {
 	unsigned c1, c2;
 };
 
-static volatile unsigned lcore_count = 0;
+static RTE_ATOMIC(unsigned int) lcore_count;
 
 static void
 test_ring_print_test_string(unsigned int api_type, int esize,
@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)
 	unsigned int n_remaining;
 	const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i];
 
-#ifdef RTE_USE_C11_MEM_MODEL
 	if (rte_atomic_fetch_add_explicit(&lcore_count, 1, rte_memory_order_relaxed) + 1 != 2)
-#else
-	if (__sync_add_and_fetch(&lcore_count, 1) != 2)
-#endif
 		while(lcore_count != 2)
 			rte_pause();
 
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
                     ` (7 preceding siblings ...)
  2025-02-18 16:32   ` [PATCH v2 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:32   ` [PATCH v2 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
  9 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev

There's no MSVC equivalent for compiler extension __builtin_constant_p,
so a workaround is needed.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_memcpy_perf.c | 106 ++++++++++++++++++------------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/app/test/test_memcpy_perf.c b/app/test/test_memcpy_perf.c
index 5c05a84619..6091b6f9dd 100644
--- a/app/test/test_memcpy_perf.c
+++ b/app/test/test_memcpy_perf.c
@@ -167,66 +167,66 @@ do_uncached_write(uint8_t *dst, int is_dst_cached,
  * Run a single memcpy performance test. This is a macro to ensure that if
  * the "size" parameter is a constant it won't be converted to a variable.
  */
-#define SINGLE_PERF_TEST(dst, is_dst_cached, dst_uoffset,                   \
-                         src, is_src_cached, src_uoffset, size)             \
-do {                                                                        \
-    unsigned int iter, t;                                                   \
-    size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE];          \
-    uint64_t start_time, total_time = 0;                                    \
-    uint64_t total_time2 = 0;                                               \
-    for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {    \
-        fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,             \
-                         src_addrs, is_src_cached, src_uoffset);            \
-        start_time = rte_rdtsc();                                           \
-        for (t = 0; t < TEST_BATCH_SIZE; t++)                               \
-            rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size);           \
-        total_time += rte_rdtsc() - start_time;                             \
-    }                                                                       \
-    for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {    \
-        fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,             \
-                         src_addrs, is_src_cached, src_uoffset);            \
-        start_time = rte_rdtsc();                                           \
-        for (t = 0; t < TEST_BATCH_SIZE; t++)                               \
-            memcpy(dst+dst_addrs[t], src+src_addrs[t], size);               \
-        total_time2 += rte_rdtsc() - start_time;                            \
-    }                                                                       \
-    printf("%3.0f -", (double)total_time  / TEST_ITERATIONS);                 \
-    printf("%3.0f",   (double)total_time2 / TEST_ITERATIONS);                 \
-    printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \
+#define SINGLE_PERF_TEST(dst, is_dst_cached, dst_uoffset,                         \
+			 src, is_src_cached, src_uoffset, size)                   \
+do {                                                                              \
+	unsigned int iter, t;                                                     \
+	size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE];            \
+	uint64_t start_time, total_time = 0;                                      \
+	uint64_t total_time2 = 0;                                                 \
+	for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {      \
+		fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,           \
+				 src_addrs, is_src_cached, src_uoffset);          \
+		start_time = rte_rdtsc();                                         \
+		for (t = 0; t < TEST_BATCH_SIZE; t++)                             \
+			rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size);     \
+		total_time += rte_rdtsc() - start_time;                           \
+	}                                                                         \
+	for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {      \
+		fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,           \
+				 src_addrs, is_src_cached, src_uoffset);          \
+		start_time = rte_rdtsc();                                         \
+		for (t = 0; t < TEST_BATCH_SIZE; t++)                             \
+			memcpy(dst+dst_addrs[t], src+src_addrs[t], size);         \
+		total_time2 += rte_rdtsc() - start_time;                          \
+	}                                                                         \
+	printf("%3.0f -", (double)total_time  / TEST_ITERATIONS);                 \
+	printf("%3.0f",   (double)total_time2 / TEST_ITERATIONS);                 \
+	printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \
 } while (0)
 
 /* Run aligned memcpy tests for each cached/uncached permutation */
-#define ALL_PERF_TESTS_FOR_SIZE(n)                                       \
-do {                                                                     \
-    if (__builtin_constant_p(n))                                         \
-        printf("\nC%6u", (unsigned)n);                                   \
-    else                                                                 \
-        printf("\n%7u", (unsigned)n);                                    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n);    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n);    \
+#define ALL_PERF_TESTS_FOR_SIZE(n, def)                                      \
+do {                                                                         \
+	if (__rte_constant_with_default(n, def))                             \
+		printf("\nC%6u", (unsigned int)n);                           \
+	else                                                                 \
+		printf("\n%7u", (unsigned int)n);                            \
+	SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n);    \
+	SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n);    \
 } while (0)
 
 /* Run unaligned memcpy tests for each cached/uncached permutation */
-#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(n)                             \
-do {                                                                     \
-    if (__builtin_constant_p(n))                                         \
-        printf("\nC%6u", (unsigned)n);                                   \
-    else                                                                 \
-        printf("\n%7u", (unsigned)n);                                    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n);    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n);    \
+#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(n, def)                            \
+do {                                                                         \
+	if (__rte_constant_with_default(n, def))                             \
+		printf("\nC%6u", (unsigned int)n);                           \
+	else                                                                 \
+		printf("\n%7u", (unsigned int)n);                            \
+	SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n);    \
+	SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n);    \
 } while (0)
 
 /* Run memcpy tests for constant length */
-#define ALL_PERF_TEST_FOR_CONSTANT                                      \
-do {                                                                    \
-    TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U);         \
-    TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U);      \
-    TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U);    \
+#define ALL_PERF_TEST_FOR_CONSTANT                                                \
+do {                                                                              \
+	TEST_CONSTANT(6U, 1); TEST_CONSTANT(64U, 1); TEST_CONSTANT(128U, 1);      \
+	TEST_CONSTANT(192U, 1); TEST_CONSTANT(256U, 1); TEST_CONSTANT(512U, 1);   \
+	TEST_CONSTANT(768U, 1); TEST_CONSTANT(1024U, 1); TEST_CONSTANT(1536U, 1); \
 } while (0)
 
 /* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void)
 {
 	unsigned i;
 	for (i = 0; i < RTE_DIM(buf_sizes); i++) {
-		ALL_PERF_TESTS_FOR_SIZE((size_t)buf_sizes[i]);
+		ALL_PERF_TESTS_FOR_SIZE(buf_sizes[i], 0);
 	}
 }
 
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void)
 {
 	unsigned i;
 	for (i = 0; i < RTE_DIM(buf_sizes); i++) {
-		ALL_PERF_TESTS_FOR_SIZE_UNALIGNED((size_t)buf_sizes[i]);
+		ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(buf_sizes[i], 0);
 	}
 }
 
-- 
2.48.1.vfs.0.0


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

* [PATCH v2 10/10] app: enable app directory to be compiled with MSVC
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
                     ` (8 preceding siblings ...)
  2025-02-18 16:32   ` [PATCH v2 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
@ 2025-02-18 16:32   ` Andre Muezerie
  2025-02-18 16:49     ` Bruce Richardson
  2025-02-19  9:15     ` David Marchand
  9 siblings, 2 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 16:32 UTC (permalink / raw)
  To: andremue; +Cc: dev

Enabled "app" directory to be compiled with MSVC along with all its
contents.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/meson.build          | 4 ----
 app/test-pmd/meson.build | 4 +++-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index e2db888ae1..1798db3ae4 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -1,10 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
-if is_ms_compiler
-    subdir_done()
-endif
-
 disable_apps = ',' + get_option('disable_apps')
 disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
 
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index f1c36529b4..8e8863812a 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -3,7 +3,9 @@
 
 # override default name to drop the hyphen
 name = 'testpmd'
-cflags += '-Wno-deprecated-declarations'
+if cc.has_argument('-Wno-deprecated-declarations')
+    cflags += '-Wno-deprecated-declarations'
+endif
 sources = files(
         '5tswap.c',
         'cmdline.c',
-- 
2.48.1.vfs.0.0


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

* Re: [PATCH v2 05/10] test-pmd: avoid undefined behavior
  2025-02-18 16:32   ` [PATCH v2 05/10] test-pmd: avoid undefined behavior Andre Muezerie
@ 2025-02-18 16:41     ` Bruce Richardson
  2025-02-19 17:09       ` Andre Muezerie
  0 siblings, 1 reply; 64+ messages in thread
From: Bruce Richardson @ 2025-02-18 16:41 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, Chengwen Feng

On Tue, Feb 18, 2025 at 08:32:04AM -0800, Andre Muezerie wrote:
> Compiling with MSVC results in warnings like below:
> 
> app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
>     directive in function-like macro argument list is undefined behavior
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  app/test-pmd/cmdline.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 2afcf916c0..4f0b0340c8 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -9011,6 +9011,18 @@ static void cmd_dump_parsed(void *parsed_result,
>  }
>  
>  static cmdline_parse_token_string_t cmd_dump_dump =
> +#ifdef RTE_EXEC_ENV_WINDOWS
> +	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
> +		"dump_physmem#"
> +		"dump_memzone#"
> +		"dump_socket_mem#"
> +		"dump_struct_sizes#"
> +		"dump_ring#"
> +		"dump_mempool#"
> +		"dump_devargs#"
> +		"dump_lcores#"
> +		"dump_log_types");
> +#else
>  	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
>  		"dump_physmem#"
>  		"dump_memzone#"
> @@ -9020,10 +9032,9 @@ static cmdline_parse_token_string_t cmd_dump_dump =
>  		"dump_mempool#"
>  		"dump_devargs#"
>  		"dump_lcores#"
> -#ifndef RTE_EXEC_ENV_WINDOWS
>  		"dump_trace#"
> -#endif
>  		"dump_log_types");
> +#endif
>  

Rather than defining two separate lists, is a better fix not to provide a
dummy implementation of dump_trace for windows, that returns e.g. TEST_SKIPPED.

/Bruce

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

* Re: [PATCH v2 07/10] test-pmd: don't return value from void function
  2025-02-18 16:32   ` [PATCH v2 07/10] test-pmd: don't return value from void function Andre Muezerie
@ 2025-02-18 16:42     ` Bruce Richardson
  0 siblings, 0 replies; 64+ messages in thread
From: Bruce Richardson @ 2025-02-18 16:42 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, Chengwen Feng

On Tue, Feb 18, 2025 at 08:32:06AM -0800, Andre Muezerie wrote:
> Compiling with MSVC results in the warning below:
> 
> app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
>     'void' function returning a value
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>


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

* Re: [PATCH v2 03/10] test-pmd: fix printf format string mismatch
  2025-02-18 16:32   ` [PATCH v2 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
@ 2025-02-18 16:46     ` Bruce Richardson
  2025-02-18 17:03       ` Andre Muezerie
  0 siblings, 1 reply; 64+ messages in thread
From: Bruce Richardson @ 2025-02-18 16:46 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, Chengwen Feng

On Tue, Feb 18, 2025 at 08:32:02AM -0800, Andre Muezerie wrote:
> Compiling with MSVC results in warnings like the one below:
> 
> app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
>     '%d' requires an argument of type 'int',
>     but variadic argument 1 has type 'uint64_t'
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  app/test-pmd/csumonly.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
> index d77a140641..8de5ad6ad9 100644
> --- a/app/test-pmd/csumonly.c
> +++ b/app/test-pmd/csumonly.c
> @@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
>  				info.l2_len, rte_be_to_cpu_16(info.ethertype),
>  				info.l3_len, info.l4_proto, info.l4_len, buf);
>  			if (rx_ol_flags & RTE_MBUF_F_RX_LRO)
> -				printf("rx: m->lro_segsz=%u\n", m->tso_segsz);
> +				printf("rx: m->lro_segsz=%" PRIu64 "\n", (uint64_t)m->tso_segsz);

tso_segsz is already uint64_t, so no need for the cast.

>  			if (info.is_tunnel == 1)
>  				printf("rx: outer_l2_len=%d outer_ethertype=%x "
>  					"outer_l3_len=%d\n", info.outer_l2_len,
> @@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
>  					    RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
>  					    RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) ||
>  				info.tso_segsz != 0)
> -				printf("tx: m->l2_len=%d m->l3_len=%d "
> -					"m->l4_len=%d\n",
> -					m->l2_len, m->l3_len, m->l4_len);
> +				printf("tx: m->l2_len=%" PRIu64 " m->l3_len=%" PRIu64
> +					" m->l4_len=%" PRIu64 "\n",
> +					(uint64_t)m->l2_len, (uint64_t)m->l3_len,
> +					(uint64_t)m->l4_len);

Same here, using casts and a changed print format seems wrong in the patch.
Either we change the format string to match the variable type, or we cast
the variables to match the format string. We should not do both, IMHO.

>  			if (info.is_tunnel == 1) {
>  				if ((tx_offloads &
>  				    RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
>  				    (tx_offloads &
>  				    RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ||
>  				    (tx_ol_flags & RTE_MBUF_F_TX_OUTER_IPV6))
> -					printf("tx: m->outer_l2_len=%d "
> -						"m->outer_l3_len=%d\n",
> -						m->outer_l2_len,
> -						m->outer_l3_len);
> +					printf("tx: m->outer_l2_len=%" PRIu64
> +						" m->outer_l3_len=%" PRIu64 "\n",
> +						(uint64_t)m->outer_l2_len,
> +						(uint64_t)m->outer_l3_len);
>  				if (info.tunnel_tso_segsz != 0 &&
>  						(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
>  							RTE_MBUF_F_TX_UDP_SEG)))
> -					printf("tx: m->tso_segsz=%d\n",
> -						m->tso_segsz);
> +					printf("tx: m->tso_segsz=%" PRIu64 "\n",
> +						(uint64_t)m->tso_segsz);
>  			} else if (info.tso_segsz != 0 &&
>  					(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
>  						RTE_MBUF_F_TX_UDP_SEG)))
> -				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
> +				printf("tx: m->tso_segsz=%" PRIu64 "\n", (uint64_t)m->tso_segsz);
>  			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
>  			printf("tx: flags=%s", buf);
>  			printf("\n");
> -- 
> 2.48.1.vfs.0.0
> 

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

* Re: [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion
  2025-02-18 16:32   ` [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
@ 2025-02-18 16:47     ` Bruce Richardson
  0 siblings, 0 replies; 64+ messages in thread
From: Bruce Richardson @ 2025-02-18 16:47 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, Chengwen Feng

On Tue, Feb 18, 2025 at 08:32:03AM -0800, Andre Muezerie wrote:
> Compiling with MSVC results in warnings like the one below:
> 
> app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
>     implicitly converted to 64 bits (was 64-bit shift intended?)
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>


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

* Re: [PATCH v2 10/10] app: enable app directory to be compiled with MSVC
  2025-02-18 16:32   ` [PATCH v2 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
@ 2025-02-18 16:49     ` Bruce Richardson
  2025-02-19  9:15     ` David Marchand
  1 sibling, 0 replies; 64+ messages in thread
From: Bruce Richardson @ 2025-02-18 16:49 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev

On Tue, Feb 18, 2025 at 08:32:09AM -0800, Andre Muezerie wrote:
> Enabled "app" directory to be compiled with MSVC along with all its
> contents.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
>  app/meson.build          | 4 ----
>  app/test-pmd/meson.build | 4 +++-
>  2 files changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/app/meson.build b/app/meson.build
> index e2db888ae1..1798db3ae4 100644
> --- a/app/meson.build
> +++ b/app/meson.build
> @@ -1,10 +1,6 @@
>  # SPDX-License-Identifier: BSD-3-Clause
>  # Copyright(c) 2017-2019 Intel Corporation
>  
> -if is_ms_compiler
> -    subdir_done()
> -endif
> -
>  disable_apps = ',' + get_option('disable_apps')
>  disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
>  
> diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
> index f1c36529b4..8e8863812a 100644
> --- a/app/test-pmd/meson.build
> +++ b/app/test-pmd/meson.build
> @@ -3,7 +3,9 @@
>  
>  # override default name to drop the hyphen
>  name = 'testpmd'
> -cflags += '-Wno-deprecated-declarations'
> +if cc.has_argument('-Wno-deprecated-declarations')
> +    cflags += '-Wno-deprecated-declarations'
> +endif
>  sources = files(
>          '5tswap.c',
>          'cmdline.c',
> -- 
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

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

* Re: [PATCH v2 03/10] test-pmd: fix printf format string mismatch
  2025-02-18 16:46     ` Bruce Richardson
@ 2025-02-18 17:03       ` Andre Muezerie
  2025-02-18 17:07         ` Bruce Richardson
  0 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-18 17:03 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Chengwen Feng

On Tue, Feb 18, 2025 at 04:46:56PM +0000, Bruce Richardson wrote:
> On Tue, Feb 18, 2025 at 08:32:02AM -0800, Andre Muezerie wrote:
> > Compiling with MSVC results in warnings like the one below:
> > 
> > app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
> >     '%d' requires an argument of type 'int',
> >     but variadic argument 1 has type 'uint64_t'
> > 
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> > ---
> >  app/test-pmd/csumonly.c | 23 ++++++++++++-----------
> >  1 file changed, 12 insertions(+), 11 deletions(-)
> > 
> > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
> > index d77a140641..8de5ad6ad9 100644
> > --- a/app/test-pmd/csumonly.c
> > +++ b/app/test-pmd/csumonly.c
> > @@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
> >  				info.l2_len, rte_be_to_cpu_16(info.ethertype),
> >  				info.l3_len, info.l4_proto, info.l4_len, buf);
> >  			if (rx_ol_flags & RTE_MBUF_F_RX_LRO)
> > -				printf("rx: m->lro_segsz=%u\n", m->tso_segsz);
> > +				printf("rx: m->lro_segsz=%" PRIu64 "\n", (uint64_t)m->tso_segsz);
> 
> tso_segsz is already uint64_t, so no need for the cast.

The compilers differ in behavior here. tso_segsz only uses 16 bits of the uint64_t,
and gcc tries to be smart about it and implicitly converts tso_segsz into an int
(since it fits into an int). Msvc does not do that, and keeps the type for tso_segsz
as uint64_t. To support both compilers it seems there's no way to avoid the cast.

> 
> >  			if (info.is_tunnel == 1)
> >  				printf("rx: outer_l2_len=%d outer_ethertype=%x "
> >  					"outer_l3_len=%d\n", info.outer_l2_len,
> > @@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
> >  					    RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
> >  					    RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) ||
> >  				info.tso_segsz != 0)
> > -				printf("tx: m->l2_len=%d m->l3_len=%d "
> > -					"m->l4_len=%d\n",
> > -					m->l2_len, m->l3_len, m->l4_len);
> > +				printf("tx: m->l2_len=%" PRIu64 " m->l3_len=%" PRIu64
> > +					" m->l4_len=%" PRIu64 "\n",
> > +					(uint64_t)m->l2_len, (uint64_t)m->l3_len,
> > +					(uint64_t)m->l4_len);
> 
> Same here, using casts and a changed print format seems wrong in the patch.
> Either we change the format string to match the variable type, or we cast
> the variables to match the format string. We should not do both, IMHO.

I also normally prefer to not see unnecessary casts in the code, but it looks like
it is needed in this case, as explained above.

> 
> >  			if (info.is_tunnel == 1) {
> >  				if ((tx_offloads &
> >  				    RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
> >  				    (tx_offloads &
> >  				    RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ||
> >  				    (tx_ol_flags & RTE_MBUF_F_TX_OUTER_IPV6))
> > -					printf("tx: m->outer_l2_len=%d "
> > -						"m->outer_l3_len=%d\n",
> > -						m->outer_l2_len,
> > -						m->outer_l3_len);
> > +					printf("tx: m->outer_l2_len=%" PRIu64
> > +						" m->outer_l3_len=%" PRIu64 "\n",
> > +						(uint64_t)m->outer_l2_len,
> > +						(uint64_t)m->outer_l3_len);
> >  				if (info.tunnel_tso_segsz != 0 &&
> >  						(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
> >  							RTE_MBUF_F_TX_UDP_SEG)))
> > -					printf("tx: m->tso_segsz=%d\n",
> > -						m->tso_segsz);
> > +					printf("tx: m->tso_segsz=%" PRIu64 "\n",
> > +						(uint64_t)m->tso_segsz);
> >  			} else if (info.tso_segsz != 0 &&
> >  					(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
> >  						RTE_MBUF_F_TX_UDP_SEG)))
> > -				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
> > +				printf("tx: m->tso_segsz=%" PRIu64 "\n", (uint64_t)m->tso_segsz);
> >  			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
> >  			printf("tx: flags=%s", buf);
> >  			printf("\n");
> > -- 
> > 2.48.1.vfs.0.0
> > 

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

* Re: [PATCH v2 03/10] test-pmd: fix printf format string mismatch
  2025-02-18 17:03       ` Andre Muezerie
@ 2025-02-18 17:07         ` Bruce Richardson
  2025-02-19 17:08           ` Andre Muezerie
  0 siblings, 1 reply; 64+ messages in thread
From: Bruce Richardson @ 2025-02-18 17:07 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, Chengwen Feng

On Tue, Feb 18, 2025 at 09:03:01AM -0800, Andre Muezerie wrote:
> On Tue, Feb 18, 2025 at 04:46:56PM +0000, Bruce Richardson wrote:
> > On Tue, Feb 18, 2025 at 08:32:02AM -0800, Andre Muezerie wrote:
> > > Compiling with MSVC results in warnings like the one below:
> > > 
> > > app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
> > >     '%d' requires an argument of type 'int',
> > >     but variadic argument 1 has type 'uint64_t'
> > > 
> > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> > > ---
> > >  app/test-pmd/csumonly.c | 23 ++++++++++++-----------
> > >  1 file changed, 12 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
> > > index d77a140641..8de5ad6ad9 100644
> > > --- a/app/test-pmd/csumonly.c
> > > +++ b/app/test-pmd/csumonly.c
> > > @@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
> > >  				info.l2_len, rte_be_to_cpu_16(info.ethertype),
> > >  				info.l3_len, info.l4_proto, info.l4_len, buf);
> > >  			if (rx_ol_flags & RTE_MBUF_F_RX_LRO)
> > > -				printf("rx: m->lro_segsz=%u\n", m->tso_segsz);
> > > +				printf("rx: m->lro_segsz=%" PRIu64 "\n", (uint64_t)m->tso_segsz);
> > 
> > tso_segsz is already uint64_t, so no need for the cast.
> 
> The compilers differ in behavior here. tso_segsz only uses 16 bits of the uint64_t,
> and gcc tries to be smart about it and implicitly converts tso_segsz into an int
> (since it fits into an int). Msvc does not do that, and keeps the type for tso_segsz
> as uint64_t. To support both compilers it seems there's no way to avoid the cast.
> 

Ok. Then can we just keep the %u and cast to either unsigned or uint16_t?
No need to update the format char if we are casting, right?

/Bruce

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

* RE: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
  2025-02-18 16:32   ` [PATCH v2 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
@ 2025-02-18 17:12     ` Morten Brørup
  2025-02-19 16:50       ` Andre Muezerie
  0 siblings, 1 reply; 64+ messages in thread
From: Morten Brørup @ 2025-02-18 17:12 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, Chengwen Feng, stephen

> From: Andre Muezerie [mailto:andremue@linux.microsoft.com]
> Sent: Tuesday, 18 February 2025 17.32
> 
> There's no MSVC equivalent for compiler extension __builtin_constant_p.
> EAL already had __rte_constant which was used as a first attempt to
> workaround __builtin_constant_p when using MSVC. However, there are
> pieces of code that would benefit from being able to provide a default
> value to be used instead of it being always 0 like how it was done by
> __rte_constant.
> 
> A new macro is added here allowing such default to be provided by the
> caller.

NAK to the new macro.

Please use the sizeof() hack suggested by Stephen to provide an implementation of __rte_constant(e) for MSVC.
Here's a link to an example of the hack:
https://news.ycombinator.com/item?id=16720172


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

* Re: [PATCH v2 10/10] app: enable app directory to be compiled with MSVC
  2025-02-18 16:32   ` [PATCH v2 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
  2025-02-18 16:49     ` Bruce Richardson
@ 2025-02-19  9:15     ` David Marchand
  2025-02-19 14:51       ` Andre Muezerie
  1 sibling, 1 reply; 64+ messages in thread
From: David Marchand @ 2025-02-19  9:15 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, Bruce Richardson, Thomas Monjalon

On Tue, Feb 18, 2025 at 5:33 PM Andre Muezerie
<andremue@linux.microsoft.com> wrote:
> diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
> index f1c36529b4..8e8863812a 100644
> --- a/app/test-pmd/meson.build
> +++ b/app/test-pmd/meson.build
> @@ -3,7 +3,9 @@
>
>  # override default name to drop the hyphen
>  name = 'testpmd'
> -cflags += '-Wno-deprecated-declarations'
> +if cc.has_argument('-Wno-deprecated-declarations')
> +    cflags += '-Wno-deprecated-declarations'
> +endif
>  sources = files(
>          '5tswap.c',
>          'cmdline.c',

We don't need this flag anymore.

This is probably a remnant of 9f2be5b3db8b ("ethdev: deprecate attach
and detach functions"), which got fixed later with
c9cce42876f5 ("ethdev: remove deprecated attach/detach functions").


-- 
David Marchand


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

* Re: [PATCH v2 10/10] app: enable app directory to be compiled with MSVC
  2025-02-19  9:15     ` David Marchand
@ 2025-02-19 14:51       ` Andre Muezerie
  0 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-19 14:51 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Bruce Richardson, Thomas Monjalon

On Wed, Feb 19, 2025 at 10:15:21AM +0100, David Marchand wrote:
> On Tue, Feb 18, 2025 at 5:33 PM Andre Muezerie
> <andremue@linux.microsoft.com> wrote:
> > diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
> > index f1c36529b4..8e8863812a 100644
> > --- a/app/test-pmd/meson.build
> > +++ b/app/test-pmd/meson.build
> > @@ -3,7 +3,9 @@
> >
> >  # override default name to drop the hyphen
> >  name = 'testpmd'
> > -cflags += '-Wno-deprecated-declarations'
> > +if cc.has_argument('-Wno-deprecated-declarations')
> > +    cflags += '-Wno-deprecated-declarations'
> > +endif
> >  sources = files(
> >          '5tswap.c',
> >          'cmdline.c',
> 
> We don't need this flag anymore.
> 
> This is probably a remnant of 9f2be5b3db8b ("ethdev: deprecate attach
> and detach functions"), which got fixed later with
> c9cce42876f5 ("ethdev: remove deprecated attach/detach functions").
> 
> 
> -- 
> David Marchand

Good to know. I'll remove it then.

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

* Re: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
  2025-02-18 17:12     ` Morten Brørup
@ 2025-02-19 16:50       ` Andre Muezerie
  2025-02-19 17:10         ` Stephen Hemminger
  0 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-19 16:50 UTC (permalink / raw)
  To: Morten Brørup; +Cc: dev, Chengwen Feng, stephen

On Tue, Feb 18, 2025 at 06:12:04PM +0100, Morten Brørup wrote:
> > From: Andre Muezerie [mailto:andremue@linux.microsoft.com]
> > Sent: Tuesday, 18 February 2025 17.32
> > 
> > There's no MSVC equivalent for compiler extension __builtin_constant_p.
> > EAL already had __rte_constant which was used as a first attempt to
> > workaround __builtin_constant_p when using MSVC. However, there are
> > pieces of code that would benefit from being able to provide a default
> > value to be used instead of it being always 0 like how it was done by
> > __rte_constant.
> > 
> > A new macro is added here allowing such default to be provided by the
> > caller.
> 
> NAK to the new macro.
> 
> Please use the sizeof() hack suggested by Stephen to provide an implementation of __rte_constant(e) for MSVC.
> Here's a link to an example of the hack:
> https://news.ycombinator.com/item?id=16720172

Thanks for the link. I tried to use the hack as suggested but turns out it does
not work with msvc. It results in error C2100: "you cannot dereference an
operand of type 'void'".

I'm open to further suggestions.

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

* Re: [PATCH v2 03/10] test-pmd: fix printf format string mismatch
  2025-02-18 17:07         ` Bruce Richardson
@ 2025-02-19 17:08           ` Andre Muezerie
  0 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-19 17:08 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Chengwen Feng

On Tue, Feb 18, 2025 at 05:07:03PM +0000, Bruce Richardson wrote:
> On Tue, Feb 18, 2025 at 09:03:01AM -0800, Andre Muezerie wrote:
> > On Tue, Feb 18, 2025 at 04:46:56PM +0000, Bruce Richardson wrote:
> > > On Tue, Feb 18, 2025 at 08:32:02AM -0800, Andre Muezerie wrote:
> > > > Compiling with MSVC results in warnings like the one below:
> > > > 
> > > > app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
> > > >     '%d' requires an argument of type 'int',
> > > >     but variadic argument 1 has type 'uint64_t'
> > > > 
> > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > > > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> > > > ---
> > > >  app/test-pmd/csumonly.c | 23 ++++++++++++-----------
> > > >  1 file changed, 12 insertions(+), 11 deletions(-)
> > > > 
> > > > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
> > > > index d77a140641..8de5ad6ad9 100644
> > > > --- a/app/test-pmd/csumonly.c
> > > > +++ b/app/test-pmd/csumonly.c
> > > > @@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
> > > >  				info.l2_len, rte_be_to_cpu_16(info.ethertype),
> > > >  				info.l3_len, info.l4_proto, info.l4_len, buf);
> > > >  			if (rx_ol_flags & RTE_MBUF_F_RX_LRO)
> > > > -				printf("rx: m->lro_segsz=%u\n", m->tso_segsz);
> > > > +				printf("rx: m->lro_segsz=%" PRIu64 "\n", (uint64_t)m->tso_segsz);
> > > 
> > > tso_segsz is already uint64_t, so no need for the cast.
> > 
> > The compilers differ in behavior here. tso_segsz only uses 16 bits of the uint64_t,
> > and gcc tries to be smart about it and implicitly converts tso_segsz into an int
> > (since it fits into an int). Msvc does not do that, and keeps the type for tso_segsz
> > as uint64_t. To support both compilers it seems there's no way to avoid the cast.
> > 
> 
> Ok. Then can we just keep the %u and cast to either unsigned or uint16_t?
> No need to update the format char if we are casting, right?
> 
> /Bruce

Yes, I'll do that.

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

* Re: [PATCH v2 05/10] test-pmd: avoid undefined behavior
  2025-02-18 16:41     ` Bruce Richardson
@ 2025-02-19 17:09       ` Andre Muezerie
  0 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-19 17:09 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Chengwen Feng

On Tue, Feb 18, 2025 at 04:41:14PM +0000, Bruce Richardson wrote:
> On Tue, Feb 18, 2025 at 08:32:04AM -0800, Andre Muezerie wrote:
> > Compiling with MSVC results in warnings like below:
> > 
> > app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
> >     directive in function-like macro argument list is undefined behavior
> > 
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> > ---
> >  app/test-pmd/cmdline.c | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> > index 2afcf916c0..4f0b0340c8 100644
> > --- a/app/test-pmd/cmdline.c
> > +++ b/app/test-pmd/cmdline.c
> > @@ -9011,6 +9011,18 @@ static void cmd_dump_parsed(void *parsed_result,
> >  }
> >  
> >  static cmdline_parse_token_string_t cmd_dump_dump =
> > +#ifdef RTE_EXEC_ENV_WINDOWS
> > +	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
> > +		"dump_physmem#"
> > +		"dump_memzone#"
> > +		"dump_socket_mem#"
> > +		"dump_struct_sizes#"
> > +		"dump_ring#"
> > +		"dump_mempool#"
> > +		"dump_devargs#"
> > +		"dump_lcores#"
> > +		"dump_log_types");
> > +#else
> >  	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
> >  		"dump_physmem#"
> >  		"dump_memzone#"
> > @@ -9020,10 +9032,9 @@ static cmdline_parse_token_string_t cmd_dump_dump =
> >  		"dump_mempool#"
> >  		"dump_devargs#"
> >  		"dump_lcores#"
> > -#ifndef RTE_EXEC_ENV_WINDOWS
> >  		"dump_trace#"
> > -#endif
> >  		"dump_log_types");
> > +#endif
> >  
> 
> Rather than defining two separate lists, is a better fix not to provide a
> dummy implementation of dump_trace for windows, that returns e.g. TEST_SKIPPED.
> 
> /Bruce

Good suggestion. I'll update the patch accordingly.

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

* Re: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
  2025-02-19 16:50       ` Andre Muezerie
@ 2025-02-19 17:10         ` Stephen Hemminger
  2025-02-20  1:59           ` Andre Muezerie
  0 siblings, 1 reply; 64+ messages in thread
From: Stephen Hemminger @ 2025-02-19 17:10 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: Morten Brørup, dev, Chengwen Feng

On Wed, 19 Feb 2025 08:50:02 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

> On Tue, Feb 18, 2025 at 06:12:04PM +0100, Morten Brørup wrote:
> > > From: Andre Muezerie [mailto:andremue@linux.microsoft.com]
> > > Sent: Tuesday, 18 February 2025 17.32
> > > 
> > > There's no MSVC equivalent for compiler extension __builtin_constant_p.
> > > EAL already had __rte_constant which was used as a first attempt to
> > > workaround __builtin_constant_p when using MSVC. However, there are
> > > pieces of code that would benefit from being able to provide a default
> > > value to be used instead of it being always 0 like how it was done by
> > > __rte_constant.
> > > 
> > > A new macro is added here allowing such default to be provided by the
> > > caller.  
> > 
> > NAK to the new macro.
> > 
> > Please use the sizeof() hack suggested by Stephen to provide an implementation of __rte_constant(e) for MSVC.
> > Here's a link to an example of the hack:
> > https://news.ycombinator.com/item?id=16720172  
> 
> Thanks for the link. I tried to use the hack as suggested but turns out it does
> not work with msvc. It results in error C2100: "you cannot dereference an
> operand of type 'void'".
> 
> I'm open to further suggestions.

Maybe contact the MSVC team? there really ought to be way to do this.
The compiler knows what is constant and what is not since it needs this for static assertions.

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

* Re: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
  2025-02-19 17:10         ` Stephen Hemminger
@ 2025-02-20  1:59           ` Andre Muezerie
  0 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  1:59 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Morten Brørup, dev, Chengwen Feng

On Wed, Feb 19, 2025 at 09:10:11AM -0800, Stephen Hemminger wrote:
> On Wed, 19 Feb 2025 08:50:02 -0800
> Andre Muezerie <andremue@linux.microsoft.com> wrote:
> 
> > On Tue, Feb 18, 2025 at 06:12:04PM +0100, Morten Brørup wrote:
> > > > From: Andre Muezerie [mailto:andremue@linux.microsoft.com]
> > > > Sent: Tuesday, 18 February 2025 17.32
> > > > 
> > > > There's no MSVC equivalent for compiler extension __builtin_constant_p.
> > > > EAL already had __rte_constant which was used as a first attempt to
> > > > workaround __builtin_constant_p when using MSVC. However, there are
> > > > pieces of code that would benefit from being able to provide a default
> > > > value to be used instead of it being always 0 like how it was done by
> > > > __rte_constant.
> > > > 
> > > > A new macro is added here allowing such default to be provided by the
> > > > caller.  
> > > 
> > > NAK to the new macro.
> > > 
> > > Please use the sizeof() hack suggested by Stephen to provide an implementation of __rte_constant(e) for MSVC.
> > > Here's a link to an example of the hack:
> > > https://news.ycombinator.com/item?id=16720172  
> > 
> > Thanks for the link. I tried to use the hack as suggested but turns out it does
> > not work with msvc. It results in error C2100: "you cannot dereference an
> > operand of type 'void'".
> > 
> > I'm open to further suggestions.
> 
> Maybe contact the MSVC team? there really ought to be way to do this.
> The compiler knows what is constant and what is not since it needs this for static assertions.

I reached out to the MSVC team and they suggested a similar hack using _Generic, which works with
msvc. I'll send out an updated series.

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

* [PATCH v3 00/10] enable "app" to be compiled with MSVC
  2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
                   ` (10 preceding siblings ...)
  2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
@ 2025-02-20  2:01 ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
                     ` (10 more replies)
  11 siblings, 11 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev

v3:
- use clever expression with _Generic for __rte_constant and use it
  where __builtin_constant_p was being used.
- use %u in csumonly.c and just cast variables to unsigned int.

v2:
- use lcore_count as atomic always, not only when RTE_USE_C11_MEM_MODEL
  is set.
- use PRIu64 in csumonly.c instead of casting variables to int.

This series fixes many issues that prevent the "app" directory
from being compiled with MSVC.

Andre Muezerie (10):
  eal: add workaround for __builtin_constant_p
  test_alarm: avoid warning about different qualifiers
  test-pmd: fix printf format string mismatch
  test-pmd: do explicit 64-bit shift to avoid implicit conversion
  test-pmd: avoid undefined behavior
  test-pmd: avoid non-constant initializer
  test-pmd: don't return value from void function
  test-pmd: declare lcore_count atomic
  test: add workaround for __builtin_constant_p in test_memcpy_perf
  app: enable app directory to be compiled with MSVC

 app/meson.build                     |  4 ---
 app/test-pmd/cmdline.c              | 16 +++++----
 app/test-pmd/cmdline_flow.c         | 22 ++++++------
 app/test-pmd/csumonly.c             | 23 ++++++------
 app/test-pmd/meson.build            |  1 -
 app/test-pmd/testpmd.c              |  2 +-
 app/test-pmd/testpmd.h              |  2 ++
 app/test-pmd/util.c                 |  2 +-
 app/test/test_alarm.c               | 12 +++----
 app/test/test_memcpy_perf.c         | 54 ++++++++++++++---------------
 app/test/test_ring_perf.c           |  6 +---
 lib/eal/include/generic/rte_pause.h |  2 +-
 lib/eal/include/rte_common.h        |  2 +-
 13 files changed, 73 insertions(+), 75 deletions(-)

--
2.48.1.vfs.0.0


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

* [PATCH v3 01/10] eal: add workaround for __builtin_constant_p
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:27     ` Stephen Hemminger
  2025-02-20  2:01   ` [PATCH v3 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
                     ` (9 subsequent siblings)
  10 siblings, 1 reply; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

There's no MSVC equivalent for compiler extension __builtin_constant_p,
but the same result can be obtained though a clever expression using
_Generic.

This patch redefines the macro __rte_constant when msvc is used and uses
it as a replacement for __builtin_constant_p.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/include/generic/rte_pause.h | 2 +-
 lib/eal/include/rte_common.h        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/eal/include/generic/rte_pause.h b/lib/eal/include/generic/rte_pause.h
index 968c0886d3..9515caadbb 100644
--- a/lib/eal/include/generic/rte_pause.h
+++ b/lib/eal/include/generic/rte_pause.h
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
  *  rte_memory_order_acquire and rte_memory_order_relaxed.
  */
 #define RTE_WAIT_UNTIL_MASKED(addr, mask, cond, expected, memorder) do { \
-	RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder));               \
+	RTE_BUILD_BUG_ON(!__rte_constant(memorder));                     \
 	RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire &&       \
 		(memorder) != rte_memory_order_relaxed);                 \
 	typeof(*(addr)) expected_value = (expected);                     \
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 3f77b7624e..0a20b6a3e3 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -45,7 +45,7 @@ extern "C" {
 #endif
 
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_constant(e) 0
+#define __rte_constant(e) _Generic((1 ? (void *) ((e) * 0ll) : (int *) 0), int * : 1, void * : 0)
 #else
 #define __rte_constant(e) __extension__(__builtin_constant_p(e))
 #endif
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 02/10] test_alarm: avoid warning about different qualifiers
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in the warning below:

app/test/test_alarm.c(54): warning C4090: 'function':
    different '_Atomic' qualifiers

The fix is to use a macro to explicitly drop the qualifier.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_alarm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/test_alarm.c b/app/test/test_alarm.c
index 9ed8c6f72c..6445f713fe 100644
--- a/app/test/test_alarm.c
+++ b/app/test/test_alarm.c
@@ -51,12 +51,12 @@ test_alarm(void)
 			 "Expected rte_eal_alarm_cancel to fail with null callback parameter");
 
 	/* check if can set a alarm for one second */
-	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(US_PER_SEC, test_alarm_callback, &triggered),
-			    "Setting one second alarm failed");
+	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(US_PER_SEC, test_alarm_callback,
+			    RTE_PTR_UNQUAL(&triggered)), "Setting one second alarm failed");
 
 	/* set a longer alarm that will be canceled. */
-	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(10 * US_PER_SEC, test_alarm_callback, &later),
-			    "Setting ten second alarm failed");
+	TEST_ASSERT_SUCCESS(rte_eal_alarm_set(10 * US_PER_SEC, test_alarm_callback,
+			    RTE_PTR_UNQUAL(&later)), "Setting ten second alarm failed");
 
 	/* wait for alarm to happen */
 	while (rte_atomic_load_explicit(&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)
 	TEST_ASSERT(!rte_atomic_load_explicit(&later, rte_memory_order_acquire),
 		    "Only one alarm should have fired.");
 
-	ret = rte_eal_alarm_cancel(test_alarm_callback, &triggered);
+	ret = rte_eal_alarm_cancel(test_alarm_callback, RTE_PTR_UNQUAL(&triggered));
 	TEST_ASSERT(ret == 0 && rte_errno == ENOENT,
 		    "Canceling alarm after run ret %d: %s", ret, rte_strerror(rte_errno));
 
-	ret = rte_eal_alarm_cancel(test_alarm_callback, &later);
+	ret = rte_eal_alarm_cancel(test_alarm_callback, RTE_PTR_UNQUAL(&later));
 	TEST_ASSERT(ret == 1, "Canceling ten second alarm failed %d: %s",
 		    ret, rte_strerror(rte_errno));
 
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 03/10] test-pmd: fix printf format string mismatch
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in warnings like the one below:

app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
    '%d' requires an argument of type 'int',
    but variadic argument 1 has type 'uint64_t'

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/csumonly.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d77a140641..5f273e60d7 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				info.l2_len, rte_be_to_cpu_16(info.ethertype),
 				info.l3_len, info.l4_proto, info.l4_len, buf);
 			if (rx_ol_flags & RTE_MBUF_F_RX_LRO)
-				printf("rx: m->lro_segsz=%u\n", m->tso_segsz);
+				printf("rx: m->lro_segsz=%u\n", (unsigned int)m->tso_segsz);
 			if (info.is_tunnel == 1)
 				printf("rx: outer_l2_len=%d outer_ethertype=%x "
 					"outer_l3_len=%d\n", info.outer_l2_len,
@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					    RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
 					    RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) ||
 				info.tso_segsz != 0)
-				printf("tx: m->l2_len=%d m->l3_len=%d "
-					"m->l4_len=%d\n",
-					m->l2_len, m->l3_len, m->l4_len);
+				printf("tx: m->l2_len=%u m->l3_len=%u "
+					"m->l4_len=%u\n",
+					(unsigned int)m->l2_len, (unsigned int)m->l3_len,
+					(unsigned int)m->l4_len);
 			if (info.is_tunnel == 1) {
 				if ((tx_offloads &
 				    RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
 				    (tx_offloads &
 				    RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ||
 				    (tx_ol_flags & RTE_MBUF_F_TX_OUTER_IPV6))
-					printf("tx: m->outer_l2_len=%d "
-						"m->outer_l3_len=%d\n",
-						m->outer_l2_len,
-						m->outer_l3_len);
+					printf("tx: m->outer_l2_len=%u "
+						"m->outer_l3_len=%u\n",
+						(unsigned int)m->outer_l2_len,
+						(unsigned int)m->outer_l3_len);
 				if (info.tunnel_tso_segsz != 0 &&
 						(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
 							RTE_MBUF_F_TX_UDP_SEG)))
-					printf("tx: m->tso_segsz=%d\n",
-						m->tso_segsz);
+					printf("tx: m->tso_segsz=%u\n",
+						(unsigned int)m->tso_segsz);
 			} else if (info.tso_segsz != 0 &&
 					(m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
 						RTE_MBUF_F_TX_UDP_SEG)))
-				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
+				printf("tx: m->tso_segsz=%u\n", (unsigned int)m->tso_segsz);
 			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
 			printf("tx: flags=%s", buf);
 			printf("\n");
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
                     ` (2 preceding siblings ...)
  2025-02-20  2:01   ` [PATCH v3 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 05/10] test-pmd: avoid undefined behavior Andre Muezerie
                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in warnings like the one below:

app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
    implicitly converted to 64 bits (was 64-bit shift intended?)

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test-pmd/cmdline.c | 4 ++--
 app/test-pmd/testpmd.c | 2 +-
 app/test-pmd/util.c    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 86d763b66a..2afcf916c0 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result,
 	}
 	old_port_flags = ports[res->port_id].mbuf_dynf;
 	if (!strcmp(res->value, "set")) {
-		ports[res->port_id].mbuf_dynf |= 1UL << flag;
+		ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
 		if (old_port_flags == 0)
 			add_tx_dynf_callback(res->port_id);
 	} else {
-		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
+		ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
 		if (ports[res->port_id].mbuf_dynf == 0)
 			remove_tx_dynf_callback(res->port_id);
 	}
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0520aba0db..0a5b999c3a 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,
 		for (i = 0; i < vmdq_rx_conf->nb_pool_maps; i++) {
 			vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i];
 			vmdq_rx_conf->pool_map[i].pools =
-				1 << (i % vmdq_rx_conf->nb_queue_pools);
+				RTE_BIT64(i % vmdq_rx_conf->nb_queue_pools);
 		}
 		for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
 			vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 5fa05fad16..3934831b19 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
 				MKDUMPSTR(print_buf, buf_size, cur_len,
 					  " - dynf %s: %d",
 					  dynf_names[dynf_index],
-					  !!(ol_flags & (1UL << dynf_index)));
+					  !!(ol_flags & RTE_BIT64(dynf_index)));
 		}
 		if (mb->packet_type) {
 			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 05/10] test-pmd: avoid undefined behavior
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
                     ` (3 preceding siblings ...)
  2025-02-20  2:01   ` [PATCH v3 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in warnings like below:

app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
    directive in function-like macro argument list is undefined behavior

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline.c | 12 ++++++++----
 app/test-pmd/testpmd.h |  2 ++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 2afcf916c0..d0b47eac8f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -8980,6 +8980,14 @@ dump_socket_mem(FILE *f)
 	last_total = total;
 }
 
+#ifdef RTE_EXEC_ENV_WINDOWS
+int
+rte_trace_save(void)
+{
+	return TEST_SKIPPED;
+}
+#endif
+
 static void cmd_dump_parsed(void *parsed_result,
 			    __rte_unused struct cmdline *cl,
 			    __rte_unused void *data)
@@ -9002,10 +9010,8 @@ static void cmd_dump_parsed(void *parsed_result,
 		rte_devargs_dump(stdout);
 	else if (!strcmp(res->dump, "dump_lcores"))
 		rte_lcore_dump(stdout);
-#ifndef RTE_EXEC_ENV_WINDOWS
 	else if (!strcmp(res->dump, "dump_trace"))
 		rte_trace_save();
-#endif
 	else if (!strcmp(res->dump, "dump_log_types"))
 		rte_log_dump(stdout);
 }
@@ -9020,9 +9026,7 @@ static cmdline_parse_token_string_t cmd_dump_dump =
 		"dump_mempool#"
 		"dump_devargs#"
 		"dump_lcores#"
-#ifndef RTE_EXEC_ENV_WINDOWS
 		"dump_trace#"
-#endif
 		"dump_log_types");
 
 static cmdline_parse_inst_t cmd_dump = {
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a933fb433a..de8e8f8dca 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -84,6 +84,8 @@ extern volatile uint8_t f_quit;
 /* Maximum number of pools supported per Rx queue */
 #define MAX_MEMPOOL 8
 
+#define TEST_SKIPPED 77
+
 typedef uint32_t lcoreid_t;
 typedef uint16_t portid_t;
 typedef uint16_t queueid_t;
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 06/10] test-pmd: avoid non-constant initializer
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
                     ` (4 preceding siblings ...)
  2025-02-20  2:01   ` [PATCH v3 05/10] test-pmd: avoid undefined behavior Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 07/10] test-pmd: don't return value from void function Andre Muezerie
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in errors like the one below:

app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
    is not a constant

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline_flow.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index e1720e54d7..24323d8891 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,
 		return -1;
 	/* Parse parameter types. */
 	switch (ctx->curr) {
-		static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
-
 	case ITEM_PARAM_IS:
 		index = 0;
 		objmask = 1;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,
 		/* Modify next token to expect a prefix. */
 		if (ctx->next_num < 2)
 			return -1;
-		ctx->next[ctx->next_num - 2] = prefix;
+		ctx->next[ctx->next_num - 2] = NEXT_ENTRY(COMMON_PREFIX);
 		/* Fall through. */
 	case ITEM_PARAM_MASK:
 		index = 2;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,
 			  const char *str, unsigned int len,
 			  void *buf, unsigned int size)
 {
-	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
 	struct action_rss_data *action_rss_data;
 	unsigned int i;
 
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,
 	/* Repeat token. */
 	if (ctx->next_num == RTE_DIM(ctx->next))
 		return -1;
-	ctx->next[ctx->next_num++] = next;
+	ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_TYPE);
 	if (!ctx->object)
 		return len;
 	action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  const char *str, unsigned int len,
 			  void *buf, unsigned int size)
 {
-	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
 	struct action_rss_data *action_rss_data;
 	const struct arg *arg;
 	int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	/* Repeat token. */
 	if (ctx->next_num == RTE_DIM(ctx->next))
 		return -1;
-	ctx->next[ctx->next_num++] = next;
+	ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_QUEUE);
 end:
 	if (!ctx->object)
 		return len;
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 07/10] test-pmd: don't return value from void function
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
                     ` (5 preceding siblings ...)
  2025-02-20  2:01   ` [PATCH v3 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in the warning below:

app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
    'void' function returning a value

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test-pmd/cmdline_flow.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 24323d8891..15a18db2c7 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)
 	int gtp_psc = -1; /* GTP PSC option index. */
 	const void *src_spec;
 
-	if (in->command == SET_SAMPLE_ACTIONS)
-		return cmd_set_raw_parsed_sample(in);
+	if (in->command == SET_SAMPLE_ACTIONS) {
+		cmd_set_raw_parsed_sample(in);
+		return;
+	}
 	else if (in->command == SET_IPV6_EXT_PUSH ||
-		 in->command == SET_IPV6_EXT_REMOVE)
-		return cmd_set_ipv6_ext_parsed(in);
+			 in->command == SET_IPV6_EXT_REMOVE) {
+		cmd_set_ipv6_ext_parsed(in);
+		return;
+	}
 	RTE_ASSERT(in->command == SET_RAW_ENCAP ||
 		   in->command == SET_RAW_DECAP);
 	if (in->command == SET_RAW_ENCAP) {
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 08/10] test-pmd: declare lcore_count atomic
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
                     ` (6 preceding siblings ...)
  2025-02-20  2:01   ` [PATCH v3 07/10] test-pmd: don't return value from void function Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev, Chengwen Feng

Compiling with MSVC results in the error below:

app/test/test_ring_perf.c(197): error C7712: address argument to atomic
    operation must be a pointer to an atomic integer,
    'volatile unsigned int *' is not valid

The fix is to mark lcore_count as atomic.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_ring_perf.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 57cd04a124..366e256323 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -34,7 +34,7 @@ struct lcore_pair {
 	unsigned c1, c2;
 };
 
-static volatile unsigned lcore_count = 0;
+static RTE_ATOMIC(unsigned int) lcore_count;
 
 static void
 test_ring_print_test_string(unsigned int api_type, int esize,
@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)
 	unsigned int n_remaining;
 	const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i];
 
-#ifdef RTE_USE_C11_MEM_MODEL
 	if (rte_atomic_fetch_add_explicit(&lcore_count, 1, rte_memory_order_relaxed) + 1 != 2)
-#else
-	if (__sync_add_and_fetch(&lcore_count, 1) != 2)
-#endif
 		while(lcore_count != 2)
 			rte_pause();
 
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
                     ` (7 preceding siblings ...)
  2025-02-20  2:01   ` [PATCH v3 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  2:01   ` [PATCH v3 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
  2025-02-20  7:57   ` [PATCH v3 00/10] enable "app" " Morten Brørup
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev

There's no MSVC equivalent for compiler extension __builtin_constant_p,
so a workaround is needed.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_memcpy_perf.c | 54 ++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/app/test/test_memcpy_perf.c b/app/test/test_memcpy_perf.c
index 5c05a84619..32c589c4ba 100644
--- a/app/test/test_memcpy_perf.c
+++ b/app/test/test_memcpy_perf.c
@@ -196,37 +196,37 @@ do {                                                                        \
 } while (0)
 
 /* Run aligned memcpy tests for each cached/uncached permutation */
-#define ALL_PERF_TESTS_FOR_SIZE(n)                                       \
-do {                                                                     \
-    if (__builtin_constant_p(n))                                         \
-        printf("\nC%6u", (unsigned)n);                                   \
-    else                                                                 \
-        printf("\n%7u", (unsigned)n);                                    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n);    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n);    \
+#define ALL_PERF_TESTS_FOR_SIZE(n)                                           \
+do {                                                                         \
+	if (__rte_constant(n))                                               \
+		printf("\nC%6u", (unsigned int)n);                           \
+	else                                                                 \
+		printf("\n%7u", (unsigned int)n);                            \
+	SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n);    \
+	SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n);    \
 } while (0)
 
 /* Run unaligned memcpy tests for each cached/uncached permutation */
-#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(n)                             \
-do {                                                                     \
-    if (__builtin_constant_p(n))                                         \
-        printf("\nC%6u", (unsigned)n);                                   \
-    else                                                                 \
-        printf("\n%7u", (unsigned)n);                                    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n);    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n);    \
+#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(n)                                 \
+do {                                                                         \
+	if (__rte_constant(n))                                               \
+		printf("\nC%6u", (unsigned int)n);                           \
+	else                                                                 \
+		printf("\n%7u", (unsigned int)n);                            \
+	SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n);    \
+	SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n);    \
 } while (0)
 
 /* Run memcpy tests for constant length */
-#define ALL_PERF_TEST_FOR_CONSTANT                                      \
-do {                                                                    \
-    TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U);         \
-    TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U);      \
-    TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U);    \
+#define ALL_PERF_TEST_FOR_CONSTANT                                          \
+do {                                                                        \
+	TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U);         \
+	TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U);      \
+	TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U);    \
 } while (0)
 
 /* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void)
 {
 	unsigned i;
 	for (i = 0; i < RTE_DIM(buf_sizes); i++) {
-		ALL_PERF_TESTS_FOR_SIZE((size_t)buf_sizes[i]);
+		ALL_PERF_TESTS_FOR_SIZE(buf_sizes[i]);
 	}
 }
 
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void)
 {
 	unsigned i;
 	for (i = 0; i < RTE_DIM(buf_sizes); i++) {
-		ALL_PERF_TESTS_FOR_SIZE_UNALIGNED((size_t)buf_sizes[i]);
+		ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(buf_sizes[i]);
 	}
 }
 
-- 
2.48.1.vfs.0.0


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

* [PATCH v3 10/10] app: enable app directory to be compiled with MSVC
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
                     ` (8 preceding siblings ...)
  2025-02-20  2:01   ` [PATCH v3 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
@ 2025-02-20  2:01   ` Andre Muezerie
  2025-02-20  7:57   ` [PATCH v3 00/10] enable "app" " Morten Brørup
  10 siblings, 0 replies; 64+ messages in thread
From: Andre Muezerie @ 2025-02-20  2:01 UTC (permalink / raw)
  To: andremue; +Cc: dev

Enabled "app" directory to be compiled with MSVC along with all its
contents.

Removed flag Wno-deprecated-declarations which is not needed anymore.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/meson.build          | 4 ----
 app/test-pmd/meson.build | 1 -
 2 files changed, 5 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index e2db888ae1..1798db3ae4 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -1,10 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
-if is_ms_compiler
-    subdir_done()
-endif
-
 disable_apps = ',' + get_option('disable_apps')
 disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
 
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index f1c36529b4..000548c261 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -3,7 +3,6 @@
 
 # override default name to drop the hyphen
 name = 'testpmd'
-cflags += '-Wno-deprecated-declarations'
 sources = files(
         '5tswap.c',
         'cmdline.c',
-- 
2.48.1.vfs.0.0


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

* Re: [PATCH v3 01/10] eal: add workaround for __builtin_constant_p
  2025-02-20  2:01   ` [PATCH v3 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
@ 2025-02-20  2:27     ` Stephen Hemminger
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Hemminger @ 2025-02-20  2:27 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, Chengwen Feng

On Wed, 19 Feb 2025 18:01:30 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:

>  
>  #ifdef RTE_TOOLCHAIN_MSVC
> -#define __rte_constant(e) 0
> +#define __rte_constant(e) _Generic((1 ? (void *) ((e) * 0ll) : (int *) 0), int * : 1, void * : 0)
>  #else
>  #define __rte_constant(e) __extension__(__builtin_constant_p(e))
>  #endif

Probably worth some explanation as to what is going on.

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

* RE: [PATCH v3 00/10] enable "app" to be compiled with MSVC
  2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
                     ` (9 preceding siblings ...)
  2025-02-20  2:01   ` [PATCH v3 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
@ 2025-02-20  7:57   ` Morten Brørup
  10 siblings, 0 replies; 64+ messages in thread
From: Morten Brørup @ 2025-02-20  7:57 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev

Series-acked-by: Morten Brørup <mb@smartsharesystems.com>


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

end of thread, other threads:[~2025-02-20  7:58 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
2025-02-11 22:01 ` [PATCH 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-11 22:09   ` Stephen Hemminger
2025-02-12  0:59   ` fengchengwen
2025-02-11 22:01 ` [PATCH 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-12  0:59   ` fengchengwen
2025-02-11 22:01 ` [PATCH 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-11 22:10   ` Stephen Hemminger
2025-02-12  1:01   ` fengchengwen
2025-02-11 22:02 ` [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-12  1:03   ` fengchengwen
2025-02-11 22:02 ` [PATCH 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-12  1:04   ` fengchengwen
2025-02-11 22:02 ` [PATCH 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-12  1:04   ` fengchengwen
2025-02-11 22:02 ` [PATCH 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-12  1:10   ` fengchengwen
2025-02-11 22:02 ` [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model Andre Muezerie
2025-02-11 22:12   ` Stephen Hemminger
2025-02-12  1:16     ` Andre Muezerie
2025-02-12  1:16   ` fengchengwen
2025-02-11 22:02 ` [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-11 22:13   ` Stephen Hemminger
2025-02-12  2:07     ` Andre Muezerie
2025-02-18 15:35 ` [PATCH 00/10] enable "app" to be compiled with MSVC David Marchand
2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-18 17:12     ` Morten Brørup
2025-02-19 16:50       ` Andre Muezerie
2025-02-19 17:10         ` Stephen Hemminger
2025-02-20  1:59           ` Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-18 16:46     ` Bruce Richardson
2025-02-18 17:03       ` Andre Muezerie
2025-02-18 17:07         ` Bruce Richardson
2025-02-19 17:08           ` Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-18 16:47     ` Bruce Richardson
2025-02-18 16:32   ` [PATCH v2 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-18 16:41     ` Bruce Richardson
2025-02-19 17:09       ` Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-18 16:42     ` Bruce Richardson
2025-02-18 16:32   ` [PATCH v2 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
2025-02-18 16:49     ` Bruce Richardson
2025-02-19  9:15     ` David Marchand
2025-02-19 14:51       ` Andre Muezerie
2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-20  2:27     ` Stephen Hemminger
2025-02-20  2:01   ` [PATCH v3 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
2025-02-20  7:57   ` [PATCH v3 00/10] enable "app" " Morten Brørup

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).