Skip to contentSkip to conversation

ethdev: add extension keyword to statement expression macro

PATCH Applied Tyler Retzlaff 3 participants 8 messages Nov 9, 2023 – Nov 14, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethdev: add extension keyword to statement expression macro

add missing __extension__ keyword to macros using gcc statement expression extension.

---
 lib/ethdev/rte_mtr.c | 10 +++++-----
 lib/ethdev/rte_tm.c  |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)
lib/ethdev/rte_mtr.c +5 -5
index 4e94af9..900837b 100644
@@ -41,14 +41,14 @@
 }
 
 #define RTE_MTR_FUNC(port_id, func)			\
-({							\
+__extension__ ({					\
 	const struct rte_mtr_ops *ops =			\
-		rte_mtr_ops_get(port_id, error);		\
-	if (ops == NULL)					\
+		rte_mtr_ops_get(port_id, error);	\
+	if (ops == NULL)				\
 		return -rte_errno;			\
 							\
 	if (ops->func == NULL)				\
-		return -rte_mtr_error_set(error,		\
+		return -rte_mtr_error_set(error,	\
 			ENOSYS,				\
 			RTE_MTR_ERROR_TYPE_UNSPECIFIED,	\
 			NULL,				\
@@ -58,7 +58,7 @@
 })
 
 #define RTE_MTR_HNDL_FUNC(port_id, func)		\
-({							\
+__extension__ ({					\
 	const struct rte_mtr_ops *ops =			\
 		rte_mtr_ops_get(port_id, error);	\
 	if (ops == NULL)				\
lib/ethdev/rte_tm.c +3 -3
index 2d08141..d594fe0 100644
@@ -40,11 +40,11 @@
 	return ops;
 }
 
-#define RTE_TM_FUNC(port_id, func)				\
-({							\
+#define RTE_TM_FUNC(port_id, func)			\
+__extension__ ({					\
 	const struct rte_tm_ops *ops =			\
 		rte_tm_ops_get(port_id, error);		\
-	if (ops == NULL)					\
+	if (ops == NULL)				\
 		return -rte_errno;			\
 							\
 	if (ops->func == NULL)				\
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Tyler Retzlaff

add missing __extension__ keyword to macros using gcc statement expression extension.

It seems there are a few more usage not marked in lib folder [1], and more including drivers.

Is this compiler extension causing any problem for the Windows build or MSVC toolchain?

[1]

$ grep -r '({' lib/ | grep -v __extension__
lib/port/rte_port_source_sink.c:({
lib/port/rte_port_source_sink.c:({
lib/pipeline/rte_swx_pipeline_internal.h:({
lib/pipeline/rte_pipeline.c:    ({ (p)->n_pkts_ah_drop =
lib/pipeline/rte_pipeline.c:    ({ (counter) += (p)->n_pkts_ah_drop;
lib/pipeline/rte_pipeline.c:    ({ (p)->pkts_drop_mask =
lib/pipeline/rte_pipeline.c:({
lib/ethdev/rte_mtr.c:({
lib/ethdev/rte_mtr.c:({
lib/ethdev/rte_tm.c:({
#3 lore raw
In reply to Ferruh Yigit
Quoted 4 lines · Ferruh Yigit
Quoted 3 lines · Tyler Retzlaff

add missing __extension__ keyword to macros using gcc statement expression extension.

Quoted 8 lines
Quoted 2 lines

It seems there are a few more usage not marked in lib folder [1], and more including drivers.

yeah, sorry i'm not doing them all at once. though given the number of instances left i'll see if i can find a few minutes maybe just clear lib/* entirely drivers like for everything else are lower priority for me right now (always open to help of course).

Quoted 3 lines

Is this compiler extension causing any problem for the Windows build or MSVC toolchain?

just the msvc toolchain, builds with gcc/clang targeting windows work fine.

i'm working internally with the msvc toolchain team to enable support for the extension on the condition that it be marked with the __extension__ keyword so i'm just making sure it is applied consistently.

Quoted 15 lines

[1]

$ grep -r '({' lib/ | grep -v __extension__
lib/port/rte_port_source_sink.c:({
lib/port/rte_port_source_sink.c:({
lib/pipeline/rte_swx_pipeline_internal.h:({
lib/pipeline/rte_pipeline.c:    ({ (p)->n_pkts_ah_drop =
lib/pipeline/rte_pipeline.c:    ({ (counter) += (p)->n_pkts_ah_drop;
lib/pipeline/rte_pipeline.c:    ({ (p)->pkts_drop_mask =
lib/pipeline/rte_pipeline.c:({
lib/ethdev/rte_mtr.c:({
lib/ethdev/rte_mtr.c:({
lib/ethdev/rte_tm.c:({
#4 lore raw
Quoted 11 lines · Tyler Retzlaff
Quoted 10 lines · Ferruh Yigit
Quoted 5 lines · Tyler Retzlaff

add missing __extension__ keyword to macros using gcc statement expression extension.

Quoted 8 lines
Quoted 2 lines

It seems there are a few more usage not marked in lib folder [1], and more including drivers.

yeah, sorry i'm not doing them all at once. though given the number of instances left i'll see if i can find a few minutes maybe just clear lib/* entirely drivers like for everything else are lower priority for me right now (always open to help of course).

that is OK, I just want to remind

Quoted 11 lines
Quoted 3 lines

Is this compiler extension causing any problem for the Windows build or MSVC toolchain?

just the msvc toolchain, builds with gcc/clang targeting windows work fine.

i'm working internally with the msvc toolchain team to enable support for the extension on the condition that it be marked with the __extension__ keyword so i'm just making sure it is applied consistently.

Nice, if just marking extensions is sufficient, that is easy to do.

Quoted 15 lines
Quoted 15 lines

[1]

$ grep -r '({' lib/ | grep -v __extension__
lib/port/rte_port_source_sink.c:({
lib/port/rte_port_source_sink.c:({
lib/pipeline/rte_swx_pipeline_internal.h:({
lib/pipeline/rte_pipeline.c:    ({ (p)->n_pkts_ah_drop =
lib/pipeline/rte_pipeline.c:    ({ (counter) += (p)->n_pkts_ah_drop;
lib/pipeline/rte_pipeline.c:    ({ (p)->pkts_drop_mask =
lib/pipeline/rte_pipeline.c:({
lib/ethdev/rte_mtr.c:({
lib/ethdev/rte_mtr.c:({
lib/ethdev/rte_tm.c:({
#5 lore raw

11/11/2023 00:25, Ferruh Yigit:

Quoted 15 lines · Tyler Retzlaff
Quoted 14 lines · Ferruh Yigit
Quoted 12 lines · Tyler Retzlaff
Quoted 5 lines

add missing __extension__ keyword to macros using gcc statement expression extension.

It seems there are a few more usage not marked in lib folder [1], and more including drivers.

Quoted 7 lines
Quoted 5 lines

yeah, sorry i'm not doing them all at once. though given the number of instances left i'll see if i can find a few minutes maybe just clear lib/* entirely drivers like for everything else are lower priority for me right now (always open to help of course).

that is OK, I just want to remind

A commit on all libs would have more sense.
Here it is not even all ethdev.
I would not apply half a patch.

#6 lore raw
Quoted 22 lines · Thomas Monjalon

11/11/2023 00:25, Ferruh Yigit:

Quoted 21 lines · Tyler Retzlaff
Quoted 19 lines · Ferruh Yigit
Quoted 12 lines · Tyler Retzlaff
Quoted 5 lines

add missing __extension__ keyword to macros using gcc statement expression extension.

It seems there are a few more usage not marked in lib folder [1], and more including drivers.

yeah, sorry i'm not doing them all at once. though given the number of instances left i'll see if i can find a few minutes maybe just clear lib/* entirely drivers like for everything else are lower priority for me right now (always open to help of course).

Quoted 7 lines
Quoted 1 line

that is OK, I just want to remind

A commit on all libs would have more sense.
Here it is not even all ethdev.
I would not apply half a patch.

Dropping patch from next-net, for the sake of more complete patch.

Patchwork status is now "change requested".

#7 lore raw
In reply to Ferruh Yigit

10/11/2023 18:22, Ferruh Yigit:

Quoted 12 lines · Tyler Retzlaff
Quoted 5 lines

add missing __extension__ keyword to macros using gcc statement expression extension.

It seems there are a few more usage not marked in lib folder [1], and more including drivers.

Please let's mark all at once.

Quoted 2 lines

Is this compiler extension causing any problem for the Windows build or MSVC toolchain?

I have the same question: is __extension__ supported in MSVC?

Quoted 12 lines

[1]

$ grep -r '({' lib/ | grep -v __extension__
lib/port/rte_port_source_sink.c:({
lib/port/rte_port_source_sink.c:({
lib/pipeline/rte_swx_pipeline_internal.h:({
lib/pipeline/rte_pipeline.c:    ({ (p)->n_pkts_ah_drop =
lib/pipeline/rte_pipeline.c:    ({ (counter) += (p)->n_pkts_ah_drop;
lib/pipeline/rte_pipeline.c:    ({ (p)->pkts_drop_mask =
lib/pipeline/rte_pipeline.c:({
lib/ethdev/rte_mtr.c:({
lib/ethdev/rte_mtr.c:({
lib/ethdev/rte_tm.c:({