libisdn
|
Go to the source code of this file.
Defines | |
#define | BITMAP_GET(m, b) (!!((m)[BITMAP_OFFSET(b)] & (1 << BITMAP_BIT(b)))) |
#define | BITMAP_SET(m, b) ((m)[BITMAP_OFFSET(b)] |= (1 << BITMAP_BIT(b))) |
#define | BITMAP_UNSET(m, b) ((m)[BITMAP_OFFSET(b)] &= ~(1 << BITMAP_BIT(b))) |
#define | bitmap_debug(x,...) |
Functions | |
int | bitmap_create (bitmap_t **bm, const int nbits) |
int | bitmap_destroy (bitmap_t *bm) |
int | bitmap_init (bitmap_t *bm, const int nbits) |
int | bitmap_is_set (const bitmap_t *bm, const int nbits, const int pos) |
int | bitmap_set (bitmap_t *bm, const int nbits, const int pos) |
int | bitmap_unset (bitmap_t *bm, const int nbits, const int pos) |
int | bitmap_clear (bitmap_t *bm, const int nbits) |
int | bitmap_is_empty (const bitmap_t *bm, const int nbits) |
int | bitmap_next_bit (const bitmap_t *bm, const int nbits, const int last) |
int | bitmap_first_bit (const bitmap_t *bm, const int nbits) |
int | bitmap_count (const bitmap_t *bm, const int nbits) |
int | bitmap_dump (const bitmap_t *bm, const int nbits) |
#define bitmap_debug | ( | x, | |
... | |||
) |
Definition at line 22 of file bitmap.c.
Referenced by bitmap_next_bit().
#define BITMAP_GET | ( | m, | |
b | |||
) | (!!((m)[BITMAP_OFFSET(b)] & (1 << BITMAP_BIT(b)))) |
Definition at line 16 of file bitmap.c.
Referenced by bitmap_is_set().
#define BITMAP_SET | ( | m, | |
b | |||
) | ((m)[BITMAP_OFFSET(b)] |= (1 << BITMAP_BIT(b))) |
Definition at line 17 of file bitmap.c.
Referenced by bitmap_set().
#define BITMAP_UNSET | ( | m, | |
b | |||
) | ((m)[BITMAP_OFFSET(b)] &= ~(1 << BITMAP_BIT(b))) |
Definition at line 18 of file bitmap.c.
Referenced by bitmap_unset().
int bitmap_clear | ( | bitmap_t * | bm, |
const int | nbits | ||
) |
Clear all bits
[in] | bm | Bitmap |
[in] | nbits | Size of bitmap in bits 0 on success, -1 on error |
Definition at line 74 of file bitmap.c.
References BITMAP_SIZE_BYTES.
int bitmap_count | ( | const bitmap_t * | bm, |
const int | nbits | ||
) |
Count set bits in bitmap
[in] | bm | Bitmap |
[in] | nbits | Size of bitmap (number of bits) |
Definition at line 131 of file bitmap.c.
References bitmap_first_bit(), and bitmap_next_bit().
int bitmap_create | ( | bitmap_t ** | bm, |
const int | nbits | ||
) |
Allocate new bitmap with size of <nbits> bits ([0:nbits-1])
bm | Bitmap | |
[in] | nbits | Size in bits |
Definition at line 24 of file bitmap.c.
References BITMAP_SIZE_BYTES.
int bitmap_destroy | ( | bitmap_t * | bm | ) |
int bitmap_dump | ( | const bitmap_t * | bm, |
const int | nbits | ||
) |
Definition at line 140 of file bitmap.c.
References BITMAP_SIZE.
int bitmap_first_bit | ( | const bitmap_t * | bm, |
const int | nbits | ||
) |
Return first bit set in bitmap
[in] | bm | Bitmap |
[in] | nbits | Size of bitmap in bits |
Definition at line 126 of file bitmap.c.
References bitmap_next_bit().
Referenced by bitmap_count().
int bitmap_init | ( | bitmap_t * | bm, |
const int | nbits | ||
) |
Initialize a static bitmap with size <nbits> bits ([0:nbits-1])
[in] | bm | Bitmap |
[in] | nbits | Size of bitmap in bits |
Definition at line 43 of file bitmap.c.
References BITMAP_SIZE_BYTES.
int bitmap_is_empty | ( | const bitmap_t * | bm, |
const int | nbits | ||
) |
Check if map has no entries
[in] | bm | Bitmap |
[in] | nbits | Size of bitmap in bits |
Definition at line 82 of file bitmap.c.
References BITMAP_SIZE_BYTES.
int bitmap_is_set | ( | const bitmap_t * | bm, |
const int | nbits, | ||
const int | pos | ||
) |
Check whether a bit in the map is set
[in] | bm | Bitmap |
[in] | nbits | Size of bitmap in bits |
[in] | pos | Bit to check |
Definition at line 51 of file bitmap.c.
References BITMAP_GET.
int bitmap_next_bit | ( | const bitmap_t * | bm, |
const int | nbits, | ||
const int | last | ||
) |
Return next bit set in bitmap
[in] | bm | Bitmap |
[in] | nbits | Size of bitmap in bits |
[in] | last | Position of last set bit (output of bitmap_next_bit()) |
Definition at line 91 of file bitmap.c.
References BITMAP_BIT, bitmap_debug, BITMAP_OFFSET, and BITS_PER_LONG.
Referenced by bitmap_count(), and bitmap_first_bit().
int bitmap_set | ( | bitmap_t * | bm, |
const int | nbits, | ||
const int | pos | ||
) |
Set a bit in the map
[in] | bm | Bitmap |
[in] | pos | Bit to set |
Definition at line 58 of file bitmap.c.
References BITMAP_SET.
int bitmap_unset | ( | bitmap_t * | bm, |
const int | nbits, | ||
const int | pos | ||
) |
Unset a bit
[in] | bm | Bitmap |
[in] | nbits | Size of bitmap in bits |
[in] | pos | Bit to clear |
Definition at line 66 of file bitmap.c.
References BITMAP_UNSET.