6
* Bitmaps for multicast downloads
10
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
16
/** A single block of bits within a bitmap */
17
typedef unsigned long bitmap_block_t;
19
/** Size of a block of bits (in bits) */
20
#define BITMAP_BLKSIZE ( sizeof ( bitmap_block_t ) * 8 )
23
* Block index within bitmap
26
* @ret index Block index
28
#define BITMAP_INDEX( bit ) ( (bit) / BITMAP_BLKSIZE )
31
* Block mask within bitmap
34
* @ret mask Block mask
36
#define BITMAP_MASK( bit ) ( 1UL << ( (bit) % BITMAP_BLKSIZE ) )
41
bitmap_block_t *blocks;
42
/** Length of the bitmap, in bits */
44
/** Index of first gap in the bitmap */
45
unsigned int first_gap;
48
extern int bitmap_resize ( struct bitmap *bitmap, unsigned int new_length );
49
extern int bitmap_test ( struct bitmap *bitmap, unsigned int bit );
50
extern void bitmap_set ( struct bitmap *bitmap, unsigned int bit );
53
* Free bitmap resources
57
static inline void bitmap_free ( struct bitmap *bitmap ) {
58
free ( bitmap->blocks );
62
* Get first gap within bitmap
65
* @ret first_gap First gap
67
* The first gap is the first unset bit within the bitmap.
69
static inline unsigned int bitmap_first_gap ( struct bitmap *bitmap ) {
70
return bitmap->first_gap;
74
* Check to see if bitmap is full
77
* @ret is_full Bitmap is full
79
* The bitmap is full if it has no gaps (i.e. no unset bits).
81
static inline int bitmap_full ( struct bitmap *bitmap ) {
82
return ( bitmap->first_gap == bitmap->length );
85
#endif /* _IPXE_BITMAP_H */