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 7D16343177; Mon, 16 Oct 2023 04:06:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB33640299; Mon, 16 Oct 2023 04:06:15 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8143640269 for ; Mon, 16 Oct 2023 04:06:14 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id B1BA720B74C0; Sun, 15 Oct 2023 19:06:13 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B1BA720B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1697421973; bh=PnjVBsVSv+BeKUou6FnfRZBD3rVjRtyeNm/htWsm+RY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nB33L3h+s0yIjpLiI75Q6TrITdMPKgQsM6+k+O2GwPRmffOuUvP+1EetIDEhHuRkM dpviNQo5p/5QqAInW8tvyssDnMIWsfyNTRl8aqF1KJBeblLrTUtZNhTvo8IPjYtdBC XpTTf9f5ZHFXYO/e+CLlV1uXPq9R88EyPlUca7g8= From: Tyler Retzlaff To: dev@dpdk.org Cc: david.marchand@redhat.com, Anatoly Burakov , Harry van Haaren , Joyce Kong , Tyler Retzlaff Subject: [PATCH v2] eal: use abstracted bit count functions Date: Sun, 15 Oct 2023 19:06:11 -0700 Message-Id: <1697421971-19254-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1697419762-13259-1-git-send-email-roretzla@linux.microsoft.com> References: <1697419762-13259-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 DPDK abstracted bitcount functions instead of gcc __builtin_'s Signed-off-by: Tyler Retzlaff --- lib/eal/common/malloc_elem.c | 2 +- lib/eal/common/rte_service.c | 4 ++-- lib/eal/include/rte_bitops.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/eal/common/malloc_elem.c b/lib/eal/common/malloc_elem.c index 619c040..f5d1c8c 100644 --- a/lib/eal/common/malloc_elem.c +++ b/lib/eal/common/malloc_elem.c @@ -386,7 +386,7 @@ return 0; /* Find next power of 2 > size. */ - log2 = sizeof(size) * 8 - __builtin_clzl(size); + log2 = sizeof(size) * 8 - rte_clz64(size); /* Compute freelist index, based on log2(size). */ index = (log2 - MALLOC_MINSIZE_LOG2 + MALLOC_LOG2_INCREMENT - 1) / diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c index 9e2aa4a..098a821 100644 --- a/lib/eal/common/rte_service.c +++ b/lib/eal/common/rte_service.c @@ -505,8 +505,8 @@ struct core_state { if (service_mask == 0) continue; - start_id = __builtin_ctzl(service_mask); - end_id = 64 - __builtin_clzl(service_mask); + start_id = rte_ctz64(service_mask); + end_id = 64 - rte_clz64(service_mask); for (i = start_id; i < end_id; i++) { /* return value ignored as no change to code flow */ diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h index d45aa54..6b8ae8d 100644 --- a/lib/eal/include/rte_bitops.h +++ b/lib/eal/include/rte_bitops.h @@ -574,7 +574,7 @@ static inline uint32_t rte_bsf32(uint32_t v) { - return (uint32_t)__builtin_ctz(v); + return (uint32_t)rte_ctz32(v); } /** @@ -615,7 +615,7 @@ static inline uint32_t rte_bsf64(uint64_t v) { - return (uint32_t)__builtin_ctzll(v); + return (uint32_t)rte_ctz64(v); } /** @@ -656,7 +656,7 @@ static inline uint32_t rte_fls_u32(uint32_t x) { - return (x == 0) ? 0 : 32 - __builtin_clz(x); + return (x == 0) ? 0 : 32 - rte_clz32(x); } /** @@ -674,7 +674,7 @@ static inline uint32_t rte_fls_u64(uint64_t x) { - return (x == 0) ? 0 : 64 - __builtin_clzll(x); + return (x == 0) ? 0 : 64 - rte_clz64(x); } /*********** Macros to work with powers of 2 ********/ -- 1.8.3.1