DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
To: <dev@dpdk.org>, David Marchand <david.marchand@redhat.com>
Cc: "Mattias Rönnblom" <hofors@lysator.liu.se>,
	"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: [PATCH 1/2] bitset: discontinue the use of GCC builtin
Date: Wed, 16 Oct 2024 15:54:10 +0200	[thread overview]
Message-ID: <20241016135411.827850-1-mattias.ronnblom@ericsson.com> (raw)

Replace the use of __builtin_ffsll() with rte_bsf64() to be MSVC
compatible.

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
Suggested-by: David Marchand <david.marchand@redhat.com>
---
 lib/eal/include/rte_bitset.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/eal/include/rte_bitset.h b/lib/eal/include/rte_bitset.h
index 74c643a72a..27b7a2e34d 100644
--- a/lib/eal/include/rte_bitset.h
+++ b/lib/eal/include/rte_bitset.h
@@ -601,7 +601,6 @@ __rte_bitset_find_nowrap(const uint64_t *bitset, size_t __rte_unused size, size_
 
 	while (word_idx <= __RTE_BITSET_WORD_IDX(end_bit - 1)) {
 		uint64_t word;
-		int word_ffs;
 
 		word = bitset[word_idx];
 		if (find_clear)
@@ -609,16 +608,14 @@ __rte_bitset_find_nowrap(const uint64_t *bitset, size_t __rte_unused size, size_
 
 		word >>= offset;
 
-		word_ffs = __builtin_ffsll(word);
-
-		if (word_ffs != 0) {
-			ssize_t ffs = start_bit + word_ffs - 1;
+		if (word != 0) {
+			size_t ffs = start_bit + rte_bsf64(word);
 
 			/*
 			 * Check if set bit were among the last,
 			 * unused bits, in the last word.
 			 */
-			if (unlikely(ffs >= (ssize_t)end_bit))
+			if (unlikely(ffs >= end_bit))
 				return -1;
 
 			return ffs;
-- 
2.43.0


             reply	other threads:[~2024-10-16 14:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16 13:54 Mattias Rönnblom [this message]
2024-10-16 13:54 ` [PATCH 2/2] devtools: forbid the use of ffs compiler builtins Mattias Rönnblom
2024-10-16 15:04   ` Stephen Hemminger
2024-10-16 15:32     ` David Marchand
2024-10-16 15:39       ` Stephen Hemminger
2024-10-16 20:55         ` David Marchand
2024-10-17  5:50     ` Mattias Rönnblom
2024-10-16 15:19 ` [PATCH 1/2] bitset: discontinue the use of GCC builtin David Marchand
2024-10-16 20:55 ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241016135411.827850-1-mattias.ronnblom@ericsson.com \
    --to=mattias.ronnblom@ericsson.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hofors@lysator.liu.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).