Changes in kernel/generic/include/adt/bitmap.h [7de18418:f72906c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/bitmap.h
r7de18418 rf72906c 44 44 size_t elements; 45 45 uint8_t *bits; 46 47 size_t block_size; 48 uint8_t *blocks; 46 size_t next_fit; 49 47 } bitmap_t; 50 48 … … 52 50 unsigned int value) 53 51 { 54 if (element < bitmap->elements) { 55 /* 56 * The 2nd level bitmap is conservative. 57 * Make sure we update it properly. 58 */ 59 60 if (value) { 61 bitmap->bits[element / BITMAP_ELEMENT] |= 62 (1 << (element & BITMAP_REMAINER)); 63 } else { 64 bitmap->bits[element / BITMAP_ELEMENT] &= 65 ~(1 << (element & BITMAP_REMAINER)); 66 67 if (bitmap->block_size > 0) { 68 size_t block = element / bitmap->block_size; 69 70 bitmap->blocks[block / BITMAP_ELEMENT] &= 71 ~(1 << (block & BITMAP_REMAINER)); 72 } 73 } 52 if (element >= bitmap->elements) 53 return; 54 55 size_t byte = element / BITMAP_ELEMENT; 56 uint8_t mask = 1 << (element & BITMAP_REMAINER); 57 58 if (value) { 59 bitmap->bits[byte] |= mask; 60 } else { 61 bitmap->bits[byte] &= ~mask; 62 bitmap->next_fit = byte; 74 63 } 75 64 } … … 80 69 return 0; 81 70 82 return !!((bitmap->bits)[element / BITMAP_ELEMENT] & 83 (1 << (element & BITMAP_REMAINER))); 71 size_t byte = element / BITMAP_ELEMENT; 72 uint8_t mask = 1 << (element & BITMAP_REMAINER); 73 74 return !!((bitmap->bits)[byte] & mask); 84 75 } 85 76 86 extern size_t bitmap_size(size_t , size_t);87 extern void bitmap_initialize(bitmap_t *, size_t, size_t,void *);77 extern size_t bitmap_size(size_t); 78 extern void bitmap_initialize(bitmap_t *, size_t, void *); 88 79 89 80 extern void bitmap_set_range(bitmap_t *, size_t, size_t); 90 81 extern void bitmap_clear_range(bitmap_t *, size_t, size_t); 91 82 92 extern int bitmap_find_range(bitmap_t *, size_t, size_t, size_t); 93 extern int bitmap_allocate_range(bitmap_t *, size_t, size_t, size_t, size_t *); 94 extern void bitmap_free_range(bitmap_t *, size_t, size_t); 83 extern int bitmap_allocate_range(bitmap_t *, size_t, size_t, size_t, size_t, 84 size_t *); 95 85 extern void bitmap_copy(bitmap_t *, bitmap_t *, size_t); 96 86
Note:
See TracChangeset
for help on using the changeset viewer.