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 * __ffs - find first bit in word.
44 * @word: The word to search
46 * Undefined if no bit exists, so code should check against 0 first.
48 static inline unsigned long __ffs(unsigned long word
)
57 * find_first_bit - find the first set bit in a memory region
58 * @addr: The address to start the search at
59 * @size: The maximum size to search
61 * Returns the bit number of the first set bit, not the number of the byte
64 static inline unsigned find_first_bit(const unsigned long *addr
, unsigned size
)
69 unsigned long val
= *addr
++;
71 return __ffs(val
) + x
;
72 x
+= sizeof(*addr
) << 3;
78 * ffz - find first zero in word.
79 * @word: The word to search
81 * Undefined if no zero exists, so code should check against ~0UL first.
83 static inline unsigned long ffz(unsigned long word
)
93 #include <asm-generic/bitops/sched.h>
96 * ffs - find first bit set
97 * @x: the word to search
99 * This is defined the same way as
100 * the libc and compiler builtin ffs routines, therefore
101 * differs in spirit from the above ffz() (man ffs).
103 static inline int ffs(int x
)
107 __asm__("bsfl %1,%0\n\t"
110 "1:" : "=r" (r
) : "rm" (x
));
115 * fls - find last bit set
116 * @x: the word to search
118 * This is defined the same way as ffs().
120 static inline int fls(int x
)
124 __asm__("bsrl %1,%0\n\t"
127 "1:" : "=r" (r
) : "rm" (x
));
131 #include <asm-generic/bitops/hweight.h>
133 #endif /* __KERNEL__ */
135 #include <asm-generic/bitops/fls64.h>
139 #include <asm-generic/bitops/ext2-non-atomic.h>
141 #define ext2_set_bit_atomic(lock, nr, addr) \
142 test_and_set_bit((nr), (unsigned long *)(addr))
143 #define ext2_clear_bit_atomic(lock, nr, addr) \
144 test_and_clear_bit((nr), (unsigned long *)(addr))
146 #include <asm-generic/bitops/minix.h>
148 #endif /* __KERNEL__ */
150 #endif /* _I386_BITOPS_H */
This page took 0.033577 seconds and 5 git commands to generate.