summaryrefslogtreecommitdiff
path: root/include/linux/bitmap.h
blob: c301d121c8d08846188518385e0e4a34056f421a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef __LINUX_BITMAP_H
#define __LINUX_BITMAP_H

#ifndef __ASSEMBLY__

#include <linux/config.h>
#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/bitops.h>
#include <linux/string.h>

int bitmap_empty(const unsigned long *bitmap, int bits);
int bitmap_full(const unsigned long *bitmap, int bits);
int bitmap_equal(const unsigned long *bitmap1,
			unsigned long *bitmap2, int bits);
void bitmap_complement(unsigned long *bitmap, int bits);

static inline void bitmap_zero(unsigned long *bitmap, int bits)
{
	memset(bitmap, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long));
}

static inline void bitmap_fill(unsigned long *bitmap, int bits)
{
	memset(bitmap, 0xff, BITS_TO_LONGS(bits)*sizeof(unsigned long));
}

static inline void bitmap_copy(unsigned long *dst,
			const unsigned long *src, int bits)
{
	int len = BITS_TO_LONGS(bits)*sizeof(unsigned long);
	memcpy(dst, src, len);
}

void bitmap_shift_right(unsigned long *dst,
			const unsigned long *src, int shift, int bits);
void bitmap_shift_left(unsigned long *dst,
			const unsigned long *src, int shift, int bits);
void bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
			const unsigned long *bitmap2, int bits);
void bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
			const unsigned long *bitmap2, int bits);
int bitmap_weight(const unsigned long *bitmap, int bits);
int bitmap_scnprintf(char *buf, unsigned int buflen,
			const unsigned long *maskp, int bits);
int bitmap_parse(const char __user *ubuf, unsigned int ubuflen,
			unsigned long *maskp, int bits);

#endif /* __ASSEMBLY__ */

#endif /* __LINUX_BITMAP_H */