summaryrefslogtreecommitdiffstats
path: root/include/asm-ppc/bitops.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1998-08-25 09:12:35 +0000
committerRalf Baechle <ralf@linux-mips.org>1998-08-25 09:12:35 +0000
commitc7fc24dc4420057f103afe8fc64524ebc25c5d37 (patch)
tree3682407a599b8f9f03fc096298134cafba1c9b2f /include/asm-ppc/bitops.h
parent1d793fade8b063fde3cf275bf1a5c2d381292cd9 (diff)
o Merge with Linux 2.1.116.
o New Newport console code. o New G364 console code.
Diffstat (limited to 'include/asm-ppc/bitops.h')
-rw-r--r--include/asm-ppc/bitops.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/include/asm-ppc/bitops.h b/include/asm-ppc/bitops.h
index 0a848013d..17fb6383b 100644
--- a/include/asm-ppc/bitops.h
+++ b/include/asm-ppc/bitops.h
@@ -1,5 +1,5 @@
/*
- * $Id: bitops.h,v 1.7 1997/08/03 00:12:07 paulus Exp $
+ * $Id: bitops.h,v 1.9 1998/07/26 03:05:28 davem Exp $
* bitops.h: Bit string operations on the ppc
*/
@@ -96,6 +96,38 @@ extern __inline__ int ffz(unsigned int x)
return 31 - n;
}
+#ifdef __KERNEL__
+
+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+#define ffs(x) generic_ffs(x)
+
+#if 0
+/* untested, someone with PPC knowledge? */
+/* From Alexander Kjeldaas <astor@guardian.no> */
+extern __inline__ int ffs(int x)
+{
+ int result;
+ asm ("cntlzw %0,%1" : "=r" (result) : "r" (x));
+ return 32 - result; /* IBM backwards ordering of bits */
+}
+#endif
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+#define hweight32(x) generic_hweight32(x)
+#define hweight16(x) generic_hweight16(x)
+#define hweight8(x) generic_hweight8(x)
+
+#endif /* __KERNEL__ */
+
/*
* This implementation of find_{first,next}_zero_bit was stolen from
* Linus' asm-alpha/bitops.h.