5 * Copyright 1992, Linus Torvalds.
8 #ifndef CONFIG_GENERIC_FIND_FIRST_BIT
10 * find_first_zero_bit - find the first zero bit in a memory region
11 * @addr: The address to start the search at
12 * @size: The maximum size to search
14 * Returns the bit number of the first zero bit, not the number of the byte
17 static inline int find_first_zero_bit(const unsigned long *addr, unsigned size)
24 /* This looks at memory.
25 * Mark it volatile to tell gcc not to move it around
27 asm volatile("movl $-1,%%eax\n\t"
28 "xorl %%edx,%%edx\n\t"
31 "xorl -4(%%edi),%%eax\n\t"
34 "1:\tsubl %%ebx,%%edi\n\t"
37 : "=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2)
38 : "1" ((size + 31) >> 5), "2" (addr),
39 "b" (addr) : "memory");
44 * find_first_bit - find the first set bit in a memory region
45 * @addr: The address to start the search at
46 * @size: The maximum size to search
48 * Returns the bit number of the first set bit, not the number of the byte
51 static inline unsigned find_first_bit(const unsigned long *addr, unsigned size)
56 unsigned long val = *addr++;
58 return __ffs(val) + x;
59 x += sizeof(*addr) << 3;
67 #include <asm-generic/bitops/sched.h>
69 #include <asm-generic/bitops/hweight.h>
71 #endif /* __KERNEL__ */
73 #include <asm-generic/bitops/fls64.h>
77 #include <asm-generic/bitops/ext2-non-atomic.h>
79 #define ext2_set_bit_atomic(lock, nr, addr) \
80 test_and_set_bit((nr), (unsigned long *)(addr))
81 #define ext2_clear_bit_atomic(lock, nr, addr) \
82 test_and_clear_bit((nr), (unsigned long *)(addr))
84 #include <asm-generic/bitops/minix.h>
86 #endif /* __KERNEL__ */
88 #endif /* _I386_BITOPS_H */