patch-2.1.106 linux/include/asm-ppc/bitops.h

Next file: linux/include/asm-sparc/bitops.h
Previous file: linux/include/asm-mips/bitops.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.105/linux/include/asm-ppc/bitops.h linux/include/asm-ppc/bitops.h
@@ -97,6 +97,34 @@
 }
 
 /*
+ * 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)
+
+/*
  * This implementation of find_{first,next}_zero_bit was stolen from
  * Linus' asm-alpha/bitops.h.
  */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov