From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59FC445F26; Tue, 24 Dec 2024 04:06:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D99D0402AD; Tue, 24 Dec 2024 04:06:14 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E285B40263 for ; Tue, 24 Dec 2024 04:06:13 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 186CB206ADD6; Mon, 23 Dec 2024 19:06:13 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 186CB206ADD6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735009573; bh=M2EXoE9P6v+9Eq6VCWHi55eoiOZZhvZGz+0EBjebCI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lEp3FTTGwPwiKtifSLGv3bHg2L4aW1bnorDx5e1MEAeWk6ATZL6mmK7wQByIxL6r+ PDALj3QuSC4UIA8t3+VW1uFo4g1kLAeUcXKMIaJzG7yd0oOpzuLIW14TreyoB8TOw4 poh3WlqWm80uY+q2xLL5S0YNsj5pwQD4Q1rhtSIY= From: Andre Muezerie To: Tyler Retzlaff Cc: dev@dpdk.org, Andre Muezerie Subject: [PATCH 1/5] lib/eal: add portable macro for weak linking Date: Mon, 23 Dec 2024 19:05:48 -0800 Message-Id: <1735009552-31906-2-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1735009552-31906-1-git-send-email-andremue@linux.microsoft.com> References: <1735009552-31906-1-git-send-email-andremue@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 MSVC uses pragmas to indicate weak linking, so the old __rte_weak attribute needs to made into a macro so that the same syntax can be used for MSVC and other compilers like gcc. This patch adds macro RTE_WEAK and deprecates __rte_weak. Signed-off-by: Andre Muezerie --- lib/eal/include/rte_common.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 4d299f2b36..904b3ba5ec 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -137,10 +137,22 @@ typedef uint16_t unaligned_uint16_t; #define RTE_DEPRECATED(x) #endif +/** + * @deprecated + * @see RTE_WEAK + */ +#define __rte_weak (RTE_DEPRECATED(__rte_weak) __attribute__((__weak__))) + /** * Mark a function or variable to a weak reference. */ -#define __rte_weak __attribute__((__weak__)) +#ifdef RTE_TOOLCHAIN_MSVC +#define RTE_WEAK(FUNC_NAME) \ + (__pragma(comment(linker, "/alternatename:" #FUNC_NAME "=rte_weak_" \ + #FUNC_NAME)) rte_weak_ ## FUNC_NAME) +#else +#define RTE_WEAK(FUNC_NAME) (__attribute__((__weak__)) FUNC_NAME) +#endif /** * Mark a function to be pure. -- 2.47.0.vfs.0.3