[v5,01/22] eal: provide macro to expand marker extensions
Checks
Commit Message
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
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.
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.
@@ -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 **********/