X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fbitmap.h;h=ada1354d26944ab8d1bb1a8f1b26f0526f296fcd;hb=45693e4cf682db525fc167d83bdcf7be919af12b;hp=2dbf38a4bdfb9faa179cbb6daa7b82ad209db915;hpb=dc83e159fc3dd0301a967aef2b84f1460aa3ef08;p=pintos-anon diff --git a/src/lib/bitmap.h b/src/lib/bitmap.h index 2dbf38a..ada1354 100644 --- a/src/lib/bitmap.h +++ b/src/lib/bitmap.h @@ -4,19 +4,31 @@ #include #include +/* 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. */ }; bool bitmap_init (struct bitmap *, size_t bit_cnt); void bitmap_destroy (struct bitmap *); size_t bitmap_size (const struct bitmap *); -size_t bitmap_storage_size (const struct bitmap *); void bitmap_set (struct bitmap *, size_t idx, bool); void bitmap_set_all (struct bitmap *, bool); @@ -41,6 +53,7 @@ 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