diff options
Diffstat (limited to 'include/linux/bitmap.h')
-rw-r--r-- | include/linux/bitmap.h | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 202e4034fe26..dbfbf4990005 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -52,16 +52,13 @@ | |||
52 | * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) | 52 | * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) |
53 | * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap | 53 | * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap |
54 | * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz | 54 | * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz |
55 | * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf | ||
56 | * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf | 55 | * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf |
57 | * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf | 56 | * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf |
58 | * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf | ||
59 | * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf | 57 | * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf |
60 | * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf | 58 | * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf |
61 | * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region | 59 | * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region |
62 | * bitmap_release_region(bitmap, pos, order) Free specified bit region | 60 | * bitmap_release_region(bitmap, pos, order) Free specified bit region |
63 | * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region | 61 | * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region |
64 | * bitmap_print_to_pagebuf(list, buf, mask, nbits) Print bitmap src as list/hex | ||
65 | */ | 62 | */ |
66 | 63 | ||
67 | /* | 64 | /* |
@@ -96,10 +93,10 @@ extern int __bitmap_equal(const unsigned long *bitmap1, | |||
96 | const unsigned long *bitmap2, unsigned int nbits); | 93 | const unsigned long *bitmap2, unsigned int nbits); |
97 | extern void __bitmap_complement(unsigned long *dst, const unsigned long *src, | 94 | extern void __bitmap_complement(unsigned long *dst, const unsigned long *src, |
98 | unsigned int nbits); | 95 | unsigned int nbits); |
99 | extern void __bitmap_shift_right(unsigned long *dst, | 96 | extern void __bitmap_shift_right(unsigned long *dst, const unsigned long *src, |
100 | const unsigned long *src, int shift, int bits); | 97 | unsigned int shift, unsigned int nbits); |
101 | extern void __bitmap_shift_left(unsigned long *dst, | 98 | extern void __bitmap_shift_left(unsigned long *dst, const unsigned long *src, |
102 | const unsigned long *src, int shift, int bits); | 99 | unsigned int shift, unsigned int nbits); |
103 | extern int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, | 100 | extern int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, |
104 | const unsigned long *bitmap2, unsigned int nbits); | 101 | const unsigned long *bitmap2, unsigned int nbits); |
105 | extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, | 102 | extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, |
@@ -147,31 +144,31 @@ bitmap_find_next_zero_area(unsigned long *map, | |||
147 | align_mask, 0); | 144 | align_mask, 0); |
148 | } | 145 | } |
149 | 146 | ||
150 | extern int bitmap_scnprintf(char *buf, unsigned int len, | ||
151 | const unsigned long *src, int nbits); | ||
152 | extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, | 147 | extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, |
153 | unsigned long *dst, int nbits); | 148 | unsigned long *dst, int nbits); |
154 | extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, | 149 | extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, |
155 | unsigned long *dst, int nbits); | 150 | unsigned long *dst, int nbits); |
156 | extern int bitmap_scnlistprintf(char *buf, unsigned int len, | ||
157 | const unsigned long *src, int nbits); | ||
158 | extern int bitmap_parselist(const char *buf, unsigned long *maskp, | 151 | extern int bitmap_parselist(const char *buf, unsigned long *maskp, |
159 | int nmaskbits); | 152 | int nmaskbits); |
160 | extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen, | 153 | extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen, |
161 | unsigned long *dst, int nbits); | 154 | unsigned long *dst, int nbits); |
162 | extern void bitmap_remap(unsigned long *dst, const unsigned long *src, | 155 | extern void bitmap_remap(unsigned long *dst, const unsigned long *src, |
163 | const unsigned long *old, const unsigned long *new, int bits); | 156 | const unsigned long *old, const unsigned long *new, unsigned int nbits); |
164 | extern int bitmap_bitremap(int oldbit, | 157 | extern int bitmap_bitremap(int oldbit, |
165 | const unsigned long *old, const unsigned long *new, int bits); | 158 | const unsigned long *old, const unsigned long *new, int bits); |
166 | extern void bitmap_onto(unsigned long *dst, const unsigned long *orig, | 159 | extern void bitmap_onto(unsigned long *dst, const unsigned long *orig, |
167 | const unsigned long *relmap, int bits); | 160 | const unsigned long *relmap, unsigned int bits); |
168 | extern void bitmap_fold(unsigned long *dst, const unsigned long *orig, | 161 | extern void bitmap_fold(unsigned long *dst, const unsigned long *orig, |
169 | int sz, int bits); | 162 | unsigned int sz, unsigned int nbits); |
170 | extern int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order); | 163 | extern int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order); |
171 | extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order); | 164 | extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order); |
172 | extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); | 165 | extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); |
173 | extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); | 166 | #ifdef __BIG_ENDIAN |
174 | extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); | 167 | extern void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int nbits); |
168 | #else | ||
169 | #define bitmap_copy_le bitmap_copy | ||
170 | #endif | ||
171 | extern unsigned int bitmap_ord_to_pos(const unsigned long *bitmap, unsigned int ord, unsigned int nbits); | ||
175 | extern int bitmap_print_to_pagebuf(bool list, char *buf, | 172 | extern int bitmap_print_to_pagebuf(bool list, char *buf, |
176 | const unsigned long *maskp, int nmaskbits); | 173 | const unsigned long *maskp, int nmaskbits); |
177 | 174 | ||
@@ -185,33 +182,33 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf, | |||
185 | #define small_const_nbits(nbits) \ | 182 | #define small_const_nbits(nbits) \ |
186 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) | 183 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) |
187 | 184 | ||
188 | static inline void bitmap_zero(unsigned long *dst, int nbits) | 185 | static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) |
189 | { | 186 | { |
190 | if (small_const_nbits(nbits)) | 187 | if (small_const_nbits(nbits)) |
191 | *dst = 0UL; | 188 | *dst = 0UL; |
192 | else { | 189 | else { |
193 | int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); | 190 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
194 | memset(dst, 0, len); | 191 | memset(dst, 0, len); |
195 | } | 192 | } |
196 | } | 193 | } |
197 | 194 | ||
198 | static inline void bitmap_fill(unsigned long *dst, int nbits) | 195 | static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) |
199 | { | 196 | { |
200 | size_t nlongs = BITS_TO_LONGS(nbits); | 197 | unsigned int nlongs = BITS_TO_LONGS(nbits); |
201 | if (!small_const_nbits(nbits)) { | 198 | if (!small_const_nbits(nbits)) { |
202 | int len = (nlongs - 1) * sizeof(unsigned long); | 199 | unsigned int len = (nlongs - 1) * sizeof(unsigned long); |
203 | memset(dst, 0xff, len); | 200 | memset(dst, 0xff, len); |
204 | } | 201 | } |
205 | dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); | 202 | dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); |
206 | } | 203 | } |
207 | 204 | ||
208 | static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, | 205 | static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, |
209 | int nbits) | 206 | unsigned int nbits) |
210 | { | 207 | { |
211 | if (small_const_nbits(nbits)) | 208 | if (small_const_nbits(nbits)) |
212 | *dst = *src; | 209 | *dst = *src; |
213 | else { | 210 | else { |
214 | int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); | 211 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
215 | memcpy(dst, src, len); | 212 | memcpy(dst, src, len); |
216 | } | 213 | } |
217 | } | 214 | } |
@@ -309,22 +306,22 @@ static inline int bitmap_weight(const unsigned long *src, unsigned int nbits) | |||
309 | return __bitmap_weight(src, nbits); | 306 | return __bitmap_weight(src, nbits); |
310 | } | 307 | } |
311 | 308 | ||
312 | static inline void bitmap_shift_right(unsigned long *dst, | 309 | static inline void bitmap_shift_right(unsigned long *dst, const unsigned long *src, |
313 | const unsigned long *src, int n, int nbits) | 310 | unsigned int shift, int nbits) |
314 | { | 311 | { |
315 | if (small_const_nbits(nbits)) | 312 | if (small_const_nbits(nbits)) |
316 | *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> n; | 313 | *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> shift; |
317 | else | 314 | else |
318 | __bitmap_shift_right(dst, src, n, nbits); | 315 | __bitmap_shift_right(dst, src, shift, nbits); |
319 | } | 316 | } |
320 | 317 | ||
321 | static inline void bitmap_shift_left(unsigned long *dst, | 318 | static inline void bitmap_shift_left(unsigned long *dst, const unsigned long *src, |
322 | const unsigned long *src, int n, int nbits) | 319 | unsigned int shift, unsigned int nbits) |
323 | { | 320 | { |
324 | if (small_const_nbits(nbits)) | 321 | if (small_const_nbits(nbits)) |
325 | *dst = (*src << n) & BITMAP_LAST_WORD_MASK(nbits); | 322 | *dst = (*src << shift) & BITMAP_LAST_WORD_MASK(nbits); |
326 | else | 323 | else |
327 | __bitmap_shift_left(dst, src, n, nbits); | 324 | __bitmap_shift_left(dst, src, shift, nbits); |
328 | } | 325 | } |
329 | 326 | ||
330 | static inline int bitmap_parse(const char *buf, unsigned int buflen, | 327 | static inline int bitmap_parse(const char *buf, unsigned int buflen, |