Add fls_long() to bitops
authorXiao Jia <stfairy@gmail.com>
Fri, 26 Jun 2015 00:10:23 +0000 (17:10 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 23 Sep 2015 17:49:29 +0000 (13:49 -0400)
kern/include/bitops.h

index 71ee2b1..ae53c80 100644 (file)
@@ -69,6 +69,13 @@ static inline unsigned long hweight_long(unsigned long w)
        //return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
 }
 
+static inline unsigned fls_long(unsigned long l)
+{
+       if (sizeof(l) == 4)
+               return fls(l);
+       return fls64(l);
+}
+
 // not used yet and I have other things I'm trying to do
 #if 0
 static inline bool BITMASK_IS_SET_IN_RANGE(uint8_t* m, size_t beg, size_t end)