5 * Copyright 1992, Linus Torvalds.
9 * find_first_zero_bit - find the first zero bit in a memory region
10 * @addr: The address to start the search at
11 * @size: The maximum size to search
13 * Returns the bit number of the first zero bit, not the number of the byte
16 static inline int find_first_zero_bit(const unsigned long *addr, unsigned size)
23 /* This looks at memory.
24 * Mark it volatile to tell gcc not to move it around
26 asm volatile("movl $-1,%%eax\n\t"
27 "xorl %%edx,%%edx\n\t"
30 "xorl -4(%%edi),%%eax\n\t"
33 "1:\tsubl %%ebx,%%edi\n\t"
36 : "=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2)
37 : "1" ((size + 31) >> 5), "2" (addr),
38 "b" (addr) : "memory");
43 * find_first_bit - find the first set bit in a memory region
44 * @addr: The address to start the search at
45 * @size: The maximum size to search
47 * Returns the bit number of the first set bit, not the number of the byte
50 static inline unsigned find_first_bit(const unsigned long *addr, unsigned size)
55 unsigned long val = *addr++;
57 return __ffs(val) + x;
58 x += sizeof(*addr) << 3;
65 #include <asm-generic/bitops/sched.h>
67 #include <asm-generic/bitops/hweight.h>
69 #endif /* __KERNEL__ */
71 #include <asm-generic/bitops/fls64.h>
75 #include <asm-generic/bitops/ext2-non-atomic.h>
77 #define ext2_set_bit_atomic(lock, nr, addr) \
78 test_and_set_bit((nr), (unsigned long *)(addr))
79 #define ext2_clear_bit_atomic(lock, nr, addr) \
80 test_and_clear_bit((nr), (unsigned long *)(addr))
82 #include <asm-generic/bitops/minix.h>
84 #endif /* __KERNEL__ */
86 #endif /* _I386_BITOPS_H */