Add a helper for a bitmap's size
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 26 Jan 2017 20:35:18 +0000 (15:35 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 9 Feb 2017 17:31:08 +0000 (12:31 -0500)
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/bitmap.h

index 46dc7da..5a591b3 100644 (file)
@@ -54,6 +54,7 @@
  * bitmap_find_free_region(bitmap, bits, order)        Find and allocate bit region
  * bitmap_release_region(bitmap, pos, order)   Free specified bit region
  * bitmap_allocate_region(bitmap, pos, order)  Allocate specified bit region
+ * bitmap_size(nbits)                          Size in bytes
  */
 
 /*
@@ -297,3 +298,8 @@ static inline int bitmap_parse(const char *buf, unsigned int buflen,
 {
        return __bitmap_parse(buf, buflen, 0, maskp, nmaskbits);
 }
+
+static inline size_t bitmap_size(int nbits)
+{
+       return BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+}