[PATCH v12 2/3] drivers/common: add diagnostics macros to make code portable
Bruce Richardson
bruce.richardson at intel.com
Wed Jan 15 12:13:02 CET 2025
On Tue, Jan 14, 2025 at 08:27:17PM -0800, Andre Muezerie wrote:
> 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 at linux.microsoft.com>
> ---
> drivers/common/idpf/idpf_common_rxtx_avx512.c | 77 ++++++++++---------
> 1 file changed, 39 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c b/drivers/common/idpf/idpf_common_rxtx_avx512.c
> index b8450b03ae..fefc0a05ca 100644
> --- a/drivers/common/idpf/idpf_common_rxtx_avx512.c
> +++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c
> @@ -6,10 +6,6 @@
> #include "idpf_common_device.h"
> #include "idpf_common_rxtx.h"
>
> -#ifndef __INTEL_COMPILER
> -#pragma GCC diagnostic ignored "-Wcast-qual"
> -#endif
> -
> #define IDPF_DESCS_PER_LOOP_AVX 8
> #define PKTLEN_SHIFT 10
>
> @@ -34,7 +30,7 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq)
> dma_addr0 = _mm_setzero_si128();
> for (i = 0; i < IDPF_VPMD_DESCS_PER_LOOP; i++) {
> rxp[i] = &rxq->fake_mbuf;
> - _mm_store_si128((__m128i *)&rxdp[i].read,
> + _mm_store_si128((__m128i *)RTE_IGNORE_CAST_QUAL(&rxdp[i].read),
> dma_addr0);
> }
> }
<SNIP for brevity>
Adding in the (void *) to the IGNORE macro will hugely reduce the amount of
casting being done in this file!
/Bruce
More information about the dev
mailing list