diff options
| author | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
| commit | 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch) | |
| tree | 868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /lib/kernel/bitmap.h | |
| parent | eae0bd57f0a26314a94785061888d193d186944a (diff) | |
| download | progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2 progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip | |
reorganize file structure to match the upstream requirements
Diffstat (limited to 'lib/kernel/bitmap.h')
| -rw-r--r-- | lib/kernel/bitmap.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/kernel/bitmap.h b/lib/kernel/bitmap.h new file mode 100644 index 0000000..a50593c --- /dev/null +++ b/lib/kernel/bitmap.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #ifndef __LIB_KERNEL_BITMAP_H | ||
| 2 | #define __LIB_KERNEL_BITMAP_H | ||
| 3 | |||
| 4 | #include <stdbool.h> | ||
| 5 | #include <stddef.h> | ||
| 6 | #include <inttypes.h> | ||
| 7 | |||
| 8 | /* Bitmap abstract data type. */ | ||
| 9 | |||
| 10 | /* Creation and destruction. */ | ||
| 11 | struct bitmap *bitmap_create (size_t bit_cnt); | ||
| 12 | struct bitmap *bitmap_create_in_buf (size_t bit_cnt, void *, size_t byte_cnt); | ||
| 13 | size_t bitmap_buf_size (size_t bit_cnt); | ||
| 14 | void bitmap_destroy (struct bitmap *); | ||
| 15 | |||
| 16 | /* Bitmap size. */ | ||
| 17 | size_t bitmap_size (const struct bitmap *); | ||
| 18 | |||
| 19 | /* Setting and testing single bits. */ | ||
| 20 | void bitmap_set (struct bitmap *, size_t idx, bool); | ||
| 21 | void bitmap_mark (struct bitmap *, size_t idx); | ||
| 22 | void bitmap_reset (struct bitmap *, size_t idx); | ||
| 23 | void bitmap_flip (struct bitmap *, size_t idx); | ||
| 24 | bool bitmap_test (const struct bitmap *, size_t idx); | ||
| 25 | |||
| 26 | /* Setting and testing multiple bits. */ | ||
| 27 | void bitmap_set_all (struct bitmap *, bool); | ||
| 28 | void bitmap_set_multiple (struct bitmap *, size_t start, size_t cnt, bool); | ||
| 29 | size_t bitmap_count (const struct bitmap *, size_t start, size_t cnt, bool); | ||
| 30 | bool bitmap_contains (const struct bitmap *, size_t start, size_t cnt, bool); | ||
| 31 | bool bitmap_any (const struct bitmap *, size_t start, size_t cnt); | ||
| 32 | bool bitmap_none (const struct bitmap *, size_t start, size_t cnt); | ||
| 33 | bool bitmap_all (const struct bitmap *, size_t start, size_t cnt); | ||
| 34 | |||
| 35 | /* Finding set or unset bits. */ | ||
| 36 | #define BITMAP_ERROR SIZE_MAX | ||
| 37 | size_t bitmap_scan (const struct bitmap *, size_t start, size_t cnt, bool); | ||
| 38 | size_t bitmap_scan_and_flip (struct bitmap *, size_t start, size_t cnt, bool); | ||
| 39 | |||
| 40 | /* File input and output. */ | ||
| 41 | #ifdef FILESYS | ||
| 42 | struct file; | ||
| 43 | size_t bitmap_file_size (const struct bitmap *); | ||
| 44 | bool bitmap_read (struct bitmap *, struct file *); | ||
| 45 | bool bitmap_write (const struct bitmap *, struct file *); | ||
| 46 | #endif | ||
| 47 | |||
| 48 | /* Debugging. */ | ||
| 49 | void bitmap_dump (const struct bitmap *); | ||
| 50 | |||
| 51 | #endif /* lib/kernel/bitmap.h */ | ||
