patch-pre2.0.8 linux/arch/ppc/kernel/support.c
Next file: linux/arch/ppc/kernel/syscalls.c
Previous file: linux/arch/ppc/kernel/stubs.c
Back to the patch index
Back to the overall index
- Lines: 85
- Date:
Mon May 27 12:00:58 1996
- Orig file:
pre2.0.7/linux/arch/ppc/kernel/support.c
- Orig date:
Thu Jan 1 02:00:00 1970
diff -u --recursive --new-file pre2.0.7/linux/arch/ppc/kernel/support.c linux/arch/ppc/kernel/support.c
@@ -0,0 +1,84 @@
+/*
+ * Miscallaneous support routines
+ */
+
+#include <asm/bitops.h>
+
+/*extern __inline__*/ int find_first_zero_bit(void *add, int len)
+{
+ int mask, nr, i;
+ BITFIELD *addr = add;
+ nr = 0;
+ while (len)
+ {
+ if (~*addr != 0)
+ { /* Contains at least one zero */
+ for (i = 0; i < 32; i++, nr++)
+ {
+ mask = BIT(nr);
+ if ((mask & *addr) == 0)
+ {
+ return (nr);
+ }
+ }
+ }
+ len -= 32;
+ addr++;
+ nr += 32;
+ }
+ return (0); /* Shouldn't happen */
+}
+
+/*extern __inline__*/ int find_next_zero_bit(void *add, int last_bit, int nr)
+{
+ int mask, i;
+ BITFIELD *addr = add;
+#if 0
+printk("Find next (%x, %x)", addr, nr);
+#endif
+ addr += nr >> 5;
+#if 0
+printk(" - Pat: %x(%08X)\n", addr, *addr);
+#endif
+ if ((nr & 0x1F) != 0)
+ {
+ if (*addr != 0xFFFFFFFF)
+ { /* At least one more bit available in this longword */
+ for (i = (nr&0x1F); i < 32; i++, nr++)
+ {
+ mask = BIT(nr);
+ if ((mask & *addr) == 0)
+ {
+#if 0
+printk("(1)Bit: %x(%d), Pat: %x(%08x)\n", nr, nr&0x1F, addr, *addr);
+#endif
+ return (nr);
+ }
+ }
+ }
+ addr++;
+ nr = (nr + 0x1F) & ~0x1F;
+ }
+ while (nr < last_bit)
+ {
+ if (*addr != 0xFFFFFFFF)
+ { /* Contains at least one zero */
+ for (i = 0; i < 32; i++, nr++)
+ {
+ mask = BIT(nr);
+ if ((mask & *addr) == 0)
+ {
+#if 0
+printk("(2)Bit: %x(%d), Pat: %x(%08x)\n", nr, nr&0x1F, addr, *addr);
+#endif
+ return (nr);
+ }
+ }
+ }
+ addr++;
+ nr += 32;
+ }
+ return (nr); /* Shouldn't happen */
+}
+
+
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this