DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andre Muezerie <andremue@linux.microsoft.com>
To: andremue@linux.microsoft.com
Cc: dev@dpdk.org, stephen@networkplumber.org
Subject: [PATCH v2 1/3] lib/eal: add diagnostics macros to make code portable
Date: Fri, 27 Dec 2024 16:45:55 -0800	[thread overview]
Message-ID: <1735346757-14891-2-git-send-email-andremue@linux.microsoft.com> (raw)
In-Reply-To: <1735346757-14891-1-git-send-email-andremue@linux.microsoft.com>

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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 4d299f2b36..13b7b92f46 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -137,6 +137,29 @@ 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
+
+/*
+ * 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


  reply	other threads:[~2024-12-28  0:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-27  1:33 [PATCH 0/3] " 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 19:43     ` Andre Muezerie
2024-12-27  1:33 ` [PATCH 3/3] drivers/net: " Andre Muezerie
2024-12-28  0:45 ` [PATCH v2 0/3] " Andre Muezerie
2024-12-28  0:45   ` Andre Muezerie [this message]
2024-12-28  0:45   ` [PATCH v2 2/3] drivers/common: " Andre Muezerie
2024-12-28  0:45   ` [PATCH v2 3/3] drivers/net: " Andre Muezerie
2024-12-28  3:18 ` [PATCH v3 0/3] " Andre Muezerie
2024-12-28  3:18   ` [PATCH v3 1/3] lib/eal: " Andre Muezerie
2024-12-28  3:18   ` [PATCH v3 2/3] drivers/common: " Andre Muezerie
2024-12-28  3:18   ` [PATCH v3 3/3] drivers/net: " Andre Muezerie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1735346757-14891-2-git-send-email-andremue@linux.microsoft.com \
    --to=andremue@linux.microsoft.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).