Changeset 4fd61ba in mainline
- Timestamp:
- 2006-04-30T19:08:14Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ea199e5
- Parents:
- 0e00b8a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/adt/bitmap.c
r0e00b8a r4fd61ba 40 40 #include <align.h> 41 41 #include <debug.h> 42 #include <macros.h> 42 43 43 44 #define ALL_ONES 0xff … … 69 70 index_t aligned_start; 70 71 count_t lub; /* leading unaligned bits */ 71 count_t tub; /* trailing unaligned bits */ 72 count_t amb; /* aligned middle bits */ 73 count_t tab; /* trailing aligned bits */ 72 74 73 75 ASSERT(start + bits <= bitmap->bits); 74 76 75 77 aligned_start = ALIGN_UP(start, 8); 76 lub = aligned_start - start; 77 tub = (bits - lub) % 8; 78 lub = min(aligned_start - start, bits); 79 amb = bits > lub ? bits - lub : 0; 80 tab = amb % 8; 78 81 79 82 if (lub) { … … 83 86 bitmap->map[start / 8] |= ~((1 << (8 - lub)) - 1); 84 87 } 85 for (i = 0; i < (bits - lub)/ 8; i++) {88 for (i = 0; i < amb / 8; i++) { 86 89 /* 87 90 * The middle bits can be set byte by byte. … … 89 92 bitmap->map[aligned_start / 8 + i] = ALL_ONES; 90 93 } 91 if (t ub) {94 if (tab) { 92 95 /* 93 * Make sure to set any trailing unaligned bits.96 * Make sure to set any trailing aligned bits. 94 97 */ 95 bitmap->map[aligned_start / 8 + i] |= (1 << t ub) - 1;98 bitmap->map[aligned_start / 8 + i] |= (1 << tab) - 1; 96 99 } 97 100 … … 109 112 index_t aligned_start; 110 113 count_t lub; /* leading unaligned bits */ 111 count_t tub; /* trailing unaligned bits */ 114 count_t amb; /* aligned middle bits */ 115 count_t tab; /* trailing aligned bits */ 112 116 113 117 ASSERT(start + bits <= bitmap->bits); 114 118 115 119 aligned_start = ALIGN_UP(start, 8); 116 lub = aligned_start - start; 117 tub = (bits - lub) % 8; 118 120 lub = min(aligned_start - start, bits); 121 amb = bits > lub ? bits - lub : 0; 122 tab = amb % 8; 123 119 124 if (lub) { 120 125 /* … … 123 128 bitmap->map[start / 8] &= (1 << (8 - lub)) - 1; 124 129 } 125 for (i = 0; i < (bits - lub)/ 8; i++) {130 for (i = 0; i < amb / 8; i++) { 126 131 /* 127 132 * The middle bits can be cleared byte by byte. … … 129 134 bitmap->map[aligned_start / 8 + i] = ALL_ZEROES; 130 135 } 131 if (t ub) {136 if (tab) { 132 137 /* 133 * Make sure to clear any trailing unaligned bits.138 * Make sure to clear any trailing aligned bits. 134 139 */ 135 bitmap->map[aligned_start / 8 + i] &= ~((1 << t ub) - 1);140 bitmap->map[aligned_start / 8 + i] &= ~((1 << tab) - 1); 136 141 } 137 142 138 143 } 139 144
Note:
See TracChangeset
for help on using the changeset viewer.