Rev 4055 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4055 | Rev 4537 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | 39 | ||
40 | #define BITS2BYTES(bits) (bits ? ((((bits)-1)>>3)+1) : 0) |
40 | #define BITS2BYTES(bits) (bits ? ((((bits)-1)>>3)+1) : 0) |
41 | 41 | ||
42 | typedef struct { |
42 | typedef struct { |
43 | uint8_t *map; |
43 | uint8_t *map; |
44 | count_t bits; |
44 | size_t bits; |
45 | } bitmap_t; |
45 | } bitmap_t; |
46 | 46 | ||
47 | extern void bitmap_initialize(bitmap_t *bitmap, uint8_t *map, count_t bits); |
47 | extern void bitmap_initialize(bitmap_t *bitmap, uint8_t *map, size_t bits); |
48 | extern void bitmap_set_range(bitmap_t *bitmap, index_t start, count_t bits); |
48 | extern void bitmap_set_range(bitmap_t *bitmap, size_t start, size_t bits); |
49 | extern void bitmap_clear_range(bitmap_t *bitmap, index_t start, count_t bits); |
49 | extern void bitmap_clear_range(bitmap_t *bitmap, size_t start, size_t bits); |
50 | extern void bitmap_copy(bitmap_t *dst, bitmap_t *src, count_t bits); |
50 | extern void bitmap_copy(bitmap_t *dst, bitmap_t *src, size_t bits); |
51 | 51 | ||
52 | static inline int bitmap_get(bitmap_t *bitmap,index_t bit) |
52 | static inline int bitmap_get(bitmap_t *bitmap, size_t bit) |
53 | { |
53 | { |
54 | if(bit >= bitmap->bits) |
54 | if(bit >= bitmap->bits) |
55 | return 0; |
55 | return 0; |
- | 56 | ||
56 | return !! ((bitmap->map)[bit/8] & (1 << (bit & 7))); |
57 | return !! ((bitmap->map)[bit/8] & (1 << (bit & 7))); |
57 | } |
58 | } |
58 | 59 | ||
59 | 60 | ||
60 | #endif |
61 | #endif |