Initial revision
[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 struct bitmap *bitmap_create (size_t bit_cnt);
8 void bitmap_destroy (struct bitmap *);
9
10 size_t bitmap_size (const struct bitmap *);
11
12 void bitmap_set (struct bitmap *, size_t idx, bool);
13 void bitmap_set_all (struct bitmap *, bool);
14
15 void bitmap_mark (struct bitmap *, size_t idx);
16 void bitmap_reset (struct bitmap *, size_t idx);
17 void bitmap_flip (struct bitmap *, size_t idx);
18
19 bool bitmap_test (const struct bitmap *, size_t idx);
20
21 #define BITMAP_ERROR ((size_t) -1)
22 size_t bitmap_scan (const struct bitmap *, bool);
23 size_t bitmap_find_and_set (struct bitmap *);
24 size_t bitmap_find_and_clear (struct bitmap *);
25
26 size_t bitmap_set_cnt (const struct bitmap *);
27 bool bitmap_clear_cnt (const struct bitmap *);
28
29 bool bitmap_any (const struct bitmap *);
30 bool bitmap_none (const struct bitmap *);
31 bool bitmap_all (const struct bitmap *);
32
33 #endif /* bitmap.h */