ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / bitmap.h
1 #ifndef __LINUX_BITMAP_H
2 #define __LINUX_BITMAP_H
3
4 #ifndef __ASSEMBLY__
5
6 #include <linux/config.h>
7 #include <linux/compiler.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/bitops.h>
11 #include <linux/string.h>
12
13 int bitmap_empty(const unsigned long *bitmap, int bits);
14 int bitmap_full(const unsigned long *bitmap, int bits);
15 int bitmap_equal(const unsigned long *bitmap1,
16                         unsigned long *bitmap2, int bits);
17 void bitmap_complement(unsigned long *bitmap, int bits);
18
19 static inline void bitmap_zero(unsigned long *bitmap, int bits)
20 {
21         memset(bitmap, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long));
22 }
23
24 static inline void bitmap_fill(unsigned long *bitmap, int bits)
25 {
26         memset(bitmap, 0xff, BITS_TO_LONGS(bits)*sizeof(unsigned long));
27 }
28
29 static inline void bitmap_copy(unsigned long *dst,
30                         const unsigned long *src, int bits)
31 {
32         memcpy(dst, src, BITS_TO_LONGS(bits)*sizeof(unsigned long));
33 }
34
35 void bitmap_shift_right(unsigned long *dst,
36                         const unsigned long *src, int shift, int bits);
37 void bitmap_shift_left(unsigned long *dst,
38                         const unsigned long *src, int shift, int bits);
39 void bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
40                         const unsigned long *bitmap2, int bits);
41 void bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
42                         const unsigned long *bitmap2, int bits);
43 int bitmap_weight(const unsigned long *bitmap, int bits);
44 int bitmap_scnprintf(char *buf, unsigned int buflen,
45                         const unsigned long *maskp, int bits);
46 int bitmap_parse(const char __user *ubuf, unsigned int ubuflen,
47                         unsigned long *maskp, int bits);
48
49 #endif /* __ASSEMBLY__ */
50
51 #endif /* __LINUX_BITMAP_H */