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 B638945E6B; Tue, 10 Dec 2024 17:33:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A2DAA402E9; Tue, 10 Dec 2024 17:33:03 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 3ACA44026A for ; Tue, 10 Dec 2024 17:33:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 55A9E20BCAD0; Tue, 10 Dec 2024 08:33:01 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 55A9E20BCAD0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1733848381; bh=UMgOWAXWWn7UpxQ2pK1ILHaOgn3jEiRnfLlFeV0uynM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MRkPGOxNcdujmssEYuBG+w+mp4+JVO/kqFNmSuhH2lN3IAMeGjWFqZUYOtcvPbKhY 48eZjKcmZU31YNBx3A4ZAEbBsJnqCGkKRrq5iyQGjYbApLpiW/2tuaRUXBLcUVQ3tL NUlpa5LAgAAV0XQwaDZafJDTMN6Z/WziQDFdDjVA= From: Andre Muezerie To: Bruce Richardson , Konstantin Ananyev Cc: dev@dpdk.org, Andre Muezerie Subject: [PATCH 1/3] lib/eal: add rte_atomic128_cmp_exchange compatible with MSVC Date: Tue, 10 Dec 2024 08:32:32 -0800 Message-Id: <1733848355-19048-2-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1733848355-19048-1-git-send-email-andremue@linux.microsoft.com> References: <1733848355-19048-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 does not support inline assembly, which is used by the implementation of rte_atomic128_cmp_exchange and is needed by lib/stack. Error printed by MSVC: stack_rte_stack_lf.c.obj : error LNK2019: unresolved external symbol rte_atomic128_cmp_exchange referenced in function __rte_stack_lf_push_elems Fix is to provide an implementation for rte_atomic128_cmp_exchange which uses an intrinsic function, which is used when compiling with MSVC. For other compilers the existing implementation continues to be used. Signed-off-by: Andre Muezerie --- lib/eal/x86/include/rte_atomic.h | 4 ++-- lib/eal/x86/include/rte_atomic_64.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/eal/x86/include/rte_atomic.h b/lib/eal/x86/include/rte_atomic.h index c72c47c83e..e8e0e4c33c 100644 --- a/lib/eal/x86/include/rte_atomic.h +++ b/lib/eal/x86/include/rte_atomic.h @@ -288,12 +288,12 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v) #endif +#endif /* RTE_TOOLCHAIN_MSVC */ + #ifdef RTE_ARCH_I686 #include "rte_atomic_32.h" #else #include "rte_atomic_64.h" #endif -#endif - #endif /* _RTE_ATOMIC_X86_H_ */ diff --git a/lib/eal/x86/include/rte_atomic_64.h b/lib/eal/x86/include/rte_atomic_64.h index 0a7a2131e0..26c87a2da6 100644 --- a/lib/eal/x86/include/rte_atomic_64.h +++ b/lib/eal/x86/include/rte_atomic_64.h @@ -182,6 +182,23 @@ static inline void rte_atomic64_clear(rte_atomic64_t *v) /*------------------------ 128 bit atomic operations -------------------------*/ +#ifdef RTE_TOOLCHAIN_MSVC +static inline int +rte_atomic128_cmp_exchange(rte_int128_t *dst, + rte_int128_t *exp, + const rte_int128_t *src, + unsigned int weak, + int success, + int failure) +{ + return (int)_InterlockedCompareExchange128( + (int64_t volatile *) dst, + src->val[1], /* exchange high */ + src->val[0], /* exchange low */ + (int64_t *) exp /* comparand result */ + ); +} +#else static inline int rte_atomic128_cmp_exchange(rte_int128_t *dst, rte_int128_t *exp, @@ -212,5 +229,6 @@ rte_atomic128_cmp_exchange(rte_int128_t *dst, return res; } +#endif /* RTE_TOOLCHAIN_MSVC */ #endif /* _RTE_ATOMIC_X86_64_H_ */ -- 2.47.0.vfs.0.3