AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
bitmap.h File Reference
#include <core/system.h>
#include <core/string.h>

Go to the source code of this file.

Data Structures

struct  bitmap
 A bitmap: its blocks, and its last bit's index. More...

Macros

#define BITMAP_BLOCK_SIZE   (32)
#define BITMAP_BLOCK_MASK   (BITMAP_BLOCK_SIZE - 1)
#define BITMAP_LOG2_BLOCK_SIZE   (5)
#define BITMAP_BLOCK_OFFSET(__bitmap__i__)
#define BITMAP_BIT_OFFSET(__bitmap__i__)
#define BITMAP_SIZE(n)
#define BITMAP_NEW(n)

Typedefs

typedef uint32_t bitmap_t

Functions

static size_t bitmap_size (size_t n)
 Returns the size in bytes of a bitmap of n bits.
static void bitmap_set (struct bitmap *bitmap, size_t index)
 Sets a bit.
static void bitmap_clear (struct bitmap *bitmap, size_t index)
 Clears a bit.
static int bitmap_check (struct bitmap *bitmap, size_t index)
 Returns whether a bit is set (non-zero if it is).
static void bitmap_set_range (struct bitmap *bitmap, size_t findex, size_t lindex)
 Sets the bits from findex to lindex, inclusive.
static void bitmap_clear_range (struct bitmap *bitmap, size_t findex, size_t lindex)
 Clears the bits from findex to lindex, inclusive.

Macro Definition Documentation

◆ BITMAP_BIT_OFFSET

#define BITMAP_BIT_OFFSET ( __bitmap__i__)
Value:
((__bitmap__i__) & (BITMAP_BLOCK_SIZE - 1))
#define BITMAP_BLOCK_SIZE
Definition bitmap.h:23

Definition at line 29 of file bitmap.h.

Referenced by bitmap_check(), bitmap_clear(), and bitmap_set().

◆ BITMAP_BLOCK_MASK

#define BITMAP_BLOCK_MASK   (BITMAP_BLOCK_SIZE - 1)

Definition at line 24 of file bitmap.h.

Referenced by bitmap_clear_range(), bitmap_set_range(), and bitmap_size().

◆ BITMAP_BLOCK_OFFSET

#define BITMAP_BLOCK_OFFSET ( __bitmap__i__)
Value:
((__bitmap__i__) >> BITMAP_LOG2_BLOCK_SIZE)
#define BITMAP_LOG2_BLOCK_SIZE
Definition bitmap.h:26

Definition at line 28 of file bitmap.h.

Referenced by bitmap_check(), bitmap_clear(), bitmap_clear_range(), bitmap_set(), and bitmap_set_range().

◆ BITMAP_BLOCK_SIZE

#define BITMAP_BLOCK_SIZE   (32)

Definition at line 23 of file bitmap.h.

Referenced by bitmap_clear_range(), bitmap_set_range(), and bitmap_size().

◆ BITMAP_LOG2_BLOCK_SIZE

#define BITMAP_LOG2_BLOCK_SIZE   (5)

Definition at line 26 of file bitmap.h.

◆ BITMAP_NEW

#define BITMAP_NEW ( n)
Value:
(&(struct bitmap){.map = (bitmap_t[BITMAP_SIZE(n)]){0}, .max_idx = (n) - 1})
#define BITMAP_SIZE(n)
Definition bitmap.h:32
uint32_t bitmap_t
Definition bitmap.h:14
A bitmap: its blocks, and its last bit's index.
Definition bitmap.h:17

Definition at line 33 of file bitmap.h.

◆ BITMAP_SIZE

#define BITMAP_SIZE ( n)
Value:
#define BITMAP_BLOCK_MASK
Definition bitmap.h:24
#define MEMBER_SIZE(type, member)
Definition system.h:15

Definition at line 32 of file bitmap.h.

Typedef Documentation

◆ bitmap_t

typedef uint32_t bitmap_t

Definition at line 14 of file bitmap.h.

Function Documentation

◆ bitmap_check()

int bitmap_check ( struct bitmap * bitmap,
size_t index )
inlinestatic

Returns whether a bit is set (non-zero if it is).

Definition at line 54 of file bitmap.h.

References BITMAP_BIT_OFFSET, BITMAP_BLOCK_OFFSET, and bitmap::map.

◆ bitmap_clear()

void bitmap_clear ( struct bitmap * bitmap,
size_t index )
inlinestatic

Clears a bit.

Definition at line 48 of file bitmap.h.

References BITMAP_BIT_OFFSET, BITMAP_BLOCK_OFFSET, and bitmap::map.

Referenced by bitmap_clear_range().

◆ bitmap_clear_range()

void bitmap_clear_range ( struct bitmap * bitmap,
size_t findex,
size_t lindex )
inlinestatic

Clears the bits from findex to lindex, inclusive.

Definition at line 89 of file bitmap.h.

References BITMAP_BLOCK_MASK, BITMAP_BLOCK_OFFSET, BITMAP_BLOCK_SIZE, bitmap_clear(), bitmap_clear_range(), bitmap::map, MEMBER_SIZE, and memset().

Referenced by bitmap_clear_range(), and buddy_setup().

◆ bitmap_set()

void bitmap_set ( struct bitmap * bitmap,
size_t index )
inlinestatic

Sets a bit.

Definition at line 42 of file bitmap.h.

References BITMAP_BIT_OFFSET, BITMAP_BLOCK_OFFSET, and bitmap::map.

Referenced by bitmap_set_range().

◆ bitmap_set_range()

void bitmap_set_range ( struct bitmap * bitmap,
size_t findex,
size_t lindex )
inlinestatic

Sets the bits from findex to lindex, inclusive.

Definition at line 60 of file bitmap.h.

References BITMAP_BLOCK_MASK, BITMAP_BLOCK_OFFSET, BITMAP_BLOCK_SIZE, bitmap_set(), bitmap_set_range(), bitmap::map, MEMBER_SIZE, and memset().

Referenced by bitmap_set_range(), and buddy_setup().

◆ bitmap_size()

size_t bitmap_size ( size_t n)
inlinestatic

Returns the size in bytes of a bitmap of n bits.

Definition at line 36 of file bitmap.h.

References BITMAP_BLOCK_MASK, BITMAP_BLOCK_SIZE, bitmap_size(), and MEMBER_SIZE.

Referenced by bitmap_size(), and buddy_setup().