[PATCH v2] eal: provide macro to allocate and name a section or segment
Tyler Retzlaff
roretzla at linux.microsoft.com
Mon Feb 12 21:51:46 CET 2024
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 at 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(-)
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index c1ba32d..612f87b 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -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.
diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include/rte_trace_point_register.h
index a9682d3..41260e5 100644
--- a/lib/eal/include/rte_trace_point_register.h
+++ b/lib/eal/include/rte_trace_point_register.h
@@ -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) \
{ \
--
1.8.3.1
More information about the dev
mailing list