[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


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Fri, 3 Aug 2018 13:58:32 +0300
  • Cc: florian.schmidt@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx
  • Delivery-date: Fri, 03 Aug 2018 10:58:52 +0000
  • Ironport-phdr: 9a23:f7CLqBMQZynliUIPZHAl6mtUPXoX/o7sNwtQ0KIMzox0I///rarrMEGX3/hxlliBBdydt6oazbKO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxlJiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0yRD+s7bpkSAXwhSkHKTA37W/ZhM93gq1ZrhKsvABzz5LObY2JLvdyYr/RcNUHTmRBRMZRUClBD5uiYosIFOoBIedYr4/grFUIsBu+HRSsD/7oxzBUgX/2xrE60+UnEQ3c2AwgAsoOsGnPodrpL6ceS/i1zLTTwjnZdfNW3i7w5Y7VeR4iufGBRa98fMXMxUU1FA7Ijk+cpZL7Mz6XzOgAvXCX4/dvWO6ykWIqqAF8riKxysoihITFnJ8Zx1/a+Sh/3Y07P8e3SFRhbt6hCJZQsiaaOJZoTc46WGFovTo6yqUBuZ6mYCgG0JQnyADba/yAa4WI/BfjW/yQITd8nn5qZKm/iwyq8Ui90eLwTNO00FFSoipElNnDqGwN2gTO5sWIV/dx5ESs1DaV2wzN9O1JI1o4mKTDJ54k2LEwl54TsUrZHi/xnUX7lLOZdkI/+ui06uTnZK/qppuBN49slwHzKbghmtelDeQgLwgBRHKX+f671LH75032XK1KjuEqkqneqJ3aIMUbpqi4Aw9SyYYv8guwACm40NsGmXkKN1ZFeBOcj4j1IFHCOv/5Aum5g1i2lzdr3f/GNKX7AprRNnjDjKvhfbFl5k5SzAozyspf55NOBbEHOv7zQVP+tNzdDh84LgO03/3qCNNj2YwCXWKAGLSWPLnMvl+V/ugvOfWDZJcJuDbhLPgo/+XujX48mV8ae6mlx5gXaG2mEfRgIkSWf2Dsj8wHEWgUogU+SPblh0aYXTFNena4R7g86S0jCIK6EYfDQZiggbyc3CehH51afH5GCleIEXj0d4WEWPAMaDyJL89njDMLSbyhRJU62h20qgD61ukvEu2B/ywetJX4kdR4+eDXvRUz7iBvSdSQ1SeKVW4nsHkPQmod27tjoEo17kqbzOAsiPtDCd1VofdUShoSPoWa1/FwTcr1DFGSNuyVQUqrF431SQo6Scg8locD
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.