1#ifndef __LIB_KERNEL_BITMAP_H
2#define __LIB_KERNEL_BITMAP_H
36#define BITMAP_ERROR SIZE_MAX
43size_t bitmap_file_size (
const struct bitmap *);
44bool bitmap_read (
struct bitmap *,
struct file *);
45bool bitmap_write (
const struct bitmap *,
struct file *);
static size_t byte_cnt(size_t bit_cnt)
Returns the number of bytes required for BIT_CNT bits.
struct bitmap * bitmap_create_in_buf(size_t bit_cnt, void *, size_t byte_cnt)
size_t bitmap_count(const struct bitmap *, size_t start, size_t cnt, bool)
Returns the number of bits in B between START and START + CNT, exclusive, that are set to VALUE.
size_t bitmap_scan_and_flip(struct bitmap *, size_t start, size_t cnt, bool)
Finds the first group of CNT consecutive bits in B at or after START that are all set to VALUE,...
bool bitmap_contains(const struct bitmap *, size_t start, size_t cnt, bool)
Returns true if any bits in B between START and START + CNT, exclusive, are set to VALUE,...
void bitmap_destroy(struct bitmap *)
Destroys bitmap B, freeing its storage.
size_t bitmap_scan(const struct bitmap *, size_t start, size_t cnt, bool)
Finding set or unset bits.
void bitmap_set_multiple(struct bitmap *, size_t start, size_t cnt, bool)
Sets the CNT bits starting at START in B to VALUE.
size_t bitmap_buf_size(size_t bit_cnt)
Returns the number of bytes required to accomodate a bitmap with BIT_CNT bits (for use with bitmap_cr...
size_t bitmap_size(const struct bitmap *)
Bitmap size.
void bitmap_reset(struct bitmap *, size_t idx)
Atomically sets the bit numbered BIT_IDX in B to false.
void bitmap_set(struct bitmap *, size_t idx, bool)
Setting and testing single bits.
void bitmap_mark(struct bitmap *, size_t idx)
Atomically sets the bit numbered BIT_IDX in B to true.
void bitmap_set_all(struct bitmap *, bool)
Setting and testing multiple bits.
void bitmap_dump(const struct bitmap *)
File input and output.
bool bitmap_none(const struct bitmap *, size_t start, size_t cnt)
Returns true if no bits in B between START and START + CNT, exclusive, are set to true,...
bool bitmap_test(const struct bitmap *, size_t idx)
Returns the value of the bit numbered IDX in B.
void bitmap_flip(struct bitmap *, size_t idx)
Atomically toggles the bit numbered IDX in B; that is, if it is true, makes it false,...
bool bitmap_any(const struct bitmap *, size_t start, size_t cnt)
Returns true if any bits in B between START and START + CNT, exclusive, are set to true,...
struct bitmap * bitmap_create(size_t bit_cnt)
Bitmap abstract data type.
bool bitmap_all(const struct bitmap *, size_t start, size_t cnt)
Returns true if every bit in B between START and START + CNT, exclusive, is set to true,...
From the outside, a bitmap is an array of bits.
size_t bit_cnt
Number of bits.