aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-01-05 14:06:34 +0100
committerFlorin Coras <florin.coras@gmail.com>2022-01-05 17:01:49 +0000
commitfdc874af1ea8be505cd5d88663215e4f4481a7a6 (patch)
tree6f79b63c766009dd9952d169388fe246f9ad47e6 /src
parent5b9cb0d275959aeb7f4e9dfb7353b638ec9a2e5a (diff)
vppinfra: few bitops inlines
Change-Id: I9aa01fafd5329a399aa9d72a6e2cc6c9d65dc85c Type: improvement Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vppinfra/bitops.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vppinfra/bitops.h b/src/vppinfra/bitops.h
index 17ad49ffb46..04365699f93 100644
--- a/src/vppinfra/bitops.h
+++ b/src/vppinfra/bitops.h
@@ -176,6 +176,32 @@ do { \
} \
} while (0)
+static_always_inline u64
+reset_lowest_set_bit (u64 x)
+{
+#ifdef __BMI__
+ return _blsr_u64 (x);
+#else
+ return x & (x - 1);
+#endif
+}
+
+static_always_inline u64
+get_lowest_set_bit (u64 x)
+{
+#ifdef __BMI__
+ return _blsi_u64 (x);
+#else
+ return x & -x;
+#endif
+}
+
+static_always_inline u64
+get_lowest_set_bit_index (u64 x)
+{
+ return __builtin_ctzll (x);
+}
+
#endif /* included_clib_bitops_h */
/*