[v2] eal: provide macro to allocate and name a section or segment
Checks
Commit Message
Provide __rte_section(name) macro that allocates and names a section
or segment that works with both MSVC and GCC.
Update RTE_TRACE_POINT_REGISTER with __rte_section("__rte_trace_point")
instead of __attribute__(section(name)) so the macro may be compatibly
expanded when using MSVC.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
v2:
* Define an internal macro __rte_section for the trace point
allocation and use it in RTE_TRACE_POINT_REGISTER instead of
duplicating original macro expansion for MSVC.
lib/eal/include/rte_common.h | 11 +++++++++++
lib/eal/include/rte_trace_point_register.h | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
Comments
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Monday, 12 February 2024 21.52
>
> Provide __rte_section(name) macro that allocates and names a section
> or segment that works with both MSVC and GCC.
>
> Update RTE_TRACE_POINT_REGISTER with __rte_section("__rte_trace_point")
> instead of __attribute__(section(name)) so the macro may be compatibly
> expanded when using MSVC.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
Acked-by: Morten Brørup <mb@smartsharesystems.com>
13/02/2024 09:51, Morten Brørup:
> > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> > Sent: Monday, 12 February 2024 21.52
> >
> > Provide __rte_section(name) macro that allocates and names a section
> > or segment that works with both MSVC and GCC.
> >
> > Update RTE_TRACE_POINT_REGISTER with __rte_section("__rte_trace_point")
> > instead of __attribute__(section(name)) so the macro may be compatibly
> > expanded when using MSVC.
> >
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
Applied (with minor nits fixed), thanks.
@@ -178,6 +178,17 @@
#endif
/**
+ * specify data or function section/segment
+ */
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_section(name) \
+ __pragma(data_seg(name)) __declspec(allocate(name))
+#else
+#define __rte_section(name) \
+ __attribute__((section(name)))
+#endif
+
+/**
* Tells compiler that the function returns a value that points to
* memory, where the size is given by the one or two arguments.
* Used by compiler to validate object size.
@@ -19,7 +19,7 @@
RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
#define RTE_TRACE_POINT_REGISTER(trace, name) \
-rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \
+rte_trace_point_t __rte_section("__rte_trace_point") __##trace; \
static const char __##trace##_name[] = RTE_STR(name); \
RTE_INIT(trace##_init) \
{ \