|
PatchworkOS
da8a090
A non-POSIX operating system.
|
A bitmap optimized using 64-bit words. More...
A bitmap optimized using 64-bit words.
Data Structures | |
| struct | bitmap_t |
| Bitmap structure. More... | |
Macros | |
| #define | BITMAP_BITS_TO_QWORDS(bits) (((bits) + 63) / 64) |
| Convert number of bits to number of qwords. | |
| #define | BITMAP_BITS_TO_BYTES(bits) (BITMAP_BITS_TO_QWORDS(bits) * sizeof(uint64_t)) |
| Convert number of bits to number of bytes. | |
| #define | BITMAP_QWORDS_TO_BITS(qwords) ((qwords) * 64) |
| Convert number of qwords to number of bits. | |
| #define | BITMAP_FOR_EACH_SET(idx, map) |
| Iterate over each set bit in the bitmap. | |
| #define | BITMAP_CREATE(name, bits) |
| Define and create a bitmap and its buffer. | |
| #define | BITMAP_CREATE_ZERO(name, bits) |
| Define and create a zero-initialized bitmap and its buffer. | |
| #define | BITMAP_DEFINE(name, bits) |
| Define a bitmap and its buffer. | |
| #define | BITMAP_DEFINE_INIT(name, bits) bitmap_init(&(name), name##Buffer, bits); |
Initialize a bitmap defined with BITMAP_DEFINE. | |
Functions | |
| void | bitmap_init (bitmap_t *map, void *buffer, uint64_t length) |
| Initialize a bitmap. | |
| bool | bitmap_is_set (bitmap_t *map, uint64_t idx) |
| Check if a bit is set in the bitmap. | |
| void | bitmap_set (bitmap_t *map, uint64_t index) |
| Set a bit in the bitmap. | |
| void | bitmap_set_range (bitmap_t *map, uint64_t low, uint64_t high) |
| Set a range of bits in the bitmap. | |
| void | bitmap_clear (bitmap_t *map, uint64_t index) |
| Clear a bit in the bitmap. | |
| void | bitmap_clear_range (bitmap_t *map, uint64_t low, uint64_t high) |
| Clear a range of bits in the bitmap. | |
| uint64_t | bitmap_find_first_clear (bitmap_t *map, uint64_t startIdx, uint64_t endIdx) |
| Find the first clear bit in the bitmap. | |
| uint64_t | bitmap_find_first_set (bitmap_t *map, uint64_t startIdx, uint64_t endIdx) |
| Find the first set bit in the bitmap. | |
| uint64_t | bitmap_find_clear_region_and_set (bitmap_t *map, uint64_t minIdx, uintptr_t maxIdx, uint64_t length, uint64_t alignment) |
| Find a clear region of specified length and alignment, and set it. | |
| #define BITMAP_BITS_TO_QWORDS | ( | bits | ) | (((bits) + 63) / 64) |
| #define BITMAP_BITS_TO_BYTES | ( | bits | ) | (BITMAP_BITS_TO_QWORDS(bits) * sizeof(uint64_t)) |
| #define BITMAP_QWORDS_TO_BITS | ( | qwords | ) | ((qwords) * 64) |
| #define BITMAP_FOR_EACH_SET | ( | idx, | |
| map | |||
| ) |
Iterate over each set bit in the bitmap.
| idx | Pointer to store the current index. |
| map | The bitmap. |
| #define BITMAP_CREATE | ( | name, | |
| bits | |||
| ) |
Define and create a bitmap and its buffer.
| name | Name of the bitmap. |
| bits | Length of the bitmap in bits. |
| #define BITMAP_CREATE_ZERO | ( | name, | |
| bits | |||
| ) |
Define and create a zero-initialized bitmap and its buffer.
| name | Name of the bitmap. |
| bits | Length of the bitmap in bits. |
| #define BITMAP_DEFINE | ( | name, | |
| bits | |||
| ) |
Define a bitmap and its buffer.
Will not initialize the bitmap, use BITMAP_DEFINE_INIT to initialize it.
Intended to be used for struct members.
| name | Name of the bitmap. |
| bits | Length of the bitmap in bits. |
| #define BITMAP_DEFINE_INIT | ( | name, | |
| bits | |||
| ) | bitmap_init(&(name), name##Buffer, bits); |
Initialize a bitmap.
| map | The bitmap. |
| buffer | Pointer to the buffer, must be a multiple of 8 bytes. |
| length | Length of the bitmap in bits. |
Definition at line 3 of file bitmap_init.c.
Check if a bit is set in the bitmap.
| map | The bitmap. |
| idx | Index of the bit to check. |
Definition at line 3 of file bitmap_is_set.c.
Set a bit in the bitmap.
| map | Pointer to the bitmap. |
| index | Index of the bit to set. |
Definition at line 3 of file bitmap_set.c.
Set a range of bits in the bitmap.
| map | Pointer to the bitmap. |
| low | Low index of the range (inclusive). |
| high | High index of the range (exclusive). |
Definition at line 3 of file bitmap_set_range.c.
Clear a bit in the bitmap.
| map | Pointer to the bitmap. |
| index | Index of the bit to clear. |
Definition at line 3 of file bitmap_clear.c.
Clear a range of bits in the bitmap.
| map | Pointer to the bitmap. |
| low | Low index of the range (inclusive). |
| high | High index of the range (exclusive). |
Definition at line 3 of file bitmap_clear_range.c.
Find the first clear bit in the bitmap.
| map | The bitmap. |
| startIdx | Index to start searching from. |
| endIdx | Index to stop searching at (exclusive). |
map->length if none found. Definition at line 3 of file bitmap_find_first_clear.c.
Find the first set bit in the bitmap.
| map | The bitmap. |
| startIdx | Index to start searching from. |
| endIdx | Index to stop searching at (exclusive). |
map->length if none found. Definition at line 3 of file bitmap_find_first_set.c.
| uint64_t bitmap_find_clear_region_and_set | ( | bitmap_t * | map, |
| uint64_t | minIdx, | ||
| uintptr_t | maxIdx, | ||
| uint64_t | length, | ||
| uint64_t | alignment | ||
| ) |
Find a clear region of specified length and alignment, and set it.
| map | Pointer to the bitmap. |
| minIdx | Minimum index to start searching from. |
| maxIdx | Maximum index to search up to. |
| length | Length of the region to find. |
| alignment | Alignment of the region. |
map->length if not found. Definition at line 3 of file bitmap_find_clear_region_and_set.c.