diff mbox series

[2/6] common: add bsf64 function similar to existing bsf32

Message ID ad34ed2862715a268ecf7d0a2909300617fae91b.1544550999.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series [1/6] bitmap: remove deprecated bsf64 function | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly Dec. 11, 2018, 5:57 p.m. UTC
Implement a new rte_bsf64 function that is following convention
set by existing rte_bsf32 function. Also, document the change in
release notes.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 doc/guides/rel_notes/release_19_02.rst     |  4 +++-
 lib/librte_eal/common/include/rte_common.h | 19 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

Comments

Thomas Monjalon Dec. 20, 2018, 9:08 a.m. UTC | #1
11/12/2018 18:57, Anatoly Burakov:
> Implement a new rte_bsf64 function that is following convention
> set by existing rte_bsf32 function. Also, document the change in
> release notes.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  doc/guides/rel_notes/release_19_02.rst     |  4 +++-
>  lib/librte_eal/common/include/rte_common.h | 19 ++++++++++++++++++-
>  2 files changed, 21 insertions(+), 2 deletions(-)

Could remove here the implementations in eal_memalloc.c and testpmd?
You could also update the test in this patch.
diff mbox series

Patch

diff --git a/doc/guides/rel_notes/release_19_02.rst b/doc/guides/rel_notes/release_19_02.rst
index ff81357d4..1d56ad43e 100644
--- a/doc/guides/rel_notes/release_19_02.rst
+++ b/doc/guides/rel_notes/release_19_02.rst
@@ -85,7 +85,9 @@  API Changes
 
 
 * eal: function ``rte_bsf64`` in ``rte_bitmap.h`` has been renamed to
-  ``rte_bsf64_safe`` and moved to ``rte_common.h``.
+  ``rte_bsf64_safe`` and moved to ``rte_common.h``. A new ``rte_bsf64`` function
+  has been added in ``rte_common.h`` that follows convention set by existing
+  ``rte_bsf32`` function.
 
 
 ABI Changes
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 66cdf60b2..2735dcca7 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -482,6 +482,23 @@  rte_fls_u32(uint32_t x)
 	return (x == 0) ? 0 : 32 - __builtin_clz(x);
 }
 
+/**
+ * Searches the input parameter for the least significant set bit
+ * (starting from zero).
+ * If a least significant 1 bit is found, its bit index is returned.
+ * If the content of the input parameter is zero, then the content of the return
+ * value is undefined.
+ * @param v
+ *     input parameter, should not be zero.
+ * @return
+ *     least significant set bit in the input parameter.
+ */
+static inline int
+rte_bsf64(uint64_t v)
+{
+	return (uint32_t)__builtin_ctzll(v);
+}
+
 /**
  * Searches the input parameter for the least significant set bit
  * (starting from zero). Safe version (checks for input parameter being zero).
@@ -502,7 +519,7 @@  rte_bsf64_safe(uint64_t v, uint32_t *pos)
 	if (v == 0)
 		return 0;
 
-	*pos = __builtin_ctzll(v);
+	*pos = rte_bsf64(v);
 	return 1;
 }