patch-2_6_7-vs1_9_1_12
[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         int len = BITS_TO_LONGS(bits)*sizeof(unsigned long);
33         memcpy(dst, src, len);
34 }
35
36 void bitmap_shift_right(unsigned long *dst,
37                         const unsigned long *src, int shift, int bits);
38 void bitmap_shift_left(unsigned long *dst,
39                         const unsigned long *src, int shift, int bits);
40 void bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
41                         const unsigned long *bitmap2, int bits);
42 void bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
43                         const unsigned long *bitmap2, int bits);
44 int bitmap_weight(const unsigned long *bitmap, int bits);
45 int bitmap_scnprintf(char *buf, unsigned int buflen,
46                         const unsigned long *maskp, int bits);
47 int bitmap_parse(const char __user *ubuf, unsigned int ubuflen,
48                         unsigned long *maskp, int bits);
49
50 #endif /* __ASSEMBLY__ */
51
52 #endif /* __LINUX_BITMAP_H */