tools: sync find_next_bit implementation
[linux-2.6-microblaze.git] / tools / include / asm-generic / bitops / find.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_
3 #define _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_
4
5 extern unsigned long _find_next_bit(const unsigned long *addr1,
6                 const unsigned long *addr2, unsigned long nbits,
7                 unsigned long start, unsigned long invert, unsigned long le);
8
9 #ifndef find_next_bit
10 /**
11  * find_next_bit - find the next set bit in a memory region
12  * @addr: The address to base the search on
13  * @offset: The bitnumber to start searching at
14  * @size: The bitmap size in bits
15  *
16  * Returns the bit number for the next set bit
17  * If no bits are set, returns @size.
18  */
19 static inline
20 unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
21                             unsigned long offset)
22 {
23         return _find_next_bit(addr, NULL, size, offset, 0UL, 0);
24 }
25 #endif
26
27 #ifndef find_next_and_bit
28 /**
29  * find_next_and_bit - find the next set bit in both memory regions
30  * @addr1: The first address to base the search on
31  * @addr2: The second address to base the search on
32  * @offset: The bitnumber to start searching at
33  * @size: The bitmap size in bits
34  *
35  * Returns the bit number for the next set bit
36  * If no bits are set, returns @size.
37  */
38 static inline
39 unsigned long find_next_and_bit(const unsigned long *addr1,
40                 const unsigned long *addr2, unsigned long size,
41                 unsigned long offset)
42 {
43         return _find_next_bit(addr1, addr2, size, offset, 0UL, 0);
44 }
45 #endif
46
47 #ifndef find_next_zero_bit
48 /**
49  * find_next_zero_bit - find the next cleared bit in a memory region
50  * @addr: The address to base the search on
51  * @offset: The bitnumber to start searching at
52  * @size: The bitmap size in bits
53  *
54  * Returns the bit number of the next zero bit
55  * If no bits are zero, returns @size.
56  */
57 static inline
58 unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
59                                  unsigned long offset)
60 {
61         return _find_next_bit(addr, NULL, size, offset, ~0UL, 0);
62 }
63 #endif
64
65 #ifndef find_first_bit
66
67 /**
68  * find_first_bit - find the first set bit in a memory region
69  * @addr: The address to start the search at
70  * @size: The maximum number of bits to search
71  *
72  * Returns the bit number of the first set bit.
73  * If no bits are set, returns @size.
74  */
75 extern unsigned long find_first_bit(const unsigned long *addr,
76                                     unsigned long size);
77
78 #endif /* find_first_bit */
79
80 #ifndef find_first_zero_bit
81
82 /**
83  * find_first_zero_bit - find the first cleared bit in a memory region
84  * @addr: The address to start the search at
85  * @size: The maximum number of bits to search
86  *
87  * Returns the bit number of the first cleared bit.
88  * If no bits are zero, returns @size.
89  */
90 unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size);
91 #endif
92
93 #endif /*_TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_ */