1 #include <linux/compiler.h>
2 #include <linux/types.h>
3 #include <asm/intrinsics.h>
4 #include <linux/module.h>
5 #include <linux/bitops.h>
8 * Find next zero bit in a bitmap reasonably efficiently..
11 int __find_next_zero_bit (const void *addr
, unsigned long size
, unsigned long offset
)
13 unsigned long *p
= ((unsigned long *) addr
) + (offset
>> 6);
14 unsigned long result
= offset
& ~63UL;
23 tmp
|= ~0UL >> (64-offset
);
31 while (size
& ~63UL) {
42 if (tmp
== ~0UL) /* any bits zero? */
43 return result
+ size
; /* nope */
45 return result
+ ffz(tmp
);
47 EXPORT_SYMBOL(__find_next_zero_bit
);
50 * Find next bit in a bitmap reasonably efficiently..
52 int __find_next_bit(const void *addr
, unsigned long size
, unsigned long offset
)
54 unsigned long *p
= ((unsigned long *) addr
) + (offset
>> 6);
55 unsigned long result
= offset
& ~63UL;
64 tmp
&= ~0UL << offset
;
72 while (size
& ~63UL) {
82 tmp
&= ~0UL >> (64-size
);
83 if (tmp
== 0UL) /* Are any bits set? */
84 return result
+ size
; /* Nope. */
86 return result
+ __ffs(tmp
);
88 EXPORT_SYMBOL(__find_next_bit
);