[v2] eal: provide macro to allocate and name a section or segment

Message ID 1707771106-29545-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] eal: provide macro to allocate and name a section or segment |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Tyler Retzlaff Feb. 12, 2024, 8:51 p.m. UTC
  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

Morten Brørup Feb. 13, 2024, 8:51 a.m. UTC | #1
> 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>
  
Thomas Monjalon Feb. 13, 2024, 11:28 a.m. UTC | #2
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.
  

Patch

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) \
 { \