Lines Matching +full:word +full:- +full:size
1 /* SPDX-License-Identifier: GPL-2.0 */
9 * Within a word, bits are numbered LSB first. Lot's of places make
11 * This can cause confusion for large (> 1 word) bitmaps on a
12 * big-endian system because, unlike little endian, the number of each
13 * bit depends on the word size.
23 * The main difference is that bit 0-63 in the bit number field needs to be
62 addr += (nr ^ (BITS_PER_LONG - BITS_PER_BYTE)) / BITS_PER_BYTE; in arch_test_bit()
63 mask = 1UL << (nr & (BITS_PER_BYTE - 1)); in arch_test_bit()
75 #include <asm-generic/bitops/atomic.h>
76 #include <asm-generic/bitops/non-instrumented-non-atomic.h>
77 #include <asm-generic/bitops/lock.h>
84 unsigned long find_first_bit_inv(const unsigned long *addr, unsigned long size);
85 unsigned long find_next_bit_inv(const unsigned long *addr, unsigned long size,
88 #define for_each_set_bit_inv(bit, addr, size) \ argument
89 for ((bit) = find_first_bit_inv((addr), (size)); \
90 (bit) < (size); \
91 (bit) = find_next_bit_inv((addr), (size), (bit) + 1))
95 return set_bit(nr ^ (BITS_PER_LONG - 1), ptr); in set_bit_inv()
100 return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr); in clear_bit_inv()
106 return test_and_clear_bit(nr ^ (BITS_PER_LONG - 1), ptr); in test_and_clear_bit_inv()
111 return __set_bit(nr ^ (BITS_PER_LONG - 1), ptr); in __set_bit_inv()
116 return __clear_bit(nr ^ (BITS_PER_LONG - 1), ptr); in __clear_bit_inv()
122 return test_bit(nr ^ (BITS_PER_LONG - 1), ptr); in test_bit_inv()
126 * __flogr - find leftmost one
127 * @word - The word to search
133 static inline unsigned char __flogr(unsigned long word) in __flogr() argument
135 if (__builtin_constant_p(word)) { in __flogr()
138 if (!word) in __flogr()
140 if (!(word & 0xffffffff00000000UL)) { in __flogr()
141 word <<= 32; in __flogr()
144 if (!(word & 0xffff000000000000UL)) { in __flogr()
145 word <<= 16; in __flogr()
148 if (!(word & 0xff00000000000000UL)) { in __flogr()
149 word <<= 8; in __flogr()
152 if (!(word & 0xf000000000000000UL)) { in __flogr()
153 word <<= 4; in __flogr()
156 if (!(word & 0xc000000000000000UL)) { in __flogr()
157 word <<= 2; in __flogr()
160 if (!(word & 0x8000000000000000UL)) { in __flogr()
161 word <<= 1; in __flogr()
168 rp.even = word; in __flogr()
177 * __ffs - find first bit in word.
178 * @word: The word to search
182 static inline unsigned long __ffs(unsigned long word) in __ffs() argument
184 return __flogr(-word & word) ^ (BITS_PER_LONG - 1); in __ffs()
188 * ffs - find first bit set
189 * @word: the word to search
194 static inline int ffs(int word) in ffs() argument
196 unsigned long mask = 2 * BITS_PER_LONG - 1; in ffs()
197 unsigned int val = (unsigned int)word; in ffs()
199 return (1 + (__flogr(-val & val) ^ (BITS_PER_LONG - 1))) & mask; in ffs()
203 * __fls - find last (most-significant) set bit in a long word
204 * @word: the word to search
208 static inline unsigned long __fls(unsigned long word) in __fls() argument
210 return __flogr(word) ^ (BITS_PER_LONG - 1); in __fls()
214 * fls64 - find last set bit in a 64-bit word
215 * @word: the word to search
224 static inline int fls64(unsigned long word) in fls64() argument
226 unsigned long mask = 2 * BITS_PER_LONG - 1; in fls64()
228 return (1 + (__flogr(word) ^ (BITS_PER_LONG - 1))) & mask; in fls64()
232 * fls - find last (most-significant) bit set
233 * @word: the word to search
238 static inline int fls(unsigned int word) in fls() argument
240 return fls64(word); in fls()
244 #include <asm-generic/bitops/const_hweight.h>
245 #include <asm-generic/bitops/ffz.h>
246 #include <asm-generic/bitops/sched.h>
247 #include <asm-generic/bitops/le.h>
248 #include <asm-generic/bitops/ext2-atomic-setbit.h>