cvsignore
[pintos-anon] / src / lib / bitmap.h
index ba4465e4e595cf040574f8388be5bade0f837d85..ada1354d26944ab8d1bb1a8f1b26f0526f296fcd 100644 (file)
@@ -4,13 +4,28 @@
 #include <stdbool.h>
 #include <stddef.h>
 
+/* Bitmap abstract data type. */
+
+/* Element type.
+
+   This must be an unsigned integer type at least as wide as int.
+
+   Each bit represents one bit in the bitmap.
+   If bit 0 in an element represents bit K in the bitmap,
+   then bit 1 in the element represents bit K+1 in the bitmap,
+   and so on. */
+typedef unsigned long elem_type;
+
+/* From the outside, a bitmap is an array of bits.  From the
+   inside, it's an array of elem_type (defined above) that
+   simulates an array of bits. */
 struct bitmap
   {
-    size_t bit_cnt;
-    elem_type *bits;
+    size_t bit_cnt;     /* Number of bits. */
+    elem_type *bits;    /* Elements that represent bits. */
   };
 
-void bitmap_init (struct bitmap *, size_t bit_cnt);
+bool bitmap_init (struct bitmap *, size_t bit_cnt);
 void bitmap_destroy (struct bitmap *);
 
 size_t bitmap_size (const struct bitmap *);
@@ -36,4 +51,13 @@ bool bitmap_any (const struct bitmap *);
 bool bitmap_none (const struct bitmap *);
 bool bitmap_all (const struct bitmap *);
 
+#ifdef FILESYS
+struct file;
+size_t bitmap_file_size (const struct bitmap *);
+void bitmap_read (struct bitmap *, struct file *);
+void bitmap_write (const struct bitmap *, struct file *);
+#endif
+
+void bitmap_dump (const struct bitmap *);
+
 #endif /* bitmap.h */