|
@@ -66,6 +66,8 @@
|
|
* bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
|
|
* bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
|
|
* bitmap_from_u32array(dst, nbits, buf, nwords) *dst = *buf (nwords 32b words)
|
|
* bitmap_from_u32array(dst, nbits, buf, nwords) *dst = *buf (nwords 32b words)
|
|
* bitmap_to_u32array(buf, nwords, src, nbits) *buf = *dst (nwords 32b words)
|
|
* bitmap_to_u32array(buf, nwords, src, nbits) *buf = *dst (nwords 32b words)
|
|
|
|
+ * bitmap_from_arr32(dst, buf, nbits) Copy nbits from u32[] buf to dst
|
|
|
|
+ * bitmap_to_arr32(buf, src, nbits) Copy nbits from buf to u32[] dst
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -228,6 +230,35 @@ static inline void bitmap_copy(unsigned long *dst, const unsigned long *src,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Copy bitmap and clear tail bits in last word.
|
|
|
|
+ */
|
|
|
|
+static inline void bitmap_copy_clear_tail(unsigned long *dst,
|
|
|
|
+ const unsigned long *src, unsigned int nbits)
|
|
|
|
+{
|
|
|
|
+ bitmap_copy(dst, src, nbits);
|
|
|
|
+ if (nbits % BITS_PER_LONG)
|
|
|
|
+ dst[nbits / BITS_PER_LONG] &= BITMAP_LAST_WORD_MASK(nbits);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * On 32-bit systems bitmaps are represented as u32 arrays internally, and
|
|
|
|
+ * therefore conversion is not needed when copying data from/to arrays of u32.
|
|
|
|
+ */
|
|
|
|
+#if BITS_PER_LONG == 64
|
|
|
|
+extern void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf,
|
|
|
|
+ unsigned int nbits);
|
|
|
|
+extern void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap,
|
|
|
|
+ unsigned int nbits);
|
|
|
|
+#else
|
|
|
|
+#define bitmap_from_arr32(bitmap, buf, nbits) \
|
|
|
|
+ bitmap_copy_clear_tail((unsigned long *) (bitmap), \
|
|
|
|
+ (const unsigned long *) (buf), (nbits))
|
|
|
|
+#define bitmap_to_arr32(buf, bitmap, nbits) \
|
|
|
|
+ bitmap_copy_clear_tail((unsigned long *) (buf), \
|
|
|
|
+ (const unsigned long *) (bitmap), (nbits))
|
|
|
|
+#endif
|
|
|
|
+
|
|
static inline int bitmap_and(unsigned long *dst, const unsigned long *src1,
|
|
static inline int bitmap_and(unsigned long *dst, const unsigned long *src1,
|
|
const unsigned long *src2, unsigned int nbits)
|
|
const unsigned long *src2, unsigned int nbits)
|
|
{
|
|
{
|