Changes in kernel/generic/include/adt/bitmap.h [f72906c:86733f3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/bitmap.h
rf72906c r86733f3 44 44 size_t elements; 45 45 uint8_t *bits; 46 size_t next_fit; 46 47 size_t block_size; 48 uint8_t *blocks; 47 49 } bitmap_t; 48 50 … … 50 52 unsigned int value) 51 53 { 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; 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 } 63 74 } 64 75 } … … 69 80 return 0; 70 81 71 size_t byte = element / BITMAP_ELEMENT; 72 uint8_t mask = 1 << (element & BITMAP_REMAINER); 73 74 return !!((bitmap->bits)[byte] & mask); 82 return !!((bitmap->bits)[element / BITMAP_ELEMENT] & 83 (1 << (element & BITMAP_REMAINER))); 75 84 } 76 85 77 extern size_t bitmap_size(size_t );78 extern void bitmap_initialize(bitmap_t *, size_t, void *);86 extern size_t bitmap_size(size_t, size_t); 87 extern void bitmap_initialize(bitmap_t *, size_t, size_t, void *); 79 88 80 89 extern void bitmap_set_range(bitmap_t *, size_t, size_t); 81 90 extern void bitmap_clear_range(bitmap_t *, size_t, size_t); 82 91 83 extern int bitmap_allocate_range(bitmap_t *, size_t, size_t, size_t, size_t ,84 size_t *);92 extern int bitmap_allocate_range(bitmap_t *, size_t, size_t, size_t, size_t *); 93 extern void bitmap_free_range(bitmap_t *, size_t, size_t); 85 94 extern void bitmap_copy(bitmap_t *, bitmap_t *, size_t); 86 95
Note:
See TracChangeset
for help on using the changeset viewer.