]> err.no Git - linux-2.6/blobdiff - include/asm-powerpc/bitops.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/kkeil/ISDN-2.6
[linux-2.6] / include / asm-powerpc / bitops.h
index 36c8f3a43792e1c431d83edcfefc2a920242704d..897eade3afbeb0109159de4e1eb855f42ddab4e0 100644 (file)
@@ -312,7 +312,29 @@ static __inline__ int fls(unsigned int x)
        asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
        return 32 - lz;
 }
+
+static __inline__ unsigned long __fls(unsigned long x)
+{
+       return __ilog2(x);
+}
+
+/*
+ * 64-bit can do this using one cntlzd (count leading zeroes doubleword)
+ * instruction; for 32-bit we use the generic version, which does two
+ * 32-bit fls calls.
+ */
+#ifdef __powerpc64__
+static __inline__ int fls64(__u64 x)
+{
+       int lz;
+
+       asm ("cntlzd %0,%1" : "=r" (lz) : "r" (x));
+       return 64 - lz;
+}
+#else
 #include <asm-generic/bitops/fls64.h>
+#endif /* __powerpc64__ */
+
 #include <asm-generic/bitops/hweight.h>
 #include <asm-generic/bitops/find.h>