DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal: use abstracted bit count functions
@ 2023-10-16  1:29 Tyler Retzlaff
  2023-10-16  2:06 ` [PATCH v2] " Tyler Retzlaff
  0 siblings, 1 reply; 3+ messages in thread
From: Tyler Retzlaff @ 2023-10-16  1:29 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, Joyce Kong, Tyler Retzlaff

Use DPDK abstracted bitcount functions in rte_bsf and rte_fls inline
functions.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/include/rte_bitops.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] eal: use abstracted bit count functions
  2023-10-16  1:29 [PATCH] eal: use abstracted bit count functions Tyler Retzlaff
@ 2023-10-16  2:06 ` Tyler Retzlaff
  2023-10-17 12:55   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Tyler Retzlaff @ 2023-10-16  2:06 UTC (permalink / raw)
  To: dev
  Cc: david.marchand, Anatoly Burakov, Harry van Haaren, Joyce Kong,
	Tyler Retzlaff

Use DPDK abstracted bitcount functions instead of gcc __builtin_'s

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] eal: use abstracted bit count functions
  2023-10-16  2:06 ` [PATCH v2] " Tyler Retzlaff
@ 2023-10-17 12:55   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2023-10-17 12:55 UTC (permalink / raw)
  To: Tyler Retzlaff
  Cc: dev, david.marchand, Anatoly Burakov, Harry van Haaren, Joyce Kong

16/10/2023 04:06, Tyler Retzlaff:
> Use DPDK abstracted bitcount functions instead of gcc __builtin_'s
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Applied, thanks.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-17 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-16  1:29 [PATCH] eal: use abstracted bit count functions Tyler Retzlaff
2023-10-16  2:06 ` [PATCH v2] " Tyler Retzlaff
2023-10-17 12:55   ` Thomas Monjalon

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).