Lines Matching +full:bit +full:- +full:mask

1 /* SPDX-License-Identifier: GPL-2.0 */
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
24 * reversed compared to the LSB0 encoded bit fields. This can be achieved by
42 #define __BITOPS_WORDS(bits) (((bits) + BITS_PER_LONG - 1) / BITS_PER_LONG)
49 addr = (unsigned long)ptr + ((nr ^ (nr & (BITS_PER_LONG - 1))) >> 3); in __bitops_word()
55 return 1UL << (nr & (BITS_PER_LONG - 1)); in __bitops_mask()
61 unsigned long mask = __bitops_mask(nr); in arch_set_bit() local
63 __atomic64_or(mask, (long *)addr); in arch_set_bit()
69 unsigned long mask = __bitops_mask(nr); in arch_clear_bit() local
71 __atomic64_and(~mask, (long *)addr); in arch_clear_bit()
78 unsigned long mask = __bitops_mask(nr); in arch_change_bit() local
80 __atomic64_xor(mask, (long *)addr); in arch_change_bit()
87 unsigned long mask = __bitops_mask(nr); in arch_test_and_set_bit() local
90 old = __atomic64_or_barrier(mask, (long *)addr); in arch_test_and_set_bit()
91 return old & mask; in arch_test_and_set_bit()
98 unsigned long mask = __bitops_mask(nr); in arch_test_and_clear_bit() local
101 old = __atomic64_and_barrier(~mask, (long *)addr); in arch_test_and_clear_bit()
102 return old & mask; in arch_test_and_clear_bit()
109 unsigned long mask = __bitops_mask(nr); in arch_test_and_change_bit() local
112 old = __atomic64_xor_barrier(mask, (long *)addr); in arch_test_and_change_bit()
113 return old & mask; in arch_test_and_change_bit()
120 unsigned long mask = __bitops_mask(nr); in arch___set_bit() local
122 *p |= mask; in arch___set_bit()
129 unsigned long mask = __bitops_mask(nr); in arch___clear_bit() local
131 *p &= ~mask; in arch___clear_bit()
138 unsigned long mask = __bitops_mask(nr); in arch___change_bit() local
140 *p ^= mask; in arch___change_bit()
147 unsigned long mask = __bitops_mask(nr); in arch___test_and_set_bit() local
151 *p |= mask; in arch___test_and_set_bit()
152 return old & mask; in arch___test_and_set_bit()
159 unsigned long mask = __bitops_mask(nr); in arch___test_and_clear_bit() local
163 *p &= ~mask; in arch___test_and_clear_bit()
164 return old & mask; in arch___test_and_clear_bit()
171 unsigned long mask = __bitops_mask(nr); in arch___test_and_change_bit() local
175 *p ^= mask; in arch___test_and_change_bit()
176 return old & mask; in arch___test_and_change_bit()
204 static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask, in arch_xor_unlock_is_negative_byte() argument
209 old = __atomic64_xor_barrier(mask, (long *)ptr); in arch_xor_unlock_is_negative_byte()
210 return old & BIT(7); in arch_xor_unlock_is_negative_byte()
214 #include <asm-generic/bitops/instrumented-atomic.h>
215 #include <asm-generic/bitops/instrumented-non-atomic.h>
216 #include <asm-generic/bitops/instrumented-lock.h>
219 * Functions which use MSB0 bit numbering.
227 #define for_each_set_bit_inv(bit, addr, size) \ argument
228 for ((bit) = find_first_bit_inv((addr), (size)); \
229 (bit) < (size); \
230 (bit) = find_next_bit_inv((addr), (size), (bit) + 1))
234 return set_bit(nr ^ (BITS_PER_LONG - 1), ptr); in set_bit_inv()
239 return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr); in clear_bit_inv()
245 return test_and_clear_bit(nr ^ (BITS_PER_LONG - 1), ptr); in test_and_clear_bit_inv()
250 return __set_bit(nr ^ (BITS_PER_LONG - 1), ptr); in __set_bit_inv()
255 return __clear_bit(nr ^ (BITS_PER_LONG - 1), ptr); in __clear_bit_inv()
261 return test_bit(nr ^ (BITS_PER_LONG - 1), ptr); in test_bit_inv()
265 * __flogr - find leftmost one
266 * @word - The word to search
268 * Returns the bit number of the most significant bit set,
269 * where the most significant bit has bit number 0.
270 * If no bit is set this function returns 64.
275 unsigned long bit = 0; in __flogr() local
281 bit += 32; in __flogr()
285 bit += 16; in __flogr()
289 bit += 8; in __flogr()
293 bit += 4; in __flogr()
297 bit += 2; in __flogr()
301 bit += 1; in __flogr()
303 return bit; in __flogr()
316 * __ffs - find first bit in word.
319 * Undefined if no bit exists, so code should check against 0 first.
323 return __flogr(-word & word) ^ (BITS_PER_LONG - 1); in __ffs()
327 * ffs - find first bit set
335 unsigned long mask = 2 * BITS_PER_LONG - 1; in ffs() local
338 return (1 + (__flogr(-val & val) ^ (BITS_PER_LONG - 1))) & mask; in ffs()
342 * __fls - find last (most-significant) set bit in a long word
345 * Undefined if no set bit exists, so code should check against 0 first.
349 return __flogr(word) ^ (BITS_PER_LONG - 1); in __fls()
353 * fls64 - find last set bit in a 64-bit word
357 * ffsll, but returns the position of the most significant set bit.
360 * set bit if value is nonzero. The last (most significant) bit is
365 unsigned long mask = 2 * BITS_PER_LONG - 1; in fls64() local
367 return (1 + (__flogr(word) ^ (BITS_PER_LONG - 1))) & mask; in fls64()
371 * fls - find last (most-significant) bit set
383 #include <asm-generic/bitops/const_hweight.h>
384 #include <asm-generic/bitops/ffz.h>
385 #include <asm-generic/bitops/sched.h>
386 #include <asm-generic/bitops/le.h>
387 #include <asm-generic/bitops/ext2-atomic-setbit.h>