PatchworkOS
Loading...
Searching...
No Matches
bitmap.h File Reference
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/math.h>

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.
 

Functions

static void bitmap_init (bitmap_t *map, void *buffer, uint64_t length)
 Initialize a bitmap.
 
static bool bitmap_is_set (bitmap_t *map, uint64_t idx)
 Check if a bit is set in the bitmap.
 
static void bitmap_set (bitmap_t *map, uint64_t index)
 Set a bit in the bitmap.
 
static void bitmap_set_range (bitmap_t *map, uint64_t low, uint64_t high)
 Set a range of bits in the bitmap.
 
static uint64_t bitmap_find_clear_region_and_set (bitmap_t *map, uint64_t length, uintptr_t maxIdx, uint64_t align)
 Find a clear region of specified length and alignment, and set it.
 
static void bitmap_clear (bitmap_t *map, uint64_t index)
 Clear a bit in the bitmap.
 
static void bitmap_clear_range (bitmap_t *map, uint64_t low, uint64_t high)
 Clear a range of bits in the bitmap.
 
static uint64_t bitmap_sum (bitmap_t *map, uint64_t low, uint64_t high)
 Sum the number of set bits in a range.
 
static uint64_t bitmap_find_first_clear (bitmap_t *map)
 Find the first clear bit in the bitmap.
 
static uint64_t bitmap_find_first_set (bitmap_t *map, uint64_t startIdx)
 Find the first set bit in the bitmap.