From patchwork Thu Apr 6 00:45:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125836 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 4627B428D0; Thu, 6 Apr 2023 02:46:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9DE042D46; Thu, 6 Apr 2023 02:45:32 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E217F40DF6 for ; Thu, 6 Apr 2023 02:45:22 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 822F8210DF02; Wed, 5 Apr 2023 17:45:21 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 822F8210DF02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680741921; bh=VdDBm/9cdO9+L/SxRkXgtMYczYWjvAWwD9x0sTv8lmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3W1rvjHuGyqg+y2Wlxy0hPyhA2G1oFX+imyrIukpCjnPAAgO4P2MKE0kNSkepuTF AKwhuis6aioQD+hjPtBMRPAFnPDOWHVt0YuJormsjIK/zCEc4haXx1M/wz02kELXXR Sc91iatTh6x9E6UiOqTf931DoWSvAShQmKwqBsk4= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, konstantin.ananyev@huawei.com, Tyler Retzlaff Subject: [PATCH v3 08/11] eal: expand most macros to empty when using msvc Date: Wed, 5 Apr 2023 17:45:16 -0700 Message-Id: <1680741919-22102-9-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680741919-22102-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> <1680741919-22102-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 For now expand a lot of common rte macros empty. The catch here is we need to test that most of the macros do what they should but at the same time they are blocking work needed to bootstrap of the unit tests. Later we will return and provide (where possible) expansions that work correctly for msvc and where not possible provide some alternate macros to achieve the same outcome. Signed-off-by: Tyler Retzlaff --- lib/eal/include/rte_branch_prediction.h | 8 ++++++++ lib/eal/include/rte_common.h | 33 +++++++++++++++++++++++++++++++++ lib/eal/include/rte_compat.h | 20 ++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/lib/eal/include/rte_branch_prediction.h b/lib/eal/include/rte_branch_prediction.h index 0256a9d..d9a0224 100644 --- a/lib/eal/include/rte_branch_prediction.h +++ b/lib/eal/include/rte_branch_prediction.h @@ -25,7 +25,11 @@ * */ #ifndef likely +#ifndef RTE_TOOLCHAIN_MSVC #define likely(x) __builtin_expect(!!(x), 1) +#else +#define likely(x) (x) +#endif #endif /* likely */ /** @@ -39,7 +43,11 @@ * */ #ifndef unlikely +#ifndef RTE_TOOLCHAIN_MSVC #define unlikely(x) __builtin_expect(!!(x), 0) +#else +#define unlikely(x) (x) +#endif #endif /* unlikely */ #ifdef __cplusplus diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 2f464e3..a724e22 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -65,7 +65,11 @@ /** * Force alignment */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_aligned(a) __attribute__((__aligned__(a))) +#else +#define __rte_aligned(a) +#endif #ifdef RTE_ARCH_STRICT_ALIGN typedef uint64_t unaligned_uint64_t __rte_aligned(1); @@ -88,8 +92,13 @@ #define __rte_may_alias __attribute__((__may_alias__)) /******* Macro to mark functions and fields scheduled for removal *****/ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_deprecated __attribute__((__deprecated__)) #define __rte_deprecated_msg(msg) __attribute__((__deprecated__(msg))) +#else +#define __rte_deprecated +#define __rte_deprecated_msg(msg) +#endif /** * Macro to mark macros and defines scheduled for removal @@ -117,7 +126,11 @@ /** * short definition to mark a function parameter unused */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_unused __attribute__((__unused__)) +#else +#define __rte_unused +#endif /** * Mark pointer as restricted with regard to pointer aliasing. @@ -141,6 +154,7 @@ * even if the underlying stdio implementation is ANSI-compliant, * so this must be overridden. */ +#ifndef RTE_TOOLCHAIN_MSVC #if RTE_CC_IS_GNU #define __rte_format_printf(format_index, first_arg) \ __attribute__((format(gnu_printf, format_index, first_arg))) @@ -148,6 +162,9 @@ #define __rte_format_printf(format_index, first_arg) \ __attribute__((format(printf, format_index, first_arg))) #endif +#else +#define __rte_format_printf(format_index, first_arg) +#endif /** * Tells compiler that the function returns a value that points to @@ -222,7 +239,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) /** * Hint never returning function */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_noreturn __attribute__((noreturn)) +#else +#define __rte_noreturn +#endif /** * Issue a warning in case the function's return value is ignored. @@ -247,12 +268,20 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) * } * @endcode */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_warn_unused_result __attribute__((warn_unused_result)) +#else +#define __rte_warn_unused_result +#endif /** * Force a function to be inlined */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_always_inline inline __attribute__((always_inline)) +#else +#define __rte_always_inline +#endif /** * Force a function to be noinlined @@ -437,7 +466,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) #define RTE_CACHE_LINE_MIN_SIZE 64 /** Force alignment to cache line. */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) +#else +#define __rte_cache_aligned +#endif /** Force minimum cache line alignment. */ #define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE) diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h index fc9fbaa..6a4b5ee 100644 --- a/lib/eal/include/rte_compat.h +++ b/lib/eal/include/rte_compat.h @@ -12,14 +12,22 @@ #ifndef ALLOW_EXPERIMENTAL_API +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_experimental \ __attribute__((deprecated("Symbol is not yet part of stable ABI"), \ section(".text.experimental"))) +#else +#define __rte_experimental +#endif #else +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_experimental \ __attribute__((section(".text.experimental"))) +#else +#define __rte_experimental +#endif #endif @@ -30,23 +38,35 @@ #if !defined ALLOW_INTERNAL_API && __has_attribute(error) /* For GCC */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_internal \ __attribute__((error("Symbol is not public ABI"), \ section(".text.internal"))) +#else +#define __rte_internal +#endif #elif !defined ALLOW_INTERNAL_API && __has_attribute(diagnose_if) /* For clang */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_internal \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \ __attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \ section(".text.internal"))) \ _Pragma("GCC diagnostic pop") +#else +#define __rte_internal +#endif #else +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_internal \ __attribute__((section(".text.internal"))) +#else +#define __rte_internal +#endif #endif