summaryrefslogtreecommitdiff
path: root/lib/ffz.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ffz.h')
-rw-r--r--lib/ffz.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ffz.h b/lib/ffz.h
index e17a2e9c..eef612d1 100644
--- a/lib/ffz.h
+++ b/lib/ffz.h
@@ -1,10 +1,16 @@
#ifndef FIO_FFZ_H
#define FIO_FFZ_H
-static inline int __ffs(int word)
+static inline int __ffs(unsigned long word)
{
int r = 0;
+#if BITS_PER_LONG == 64
+ if ((word & 0xffffffff) == 0) {
+ r += 32;
+ word >>= 32;
+ }
+#endif
if (!(word & 0xffff)) {
word >>= 16;
r += 16;
@@ -29,7 +35,7 @@ static inline int __ffs(int word)
return r;
}
-static inline int ffz(unsigned int bitmask)
+static inline int ffz(unsigned long bitmask)
{
return __ffs(~bitmask);
}