From patchwork Wed Mar 20 21:33:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138647 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 D5CC243D0A; Wed, 20 Mar 2024 22:33:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 541FE42E2D; Wed, 20 Mar 2024 22:33:42 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 3DEE242D80 for ; Wed, 20 Mar 2024 22:33:40 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 85C1720B74C1; Wed, 20 Mar 2024 14:33:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 85C1720B74C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710970419; bh=AoxkIcz98u0FQ8JOWwLgH8q2jdgzPIGO2CL1CCXocu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=idE/VIhte7b//1Xty0ytmLVT7qm29PBcJxJwJn5xcu7rwuON8M1BRMOLEaz2ikkxV 0vNDNjtR2zQB1Ewv13GChjkpWZRpxhgaY2bLBvUnQmjfQQaXbROh9XhJ/SlIceh5A3 iTMvTEINIgODNEmpnPbhim4esHP2lLG4vFrQ2ibQ= From: Tyler Retzlaff To: dev@dpdk.org Cc: =?utf-8?q?Morten_Br=C3=B8rup?= , Andrew Rybchenko , Tyler Retzlaff Subject: [PATCH 1/2] eal: provide macro for GCC builtin constant intrinsic Date: Wed, 20 Mar 2024 14:33:35 -0700 Message-Id: <1710970416-27841-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710970416-27841-1-git-send-email-roretzla@linux.microsoft.com> References: <1710970416-27841-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 MSVC does not have a __builtin_constant_p intrinsic so provide __rte_constant(e) that expands false for MSVC and to the intrinsic for GCC. Signed-off-by: Tyler Retzlaff Reviewed-by: Morten Brørup --- lib/eal/include/rte_common.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 298a5c6..d520be6 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -44,6 +44,12 @@ #endif #endif +#ifdef RTE_TOOLCHAIN_MSVC +#define __rte_constant(e) 0 +#else +#define __rte_constant(e) __extension__(__builtin_constant_p(e)) +#endif + /* * RTE_TOOLCHAIN_GCC is defined if the target is built with GCC, * while a host application (like pmdinfogen) may have another compiler. From patchwork Wed Mar 20 21:33:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138648 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 BDA2943D0A; Wed, 20 Mar 2024 22:33:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E31442E52; Wed, 20 Mar 2024 22:33:43 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4842342DF0 for ; Wed, 20 Mar 2024 22:33:40 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 926DC20B74C2; Wed, 20 Mar 2024 14:33:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 926DC20B74C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710970419; bh=Xgnxw5kbPdpr/6stM/xRxTFlKKcRaOPYkWsLcHCrk/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KNXgTlNApC24evIHmtCjeTY+JHoUisCItD27zZnnhkct8GiAUoJtH4y7/OsAIgI6n FT812OTw1fHoTAOV8O/F7aTdT21k2Nwyp2m6J1POP/SnhOgCmRSm0EF6p84pHDMv3q H8l4tLssB/8/L+bfsLwvCA6rjMUvDJAM7+SkP8Q0= From: Tyler Retzlaff To: dev@dpdk.org Cc: =?utf-8?q?Morten_Br=C3=B8rup?= , Andrew Rybchenko , Tyler Retzlaff Subject: [PATCH 2/2] mempool: use rte constant macro instead of GCC builtin Date: Wed, 20 Mar 2024 14:33:36 -0700 Message-Id: <1710970416-27841-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710970416-27841-1-git-send-email-roretzla@linux.microsoft.com> References: <1710970416-27841-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 Use newly introduced __rte_constant(e) macro instead of directly using __builtin_constant_p() allowing mempool to be built by MSVC. Signed-off-by: Tyler Retzlaff Reviewed-by: Morten Brørup --- lib/mempool/rte_mempool.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 23fd5c8..a3564fb 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -1521,7 +1521,7 @@ struct rte_mempool_cache * /* The cache is a stack, so copy will be in reverse order. */ cache_objs = &cache->objs[cache->len]; - if (__extension__(__builtin_constant_p(n)) && n <= cache->len) { + if (__rte_constant(n) && n <= cache->len) { /* * The request size is known at build time, and * the entire request can be satisfied from the cache, @@ -1542,8 +1542,7 @@ struct rte_mempool_cache * * If the request size 'n' is known at build time, the above comparison * ensures that n > cache->len here, so omit RTE_MIN(). */ - len = __extension__(__builtin_constant_p(n)) ? cache->len : - RTE_MIN(n, cache->len); + len = __rte_constant(n) ? cache->len : RTE_MIN(n, cache->len); cache->len -= len; remaining = n - len; for (index = 0; index < len; index++) @@ -1554,7 +1553,7 @@ struct rte_mempool_cache * * where the entire request can be satisfied from the cache * has already been handled above, so omit handling it here. */ - if (!__extension__(__builtin_constant_p(n)) && remaining == 0) { + if (!__rte_constant(n) && remaining == 0) { /* The entire request is satisfied from the cache. */ RTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_bulk, 1);