1 #ifndef __LINUX_BITMAP_H
2 #define __LINUX_BITMAP_H
6 #include <linux/types.h>
7 #include <linux/bitops.h>
8 #include <linux/string.h>
9 #include <linux/kernel.h>
94 const unsigned long *bitmap2,
int bits);
98 const unsigned long *
src,
int shift,
int bits);
100 const unsigned long *
src,
int shift,
int bits);
101 extern int __bitmap_and(
unsigned long *
dst,
const unsigned long *bitmap1,
102 const unsigned long *bitmap2,
int bits);
103 extern void __bitmap_or(
unsigned long *
dst,
const unsigned long *bitmap1,
104 const unsigned long *bitmap2,
int bits);
105 extern void __bitmap_xor(
unsigned long *
dst,
const unsigned long *bitmap1,
106 const unsigned long *bitmap2,
int bits);
108 const unsigned long *bitmap2,
int bits);
110 const unsigned long *bitmap2,
int bits);
112 const unsigned long *bitmap2,
int bits);
121 unsigned long align_mask);
124 const unsigned long *
src,
int nbits);
126 unsigned long *
dst,
int nbits);
128 unsigned long *
dst,
int nbits);
130 const unsigned long *
src,
int nbits);
134 unsigned long *
dst,
int nbits);
136 const unsigned long *old,
const unsigned long *
new,
int bits);
138 const unsigned long *old,
const unsigned long *
new,
int bits);
139 extern void bitmap_onto(
unsigned long *
dst,
const unsigned long *orig,
140 const unsigned long *relmap,
int bits);
141 extern void bitmap_fold(
unsigned long *
dst,
const unsigned long *orig,
149 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
150 #define BITMAP_LAST_WORD_MASK(nbits) \
152 ((nbits) % BITS_PER_LONG) ? \
153 (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
156 #define small_const_nbits(nbits) \
157 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
159 static inline void bitmap_zero(
unsigned long *
dst,
int nbits)
169 static inline void bitmap_fill(
unsigned long *
dst,
int nbits)
173 int len = (nlongs - 1) *
sizeof(
unsigned long);
179 static inline void bitmap_copy(
unsigned long *dst,
const unsigned long *
src,
190 static inline int bitmap_and(
unsigned long *dst,
const unsigned long *src1,
191 const unsigned long *src2,
int nbits)
194 return (*dst = *src1 & *src2) != 0;
198 static inline void bitmap_or(
unsigned long *dst,
const unsigned long *src1,
199 const unsigned long *src2,
int nbits)
202 *dst = *src1 | *src2;
207 static inline void bitmap_xor(
unsigned long *dst,
const unsigned long *src1,
208 const unsigned long *src2,
int nbits)
211 *dst = *src1 ^ *src2;
216 static inline int bitmap_andnot(
unsigned long *dst,
const unsigned long *src1,
217 const unsigned long *src2,
int nbits)
220 return (*dst = *src1 & ~(*src2)) != 0;
224 static inline void bitmap_complement(
unsigned long *dst,
const unsigned long *src,
233 static inline int bitmap_equal(
const unsigned long *src1,
234 const unsigned long *src2,
int nbits)
242 static inline int bitmap_intersects(
const unsigned long *src1,
243 const unsigned long *src2,
int nbits)
251 static inline int bitmap_subset(
const unsigned long *src1,
252 const unsigned long *src2,
int nbits)
260 static inline int bitmap_empty(
const unsigned long *src,
int nbits)
268 static inline int bitmap_full(
const unsigned long *src,
int nbits)
276 static inline int bitmap_weight(
const unsigned long *src,
int nbits)
283 static inline void bitmap_shift_right(
unsigned long *dst,
284 const unsigned long *src,
int n,
int nbits)
292 static inline void bitmap_shift_left(
unsigned long *dst,
293 const unsigned long *src,
int n,
int nbits)
301 static inline int bitmap_parse(
const char *
buf,
unsigned int buflen,
302 unsigned long *maskp,
int nmaskbits)