From patchwork Mon Feb 12 20:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136602 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E8B243AF4; Mon, 12 Feb 2024 21:51:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D88D40274; Mon, 12 Feb 2024 21:51:57 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 11CF14026E for ; Mon, 12 Feb 2024 21:51:56 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 47F5B20B2000; Mon, 12 Feb 2024 12:51:55 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 47F5B20B2000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707771115; bh=a+i+utzJrB+OxiCfHRopj7WW7AEZoH4TPqFiMGs4u4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kKR5w2aaWmpa1a9/cyk5fTzyXU0ZK+7tH/kU9Dro4E9UG+6AF+zdA/k68NicVAh8i 0tnv9huY6Y7/RMc1M19xRoUbwythnZg3wnVmieMkJYP0PSU+Ftvlh0xHxjsTMelUz0 bJ4K8wSDQDWAFzF5aQEL0OmMJg+P8CQhA+IedzFg= From: Tyler Retzlaff To: dev@dpdk.org Cc: Jerin Jacob , Sunil Kumar Kori , david.marchand@redhat.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH v2] eal: provide macro to allocate and name a section or segment Date: Mon, 12 Feb 2024 12:51:46 -0800 Message-Id: <1707771106-29545-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1698878822-17099-1-git-send-email-roretzla@linux.microsoft.com> References: <1698878822-17099-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Morten Brørup --- 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) \ { \