PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
bitmap.h File Reference
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/math.h>
Include dependency graph for bitmap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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.