[PATCH v2 2/3] eal: simplify internal/experimental tags definitions

David Marchand david.marchand at redhat.com
Thu Oct 15 13:29:15 CEST 2026


The tags definitions have become hard to read after adding support for
various compilers.

Let's reorder the definitions:
- put MSVC first, as it offers neither the section attribute nor helps
  with detecting wrong use of symbols,
- then for each tag
  - start with error/diagnostic tweaks for the respective !ALLOW cases,
  - if no tweak is available, and for the ALLOW cases, fallback to
    moving the symbol to a section,

Signed-off-by: David Marchand <david.marchand at redhat.com>
---
 lib/eal/include/rte_compat.h | 39 +++++++++++++++---------------------
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h
index 97c1540bd0..cb7836a190 100644
--- a/lib/eal/include/rte_compat.h
+++ b/lib/eal/include/rte_compat.h
@@ -6,64 +6,57 @@
 #ifndef _RTE_COMPAT_H_
 #define _RTE_COMPAT_H_
 
-#ifndef ALLOW_EXPERIMENTAL_API
-
 #ifdef RTE_TOOLCHAIN_MSVC
+
 #define __rte_experimental
-#else
+#define __rte_internal
+
+#else /* !RTE_TOOLCHAIN_MSVC */
+
+#ifndef ALLOW_EXPERIMENTAL_API
+
 #define __rte_experimental \
 __attribute__((deprecated("Symbol is not yet part of stable ABI"), \
 section(".text.experimental")))
-#endif
 
-#else
+#endif /* !ALLOW_EXPERIMENTAL_API */
 
-#ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_experimental
-#else
+#ifndef __rte_experimental
 #define __rte_experimental \
 __attribute__((section(".text.experimental")))
 #endif
 
-#endif
+#ifndef ALLOW_INTERNAL_API
 
 #ifndef __has_attribute
 /* if no has_attribute assume no support for attribute too */
 #define __has_attribute(x) 0
 #endif
 
-#if !defined ALLOW_INTERNAL_API && __has_attribute(error) /* For GCC */
+#if __has_attribute(error) /* For GCC */
 
-#ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_internal
-#else
 #define __rte_internal \
 __attribute__((error("Symbol is not public ABI"), \
 section(".text.internal")))
-#endif
 
-#elif !defined ALLOW_INTERNAL_API && __has_attribute(diagnose_if) /* For clang */
+#elif __has_attribute(diagnose_if) /* For clang */
 
-#ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_internal
-#else
 #define __rte_internal \
 _Pragma("GCC diagnostic push") \
 _Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \
 __attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \
 section(".text.internal"))) \
 _Pragma("GCC diagnostic pop")
+
 #endif
 
-#else
+#endif /* !ALLOW_INTERNAL_API */
 
-#ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_internal
-#else
+#ifndef __rte_internal
 #define __rte_internal \
 __attribute__((section(".text.internal")))
 #endif
 
-#endif
+#endif /* !RTE_TOOLCHAIN_MSVC */
 
 #endif /* _RTE_COMPAT_H_ */
-- 
2.54.0



More information about the dev mailing list