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

Next file: linux/include/asm-i386/math_emu.h
Previous file: linux/include/asm-generic/bitops.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.105/linux/include/asm-i386/bitops.h linux/include/asm-i386/bitops.h
@@ -187,6 +187,33 @@
 	return word;
 }
 
+/*
+ * 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).
+ */
+
+extern __inline__ int ffs(int x)
+{
+	int r;
+
+	__asm__("bsfl %1,%0\n\t"
+		"jnz 1f\n\t"
+		"movl $-1,%0\n"
+		"1:" : "=r" (r) : "g" (x));
+	return r+1;
+}
+
+/*
+ * 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)
+
+
 #ifdef __KERNEL__
 
 #define ext2_set_bit                 test_and_set_bit

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