|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 1/6] include/uk/arch: Add ukarch_ffs, ukarch_fls, ukarch_flsl functions for x86_64
Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
include/uk/arch/x86_64/atomic.h | 46 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/include/uk/arch/x86_64/atomic.h b/include/uk/arch/x86_64/atomic.h
index c5f30cc..c48d5bd 100644
--- a/include/uk/arch/x86_64/atomic.h
+++ b/include/uk/arch/x86_64/atomic.h
@@ -31,6 +31,34 @@
#endif
/**
+ * ukarch_ffs - find first (lowest) set bit in word.
+ * @word: The word to search
+ *
+ * Undefined if no bit exists, so code should check against 0 first.
+ */
+static inline unsigned int ukarch_ffs(unsigned int word)
+{
+ __asm__("bsfl %1,%0"
+ : "=r" (word)
+ : "rm" (word));
+ return word;
+}
+
+/**
+ * ukarch_fls - find last (highest) set bit in word.
+ * @word: The word to search
+ *
+ * Undefined if no bit exists, so code should check against 0 first.
+ */
+static inline unsigned int ukarch_fls(unsigned int word)
+{
+ __asm__("bsrl %1,%0"
+ : "=r" (word)
+ : "rm" (word));
+ return word;
+}
+
+/**
* ukarch_ffsl - find first (lowest) set bit in word.
* @word: The word to search
*
@@ -39,7 +67,21 @@
static inline unsigned long ukarch_ffsl(unsigned long word)
{
__asm__("bsfq %1,%0"
- :"=r" (word)
- :"rm" (word));
+ : "=r" (word)
+ : "rm" (word));
+ return word;
+}
+
+/**
+ * ukarch_flsl - find last (highest) set bit in word.
+ * @word: The word to search
+ *
+ * Undefined if no bit exists, so code should check against 0 first.
+ */
+static inline unsigned long ukarch_flsl(unsigned long word)
+{
+ __asm__("bsrq %1,%0"
+ : "=r" (word)
+ : "rm" (word));
return word;
}
--
2.11.0
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |