Debug. Add bitmap_dump().
[pintos-anon] / src / lib / bitmap.h
1 #ifndef HEADER_BITMAP_H
2 #define HEADER_BITMAP_H 1
3
4 #include <stdbool.h>
5 #include <stddef.h>
6
7 typedef unsigned long elem_type;
8
9 struct bitmap
10   {
11     size_t bit_cnt;
12     elem_type *bits;
13   };
14
15 bool bitmap_init (struct bitmap *, size_t bit_cnt);
16 void bitmap_destroy (struct bitmap *);
17
18 size_t bitmap_size (const struct bitmap *);
19 size_t bitmap_storage_size (const struct bitmap *);
20
21 void bitmap_set (struct bitmap *, size_t idx, bool);
22 void bitmap_set_all (struct bitmap *, bool);
23
24 void bitmap_mark (struct bitmap *, size_t idx);
25 void bitmap_reset (struct bitmap *, size_t idx);
26 void bitmap_flip (struct bitmap *, size_t idx);
27
28 bool bitmap_test (const struct bitmap *, size_t idx);
29
30 #define BITMAP_ERROR ((size_t) -1)
31 size_t bitmap_scan (const struct bitmap *, bool);
32 size_t bitmap_find_and_set (struct bitmap *);
33 size_t bitmap_find_and_clear (struct bitmap *);
34
35 size_t bitmap_set_cnt (const struct bitmap *);
36 bool bitmap_clear_cnt (const struct bitmap *);
37
38 bool bitmap_any (const struct bitmap *);
39 bool bitmap_none (const struct bitmap *);
40 bool bitmap_all (const struct bitmap *);
41
42 #ifdef FILESYS
43 struct file;
44 void bitmap_read (struct bitmap *, struct file *);
45 void bitmap_write (const struct bitmap *, struct file *);
46 #endif
47
48 void bitmap_dump (const struct bitmap *);
49
50 #endif /* bitmap.h */