libisdn
|
Go to the source code of this file.
Defines | |
#define | BITS_PER_LONG 64 |
#define | BITMAP_SIZE(x) (((x) + 63) >> 6) |
#define | BITMAP_SIZE_BYTES(x) (BITMAP_SIZE(x) << 3) |
#define | BITMAP_BIT(x) ((x) & 0x3f) |
#define | BITMAP_OFFSET(x) ((x) >> 6) |
#define | DECLARE_BITMAP(_name, _nbits) bitmap_t _name[BITMAP_SIZE(_nbits)] |
Typedefs | |
typedef unsigned long | bitmap_t |
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_first_bit (const bitmap_t *bm, const int nbits) |
int | bitmap_next_bit (const bitmap_t *bm, const int nbits, const int last) |
int | bitmap_count (const bitmap_t *bm, const int nbits) |
#define BITMAP_BIT | ( | x | ) | ((x) & 0x3f) |
Definition at line 21 of file bitmap.h.
Referenced by bitmap_next_bit().
#define BITMAP_OFFSET | ( | x | ) | ((x) >> 6) |
Definition at line 22 of file bitmap.h.
Referenced by bitmap_next_bit().
#define BITMAP_SIZE | ( | x | ) | (((x) + 63) >> 6) |
Definition at line 19 of file bitmap.h.
Referenced by bitmap_dump().
#define BITMAP_SIZE_BYTES | ( | x | ) | (BITMAP_SIZE(x) << 3) |
Definition at line 20 of file bitmap.h.
Referenced by bitmap_clear(), bitmap_create(), bitmap_init(), and bitmap_is_empty().
#define BITS_PER_LONG 64 |
Definition at line 18 of file bitmap.h.
Referenced by bitmap_next_bit().
#define DECLARE_BITMAP | ( | _name, | |
_nbits | |||
) | bitmap_t _name[BITMAP_SIZE(_nbits)] |
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_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.