aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bitops.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r--include/linux/bitops.h51
1 files changed, 50 insertions, 1 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 40d54731de7e..024f2b027244 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -6,8 +6,8 @@
6#define BIT(nr) (1UL << (nr)) 6#define BIT(nr) (1UL << (nr))
7#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) 7#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
8#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 8#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
9#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG)
10#define BITS_PER_BYTE 8 9#define BITS_PER_BYTE 8
10#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
11#endif 11#endif
12 12
13/* 13/*
@@ -112,4 +112,53 @@ static inline unsigned fls_long(unsigned long l)
112 return fls64(l); 112 return fls64(l);
113} 113}
114 114
115#ifdef __KERNEL__
116#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
117
118/**
119 * find_first_bit - find the first set bit in a memory region
120 * @addr: The address to start the search at
121 * @size: The maximum size to search
122 *
123 * Returns the bit number of the first set bit.
124 */
125extern unsigned long find_first_bit(const unsigned long *addr,
126 unsigned long size);
127
128/**
129 * find_first_zero_bit - find the first cleared bit in a memory region
130 * @addr: The address to start the search at
131 * @size: The maximum size to search
132 *
133 * Returns the bit number of the first cleared bit.
134 */
135extern unsigned long find_first_zero_bit(const unsigned long *addr,
136 unsigned long size);
137
138#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
139
140#ifdef CONFIG_GENERIC_FIND_NEXT_BIT
141
142/**
143 * find_next_bit - find the next set bit in a memory region
144 * @addr: The address to base the search on
145 * @offset: The bitnumber to start searching at
146 * @size: The bitmap size in bits
147 */
148extern unsigned long find_next_bit(const unsigned long *addr,
149 unsigned long size, unsigned long offset);
150
151/**
152 * find_next_zero_bit - find the next cleared bit in a memory region
153 * @addr: The address to base the search on
154 * @offset: The bitnumber to start searching at
155 * @size: The bitmap size in bits
156 */
157
158extern unsigned long find_next_zero_bit(const unsigned long *addr,
159 unsigned long size,
160 unsigned long offset);
161
162#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */
163#endif /* __KERNEL__ */
115#endif 164#endif