[v5,01/22] eal: provide macro to expand marker extensions

Message ID 1708762927-14126-2-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series stop using RTE_MARKER extensions |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Tyler Retzlaff Feb. 24, 2024, 8:21 a.m. UTC
  RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide a
new macro __rte_marker(type, name) that may be used to expand RTE_MARKER
empty in struct definitions when building with MSVC.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/include/rte_common.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Feb. 24, 2024, 10:51 a.m. UTC | #1
24/02/2024 09:21, Tyler Retzlaff:
> RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide a
> new macro __rte_marker(type, name) that may be used to expand RTE_MARKER
> empty in struct definitions when building with MSVC.

I don't think we need to define a new marker macro.
I propose to simply not define them with MSVC, triggering a compilation error.
So we keep the old markers for applications which were not using MSVC anyway.
And inside DPDK libraries and drivers, we remove their usages.
  
Thomas Monjalon Feb. 24, 2024, 11:18 a.m. UTC | #2
24/02/2024 11:51, Thomas Monjalon:
> 24/02/2024 09:21, Tyler Retzlaff:
> > RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide a
> > new macro __rte_marker(type, name) that may be used to expand RTE_MARKER
> > empty in struct definitions when building with MSVC.
> 
> I don't think we need to define a new marker macro.
> I propose to simply not define them with MSVC, triggering a compilation error.
> So we keep the old markers for applications which were not using MSVC anyway.
> And inside DPDK libraries and drivers, we remove their usages.

One more thing to fix:
When padding is done on the marker, example:
	RTE_MARKER cacheline1 __rte_cache_min_aligned;
We need to move alignment on the first real field,
while keeping compatibility with the marker.
I'm afraid we need to have alignment done only once.

It may be difficult without using #ifdef inside the struct.

It's probably easier to replace alignment with explicit padding.
  

Patch

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 1cc1222..60d81a2 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -578,7 +578,11 @@  static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 
 /*********** Structure alignment markers ********/
 
-#ifndef RTE_TOOLCHAIN_MSVC
+#ifdef RTE_TOOLCHAIN_MSVC
+
+#define __rte_marker(type, name)
+
+#else
 
 /** Generic marker for any place in a structure. */
 __extension__ typedef void    *RTE_MARKER[0];
@@ -591,6 +595,8 @@  static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name;
+
 #endif
 
 /*********** Macros for calculating min and max **********/