* [PATCH 0/3] add diagnostics macros to make code portable
@ 2024-12-27 1:33 Andre Muezerie
2024-12-27 1:33 ` [PATCH 1/3] lib/eal: " Andre Muezerie
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andre Muezerie @ 2024-12-27 1:33 UTC (permalink / raw)
Cc: dev, Andre Muezerie
It was a common pattern to have "GCC diagnostic ignored" pragmas
sprinkled over the code and only activate these pragmas for certain
compilers (gcc and clang). Clang supports GCCΓÇÖs pragma for
compatibility with existing source code, so #pragma GCC diagnostic
and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC
these expressions would become more complex. It makes sense to hide
this complexity behind macros. This makes maintenance easier as these
macros are defined in a single place. As a plus the code becomes
more readable as well.
Andre Muezerie (3):
lib/eal: add diagnostics macros to make code portable
drivers/common: add diagnostics macros to make code portable
drivers/net: add diagnostics macros to make code portable
drivers/common/idpf/idpf_common_rxtx_avx512.c | 4 +--
drivers/net/axgbe/axgbe_rxtx.h | 12 +++----
drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 +--
drivers/net/dpaa2/dpaa2_rxtx.c | 15 ++------
drivers/net/fm10k/fm10k_rxtx_vec.c | 4 +--
drivers/net/hns3/hns3_rxtx_vec_neon.h | 2 +-
.../net/i40e/i40e_recycle_mbufs_vec_common.c | 2 +-
drivers/net/i40e/i40e_rxtx_common_avx.h | 4 +--
drivers/net/i40e/i40e_rxtx_vec_altivec.c | 2 +-
drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +--
drivers/net/i40e/i40e_rxtx_vec_avx512.c | 4 +--
drivers/net/i40e/i40e_rxtx_vec_common.h | 4 +--
drivers/net/i40e/i40e_rxtx_vec_neon.c | 3 +-
drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +--
drivers/net/iavf/iavf_rxtx_vec_avx2.c | 4 +--
drivers/net/iavf/iavf_rxtx_vec_avx512.c | 4 +--
drivers/net/iavf/iavf_rxtx_vec_common.h | 4 +--
drivers/net/iavf/iavf_rxtx_vec_sse.c | 4 +--
drivers/net/ice/ice_rxtx_common_avx.h | 4 +--
drivers/net/ice/ice_rxtx_vec_avx2.c | 4 +--
drivers/net/ice/ice_rxtx_vec_avx512.c | 4 +--
drivers/net/ice/ice_rxtx_vec_common.h | 4 +--
drivers/net/ice/ice_rxtx_vec_sse.c | 4 +--
drivers/net/idpf/idpf_rxtx_vec_common.h | 4 +--
.../ixgbe/ixgbe_recycle_mbufs_vec_common.c | 2 +-
drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 2 +-
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +--
drivers/net/mlx5/mlx5_flow.c | 6 ++--
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 6 ++--
drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 2 +-
drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 4 +--
drivers/net/tap/tap_flow.c | 6 ++--
drivers/net/virtio/virtio_rxtx_simple.c | 4 +--
lib/eal/include/rte_common.h | 34 +++++++++++++++++++
34 files changed, 77 insertions(+), 101 deletions(-)
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] lib/eal: add diagnostics macros to make code portable
2024-12-27 1:33 [PATCH 0/3] add diagnostics macros to make code portable Andre Muezerie
@ 2024-12-27 1:33 ` Andre Muezerie
2024-12-27 1:33 ` [PATCH 2/3] drivers/common: " Andre Muezerie
2024-12-27 1:33 ` [PATCH 3/3] drivers/net: " Andre Muezerie
2 siblings, 0 replies; 5+ messages in thread
From: Andre Muezerie @ 2024-12-27 1:33 UTC (permalink / raw)
To: Tyler Retzlaff; +Cc: dev, Andre Muezerie
It was a common pattern to have "GCC diagnostic ignored" pragmas
sprinkled over the code and only activate these pragmas for certain
compilers (gcc and clang). Clang supports GCC’s pragma for
compatibility with existing source code, so #pragma GCC diagnostic
and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC
these expressions would become more complex. It makes sense to hide
this complexity behind macros. This makes maintenance easier as these
macros are defined in a single place. As a plus the code becomes
more readable as well.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/eal/include/rte_common.h | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 4d299f2b36..c5f91730ef 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -137,6 +137,40 @@ typedef uint16_t unaligned_uint16_t;
#define RTE_DEPRECATED(x)
#endif
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove a type
+ * qualifier from the target type.
+ */
+#if !defined __INTEL_COMPILER && !defined RTE_TOOLCHAIN_MSVC
+#define __rte_diagnostic_ignored_wcast_qual \
+ _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
+#else
+#define __rte_diagnostic_ignored_wcast_qual
+#endif
+
+/*
+ * Macro to ignore code that might break the strict aliasing rules that
+ * the compiler is using for optimization.
+ */
+#if !defined __INTEL_COMPILER && !defined RTE_TOOLCHAIN_MSVC
+#define __rte_diagnostic_ignored_wstrict_aliasing \
+ _Pragma("GCC diagnostic ignored \"-Wstrict-aliasing\"")
+#else
+#define __rte_diagnostic_ignored_wstrict_aliasing
+#endif
+
+/*
+ * Macros to cause the compiler to remember the state of the diagnostics as of
+ * each push, and restore to that point at each pop.
+ */
+#if !defined __INTEL_COMPILER && !defined RTE_TOOLCHAIN_MSVC
+#define __rte_diagnostic_push _Pragma("GCC diagnostic push")
+#define __rte_diagnostic_pop _Pragma("GCC diagnostic pop")
+#else
+#define __rte_diagnostic_push
+#define __rte_diagnostic_pop
+#endif
+
/**
* Mark a function or variable to a weak reference.
*/
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] drivers/common: add diagnostics macros to make code portable
2024-12-27 1:33 [PATCH 0/3] add diagnostics macros to make code portable Andre Muezerie
2024-12-27 1:33 ` [PATCH 1/3] lib/eal: " Andre Muezerie
@ 2024-12-27 1:33 ` Andre Muezerie
2024-12-27 17:57 ` Stephen Hemminger
2024-12-27 1:33 ` [PATCH 3/3] drivers/net: " Andre Muezerie
2 siblings, 1 reply; 5+ messages in thread
From: Andre Muezerie @ 2024-12-27 1:33 UTC (permalink / raw)
To: Bruce Richardson, Konstantin Ananyev, Jingjing Wu, Praveen Shetty
Cc: dev, Andre Muezerie
It was a common pattern to have "GCC diagnostic ignored" pragmas
sprinkled over the code and only activate these pragmas for certain
compilers (gcc and clang). Clang supports GCC’s pragma for
compatibility with existing source code, so #pragma GCC diagnostic
and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC
these expressions would become more complex. It makes sense to hide
this complexity behind macros. This makes maintenance easier as these
macros are defined in a single place. As a plus the code becomes
more readable as well.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
drivers/common/idpf/idpf_common_rxtx_avx512.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c b/drivers/common/idpf/idpf_common_rxtx_avx512.c
index b8450b03ae..d298a5ca36 100644
--- a/drivers/common/idpf/idpf_common_rxtx_avx512.c
+++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c
@@ -6,9 +6,7 @@
#include "idpf_common_device.h"
#include "idpf_common_rxtx.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
#define IDPF_DESCS_PER_LOOP_AVX 8
#define PKTLEN_SHIFT 10
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] drivers/net: add diagnostics macros to make code portable
2024-12-27 1:33 [PATCH 0/3] add diagnostics macros to make code portable Andre Muezerie
2024-12-27 1:33 ` [PATCH 1/3] lib/eal: " Andre Muezerie
2024-12-27 1:33 ` [PATCH 2/3] drivers/common: " Andre Muezerie
@ 2024-12-27 1:33 ` Andre Muezerie
2 siblings, 0 replies; 5+ messages in thread
From: Andre Muezerie @ 2024-12-27 1:33 UTC (permalink / raw)
To: Selwin Sebastian, Praveen Shetty, Hemant Agrawal, Sachin Saxena,
Wathsala Vithanage, Jie Hai, Ian Stokes, Bruce Richardson,
Konstantin Ananyev, David Christensen, Vladimir Medvedkin,
Anatoly Burakov, Jingjing Wu, Dariusz Sosnowski,
Viacheslav Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou,
Matan Azrad, Stephen Hemminger, Maxime Coquelin, Chenbo Xia
Cc: dev, Andre Muezerie
It was a common pattern to have "GCC diagnostic ignored" pragmas
sprinkled over the code and only activate these pragmas for certain
compilers (gcc and clang). Clang supports GCC’s pragma for
compatibility with existing source code, so #pragma GCC diagnostic
and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC
these expressions would become more complex. It makes sense to hide
this complexity behind macros. This makes maintenance easier as these
macros are defined in a single place. As a plus the code becomes
more readable as well.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
drivers/net/axgbe/axgbe_rxtx.h | 12 ++++--------
drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 +---
drivers/net/dpaa2/dpaa2_rxtx.c | 15 +++------------
drivers/net/fm10k/fm10k_rxtx_vec.c | 4 +---
drivers/net/hns3/hns3_rxtx_vec_neon.h | 2 +-
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c | 2 +-
drivers/net/i40e/i40e_rxtx_common_avx.h | 4 +---
drivers/net/i40e/i40e_rxtx_vec_altivec.c | 2 +-
drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +---
drivers/net/i40e/i40e_rxtx_vec_avx512.c | 4 +---
drivers/net/i40e/i40e_rxtx_vec_common.h | 4 +---
drivers/net/i40e/i40e_rxtx_vec_neon.c | 3 +--
drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +---
drivers/net/iavf/iavf_rxtx_vec_avx2.c | 4 +---
drivers/net/iavf/iavf_rxtx_vec_avx512.c | 4 +---
drivers/net/iavf/iavf_rxtx_vec_common.h | 4 +---
drivers/net/iavf/iavf_rxtx_vec_sse.c | 4 +---
drivers/net/ice/ice_rxtx_common_avx.h | 4 +---
drivers/net/ice/ice_rxtx_vec_avx2.c | 4 +---
drivers/net/ice/ice_rxtx_vec_avx512.c | 4 +---
drivers/net/ice/ice_rxtx_vec_common.h | 4 +---
drivers/net/ice/ice_rxtx_vec_sse.c | 4 +---
drivers/net/idpf/idpf_rxtx_vec_common.h | 4 +---
.../net/ixgbe/ixgbe_recycle_mbufs_vec_common.c | 2 +-
drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 2 +-
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +---
drivers/net/mlx5/mlx5_flow.c | 6 +++---
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 6 ++----
drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 2 +-
drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 4 +---
drivers/net/tap/tap_flow.c | 6 +++---
drivers/net/virtio/virtio_rxtx_simple.c | 4 +---
32 files changed, 42 insertions(+), 98 deletions(-)
diff --git a/drivers/net/axgbe/axgbe_rxtx.h b/drivers/net/axgbe/axgbe_rxtx.h
index a326ba9ac8..59583477ac 100644
--- a/drivers/net/axgbe/axgbe_rxtx.h
+++ b/drivers/net/axgbe/axgbe_rxtx.h
@@ -6,14 +6,10 @@
#ifndef _AXGBE_RXTX_H_
#define _AXGBE_RXTX_H_
-/* to suppress gcc warnings related to descriptor casting*/
-#ifdef RTE_TOOLCHAIN_GCC
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
-#ifdef RTE_TOOLCHAIN_CLANG
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+#include <rte_common.h>
+
+/* to suppress compiler warnings related to descriptor casting */
+__rte_diagnostic_ignored_wcast_qual
/* Descriptor related defines */
#define AXGBE_MAX_RING_DESC 4096 /*should be power of 2*/
diff --git a/drivers/net/cpfl/cpfl_rxtx_vec_common.h b/drivers/net/cpfl/cpfl_rxtx_vec_common.h
index 479e1ddcb9..5cc841022c 100644
--- a/drivers/net/cpfl/cpfl_rxtx_vec_common.h
+++ b/drivers/net/cpfl/cpfl_rxtx_vec_common.h
@@ -11,9 +11,7 @@
#include "cpfl_ethdev.h"
#include "cpfl_rxtx.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
#define CPFL_SCALAR_PATH 0
#define CPFL_VECTOR_PATH 1
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index e3b6c7e460..f2aba62588 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -1962,13 +1962,8 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
return num_tx;
}
-#if defined(RTE_TOOLCHAIN_GCC)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#elif defined(RTE_TOOLCHAIN_CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
/* This function loopbacks all the received packets.*/
uint16_t
@@ -2118,8 +2113,4 @@ dpaa2_dev_loopback_rx(void *queue,
return 0;
}
-#if defined(RTE_TOOLCHAIN_GCC)
-#pragma GCC diagnostic pop
-#elif defined(RTE_TOOLCHAIN_CLANG)
-#pragma clang diagnostic pop
-#endif
+__rte_diagnostic_pop
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 68acaca75b..d8c8eba9b5 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -11,9 +11,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static void
fm10k_reset_tx_queue(struct fm10k_tx_queue *txq);
diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h
index bbb5478015..429f37b8f7 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_neon.h
+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h
@@ -9,7 +9,7 @@
#include <arm_neon.h>
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
static inline void
hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)
diff --git a/drivers/net/i40e/i40e_recycle_mbufs_vec_common.c b/drivers/net/i40e/i40e_recycle_mbufs_vec_common.c
index 14424c9921..c399bfd95d 100644
--- a/drivers/net/i40e/i40e_recycle_mbufs_vec_common.c
+++ b/drivers/net/i40e/i40e_recycle_mbufs_vec_common.c
@@ -10,7 +10,7 @@
#include "i40e_ethdev.h"
#include "i40e_rxtx.h"
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
void
i40e_recycle_rx_descriptors_refill_vec(void *rx_queue, uint16_t nb_mbufs)
diff --git a/drivers/net/i40e/i40e_rxtx_common_avx.h b/drivers/net/i40e/i40e_rxtx_common_avx.h
index 85958d6c81..2a2635ce43 100644
--- a/drivers/net/i40e/i40e_rxtx_common_avx.h
+++ b/drivers/net/i40e/i40e_rxtx_common_avx.h
@@ -11,9 +11,7 @@
#include "i40e_ethdev.h"
#include "i40e_rxtx.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
#ifdef __AVX2__
static __rte_always_inline void
diff --git a/drivers/net/i40e/i40e_rxtx_vec_altivec.c b/drivers/net/i40e/i40e_rxtx_vec_altivec.c
index b6b0d38ec1..e3d4ec0459 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_altivec.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_altivec.c
@@ -15,7 +15,7 @@
#include <rte_altivec.h>
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
static inline void
i40e_rxq_rearm(struct i40e_rx_queue *rxq)
diff --git a/drivers/net/i40e/i40e_rxtx_vec_avx2.c b/drivers/net/i40e/i40e_rxtx_vec_avx2.c
index 19cf0ac718..49a9866ea9 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_avx2.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_avx2.c
@@ -15,9 +15,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static __rte_always_inline void
i40e_rxq_rearm(struct i40e_rx_queue *rxq)
diff --git a/drivers/net/i40e/i40e_rxtx_vec_avx512.c b/drivers/net/i40e/i40e_rxtx_vec_avx512.c
index 3b2750221b..c2148b65e4 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_avx512.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_avx512.c
@@ -15,9 +15,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
#define RTE_I40E_DESCS_PER_LOOP_AVX 8
diff --git a/drivers/net/i40e/i40e_rxtx_vec_common.h b/drivers/net/i40e/i40e_rxtx_vec_common.h
index 8b745630e4..94eaf6109d 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_common.h
+++ b/drivers/net/i40e/i40e_rxtx_vec_common.h
@@ -11,9 +11,7 @@
#include "i40e_ethdev.h"
#include "i40e_rxtx.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static inline uint16_t
reassemble_packets(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_bufs,
diff --git a/drivers/net/i40e/i40e_rxtx_vec_neon.c b/drivers/net/i40e/i40e_rxtx_vec_neon.c
index e1c5c7041b..fc82189e84 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_neon.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_neon.c
@@ -16,8 +16,7 @@
#include "i40e_rxtx.h"
#include "i40e_rxtx_vec_common.h"
-
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
static inline void
i40e_rxq_rearm(struct i40e_rx_queue *rxq)
diff --git a/drivers/net/i40e/i40e_rxtx_vec_sse.c b/drivers/net/i40e/i40e_rxtx_vec_sse.c
index ad560d2b6b..89a07f74f5 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_sse.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_sse.c
@@ -14,9 +14,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static inline void
i40e_rxq_rearm(struct i40e_rx_queue *rxq)
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx2.c b/drivers/net/iavf/iavf_rxtx_vec_avx2.c
index 49d41af953..d80b06c4a6 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx2.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx2.c
@@ -6,9 +6,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static __rte_always_inline void
iavf_rxq_rearm(struct iavf_rx_queue *rxq)
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index d6a861bf80..876935d199 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -6,9 +6,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
#define IAVF_DESCS_PER_LOOP_AVX 8
#define PKTLEN_SHIFT 10
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index 5c5220048d..fc886b0ab6 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -11,9 +11,7 @@
#include "iavf.h"
#include "iavf_rxtx.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static __rte_always_inline uint16_t
reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs,
diff --git a/drivers/net/iavf/iavf_rxtx_vec_sse.c b/drivers/net/iavf/iavf_rxtx_vec_sse.c
index 0db6fa8bd4..88556e1bf3 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_sse.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_sse.c
@@ -12,9 +12,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static inline void
iavf_rxq_rearm(struct iavf_rx_queue *rxq)
diff --git a/drivers/net/ice/ice_rxtx_common_avx.h b/drivers/net/ice/ice_rxtx_common_avx.h
index dacb87dcb0..7d2acc622f 100644
--- a/drivers/net/ice/ice_rxtx_common_avx.h
+++ b/drivers/net/ice/ice_rxtx_common_avx.h
@@ -7,9 +7,7 @@
#include "ice_rxtx.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
#ifdef __AVX2__
static __rte_always_inline void
diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c b/drivers/net/ice/ice_rxtx_vec_avx2.c
index d6e88dbb29..1d53404af8 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx2.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx2.c
@@ -7,9 +7,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static __rte_always_inline void
ice_rxq_rearm(struct ice_rx_queue *rxq)
diff --git a/drivers/net/ice/ice_rxtx_vec_avx512.c b/drivers/net/ice/ice_rxtx_vec_avx512.c
index add095ef06..e1f41312b5 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx512.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx512.c
@@ -7,9 +7,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
#define ICE_DESCS_PER_LOOP_AVX 8
diff --git a/drivers/net/ice/ice_rxtx_vec_common.h b/drivers/net/ice/ice_rxtx_vec_common.h
index 4b73465af5..537d1d086a 100644
--- a/drivers/net/ice/ice_rxtx_vec_common.h
+++ b/drivers/net/ice/ice_rxtx_vec_common.h
@@ -7,9 +7,7 @@
#include "ice_rxtx.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static inline uint16_t
ice_rx_reassemble_packets(struct ice_rx_queue *rxq, struct rte_mbuf **rx_bufs,
diff --git a/drivers/net/ice/ice_rxtx_vec_sse.c b/drivers/net/ice/ice_rxtx_vec_sse.c
index c01d8ede29..77ede76632 100644
--- a/drivers/net/ice/ice_rxtx_vec_sse.c
+++ b/drivers/net/ice/ice_rxtx_vec_sse.c
@@ -6,9 +6,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static inline __m128i
ice_flex_rxd_to_fdir_flags_vec(const __m128i fdir_id0_3)
diff --git a/drivers/net/idpf/idpf_rxtx_vec_common.h b/drivers/net/idpf/idpf_rxtx_vec_common.h
index 2787d27616..ba29901e67 100644
--- a/drivers/net/idpf/idpf_rxtx_vec_common.h
+++ b/drivers/net/idpf/idpf_rxtx_vec_common.h
@@ -11,9 +11,7 @@
#include "idpf_ethdev.h"
#include "idpf_rxtx.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
#define IDPF_SCALAR_PATH 0
#define IDPF_VECTOR_PATH 1
diff --git a/drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c b/drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c
index d451562269..b39661b3e3 100644
--- a/drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c
+++ b/drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c
@@ -8,7 +8,7 @@
#include "ixgbe_ethdev.h"
#include "ixgbe_rxtx.h"
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
void
ixgbe_recycle_rx_descriptors_refill_vec(void *rx_queue, uint16_t nb_mbufs)
diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c b/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
index 952b032eb6..25e820bef8 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
@@ -11,7 +11,7 @@
#include "ixgbe_rxtx.h"
#include "ixgbe_rxtx_vec_common.h"
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
static inline void
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
index a77370cdb7..5a5e8242ef 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
@@ -12,9 +12,7 @@
#include <rte_vect.h>
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
static inline void
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 16ddd05448..0a89d2c414 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7287,10 +7287,10 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)
{
struct mlx5_flow_tunnel *tunnel;
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
tunnel = (typeof(tunnel))flow->tunnel;
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
return tunnel;
}
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h
index 240987d03d..8fa91d1269 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h
@@ -25,10 +25,8 @@
#include "mlx5_rxtx_vec.h"
#include "mlx5_autoconf.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
-#endif
+__rte_diagnostic_ignored_wcast_qual
+__rte_diagnostic_ignored_wstrict_aliasing
/**
* Store free buffers to RX SW ring.
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
index dc1d30753d..d097bb443b 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
@@ -25,7 +25,7 @@
#include "mlx5_rxtx_vec.h"
#include "mlx5_autoconf.h"
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
/**
* Store free buffers to RX SW ring.
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
index 81a177fce7..f786a91032 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
@@ -24,9 +24,7 @@
#include "mlx5_rxtx_vec.h"
#include "mlx5_autoconf.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
/**
* Store free buffers to RX SW ring.
diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index c0e44bb1a7..373b773e2d 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -23,10 +23,10 @@
#ifdef HAVE_BPF_RSS
/* Workaround for warning in bpftool generated skeleton code */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
#include "tap_rss.skel.h"
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
#endif
#define ISOLATE_HANDLE 1
diff --git a/drivers/net/virtio/virtio_rxtx_simple.c b/drivers/net/virtio/virtio_rxtx_simple.c
index 438256970d..4037c212c2 100644
--- a/drivers/net/virtio/virtio_rxtx_simple.c
+++ b/drivers/net/virtio/virtio_rxtx_simple.c
@@ -23,9 +23,7 @@
#include "virtio_rxtx_simple.h"
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
int __rte_cold
virtio_rxq_vec_setup(struct virtnet_rx *rxq)
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] drivers/common: add diagnostics macros to make code portable
2024-12-27 1:33 ` [PATCH 2/3] drivers/common: " Andre Muezerie
@ 2024-12-27 17:57 ` Stephen Hemminger
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2024-12-27 17:57 UTC (permalink / raw)
To: Andre Muezerie
Cc: Bruce Richardson, Konstantin Ananyev, Jingjing Wu, Praveen Shetty, dev
On Thu, 26 Dec 2024 17:33:15 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:
> From: Andre Muezerie <andremue@linux.microsoft.com>
> To: Bruce Richardson <bruce.richardson@intel.com>, Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>, Jingjing Wu <jingjing.wu@intel.com>, Praveen Shetty <praveen.shetty@intel.com>
> Cc: dev@dpdk.org, Andre Muezerie <andremue@linux.microsoft.com>
> Subject: [PATCH 2/3] drivers/common: add diagnostics macros to make code portable
> Date: Thu, 26 Dec 2024 17:33:15 -0800
> X-Mailer: git-send-email 1.8.3.1
>
> It was a common pattern to have "GCC diagnostic ignored" pragmas
> sprinkled over the code and only activate these pragmas for certain
> compilers (gcc and clang). Clang supports GCC’s pragma for
> compatibility with existing source code, so #pragma GCC diagnostic
> and #pragma clang diagnostic are synonyms for Clang
> (https://clang.llvm.org/docs/UsersManual.html).
As much as possible, these should be fixed. Disabling warnings hides too many
pre-existing bugs.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-27 17:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-27 1:33 [PATCH 0/3] add diagnostics macros to make code portable Andre Muezerie
2024-12-27 1:33 ` [PATCH 1/3] lib/eal: " Andre Muezerie
2024-12-27 1:33 ` [PATCH 2/3] drivers/common: " Andre Muezerie
2024-12-27 17:57 ` Stephen Hemminger
2024-12-27 1:33 ` [PATCH 3/3] drivers/net: " Andre Muezerie
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).