1Testing with TEST_LENGTH = 32 2 3test _bit_byte, _bit_mask, and bitstr_size 4 i _bit_byte(i) _bit_mask(i) bitstr_size(i) 5 0 0 1 0 6 1 0 2 1 7 2 0 4 1 8 3 0 8 1 9 4 0 16 1 10 5 0 32 1 11 6 0 64 1 12 7 0 128 1 13 8 1 1 1 14 9 1 2 2 15 10 1 4 2 16 11 1 8 2 17 12 1 16 2 18 13 1 32 2 19 14 1 64 2 20 15 1 128 2 21 16 2 1 2 22 17 2 2 3 23 18 2 4 3 24 19 2 8 3 25 20 2 16 3 26 21 2 32 3 27 22 2 64 3 28 23 2 128 3 29 24 3 1 3 30 25 3 2 4 31 26 3 4 4 32 27 3 8 4 33 28 3 16 4 34 29 3 32 4 35 30 3 64 4 36 31 3 128 4 37 38test bit_alloc, clearbits, bit_ffc, bit_ffs 39be: 0 -1 00000000000000000000000000000000 40is: 0 -1 00000000000000000000000000000000 41 42test bit_set 43be: 1 0 10010010010010010010010010010010 44is: 1 0 10010010010010010010010010010010 45 46test bit_clear 47be: 0 3 00010000010000010000010000010000 48is: 0 3 00010000010000010000010000010000 49 50test bit_test using previous bitstring 51 i bit_test(i) 52 0 0 53 1 0 54 2 0 55 3 8 56 4 0 57 5 0 58 6 0 59 7 0 60 8 0 61 9 2 62 10 0 63 11 0 64 12 0 65 13 0 66 14 0 67 15 128 68 16 0 69 17 0 70 18 0 71 19 0 72 20 0 73 21 32 74 22 0 75 23 0 76 24 0 77 25 0 78 26 0 79 27 8 80 28 0 81 29 0 82 30 0 83 31 0 84 85test clearbits 86be: 0 -1 00000000000000000000000000000000 87is: 0 -1 00000000000000000000000000000000 88 89test bit_nset and bit_nclear 90be: 0 1 01111111111111111111111111111110 91is: 0 1 01111111111111111111111111111110 92be: 0 1 01000000000000000000000000000010 93is: 0 1 01000000000000000000000000000010 94be: 0 -1 00000000000000000000000000000000 95is: 0 -1 00000000000000000000000000000000 96be: 31 0 11111111111111111111111111111110 97is: 31 0 11111111111111111111111111111110 98be: 0 -1 00000000000000000000000000000000 99is: 0 -1 00000000000000000000000000000000 100 101first 1 bit should move right 1 position each line 102 0 -1 0 11111111111111111111111111111111 103 1 0 1 01111111111111111111111111111111 104 2 0 2 00111111111111111111111111111111 105 3 0 3 00011111111111111111111111111111 106 4 0 4 00001111111111111111111111111111 107 5 0 5 00000111111111111111111111111111 108 6 0 6 00000011111111111111111111111111 109 7 0 7 00000001111111111111111111111111 110 8 0 8 00000000111111111111111111111111 111 9 0 9 00000000011111111111111111111111 112 10 0 10 00000000001111111111111111111111 113 11 0 11 00000000000111111111111111111111 114 12 0 12 00000000000011111111111111111111 115 13 0 13 00000000000001111111111111111111 116 14 0 14 00000000000000111111111111111111 117 15 0 15 00000000000000011111111111111111 118 16 0 16 00000000000000001111111111111111 119 17 0 17 00000000000000000111111111111111 120 18 0 18 00000000000000000011111111111111 121 19 0 19 00000000000000000001111111111111 122 20 0 20 00000000000000000000111111111111 123 21 0 21 00000000000000000000011111111111 124 22 0 22 00000000000000000000001111111111 125 23 0 23 00000000000000000000000111111111 126 24 0 24 00000000000000000000000011111111 127 25 0 25 00000000000000000000000001111111 128 26 0 26 00000000000000000000000000111111 129 27 0 27 00000000000000000000000000011111 130 28 0 28 00000000000000000000000000001111 131 29 0 29 00000000000000000000000000000111 132 30 0 30 00000000000000000000000000000011 133 31 0 31 00000000000000000000000000000001 134 135first 0 bit should move right 1 position each line 136 0 0 -1 00000000000000000000000000000000 137 1 1 0 10000000000000000000000000000000 138 2 2 0 11000000000000000000000000000000 139 3 3 0 11100000000000000000000000000000 140 4 4 0 11110000000000000000000000000000 141 5 5 0 11111000000000000000000000000000 142 6 6 0 11111100000000000000000000000000 143 7 7 0 11111110000000000000000000000000 144 8 8 0 11111111000000000000000000000000 145 9 9 0 11111111100000000000000000000000 146 10 10 0 11111111110000000000000000000000 147 11 11 0 11111111111000000000000000000000 148 12 12 0 11111111111100000000000000000000 149 13 13 0 11111111111110000000000000000000 150 14 14 0 11111111111111000000000000000000 151 15 15 0 11111111111111100000000000000000 152 16 16 0 11111111111111110000000000000000 153 17 17 0 11111111111111111000000000000000 154 18 18 0 11111111111111111100000000000000 155 19 19 0 11111111111111111110000000000000 156 20 20 0 11111111111111111111000000000000 157 21 21 0 11111111111111111111100000000000 158 22 22 0 11111111111111111111110000000000 159 23 23 0 11111111111111111111111000000000 160 24 24 0 11111111111111111111111100000000 161 25 25 0 11111111111111111111111110000000 162 26 26 0 11111111111111111111111111000000 163 27 27 0 11111111111111111111111111100000 164 28 28 0 11111111111111111111111111110000 165 29 29 0 11111111111111111111111111111000 166 30 30 0 11111111111111111111111111111100 167 31 31 0 11111111111111111111111111111110 168 169first 0 bit should move left 1 position each line 170 0 -1 0 11111111111111111111111111111111 171 1 31 0 11111111111111111111111111111110 172 2 30 0 11111111111111111111111111111100 173 3 29 0 11111111111111111111111111111000 174 4 28 0 11111111111111111111111111110000 175 5 27 0 11111111111111111111111111100000 176 6 26 0 11111111111111111111111111000000 177 7 25 0 11111111111111111111111110000000 178 8 24 0 11111111111111111111111100000000 179 9 23 0 11111111111111111111111000000000 180 10 22 0 11111111111111111111110000000000 181 11 21 0 11111111111111111111100000000000 182 12 20 0 11111111111111111111000000000000 183 13 19 0 11111111111111111110000000000000 184 14 18 0 11111111111111111100000000000000 185 15 17 0 11111111111111111000000000000000 186 16 16 0 11111111111111110000000000000000 187 17 15 0 11111111111111100000000000000000 188 18 14 0 11111111111111000000000000000000 189 19 13 0 11111111111110000000000000000000 190 20 12 0 11111111111100000000000000000000 191 21 11 0 11111111111000000000000000000000 192 22 10 0 11111111110000000000000000000000 193 23 9 0 11111111100000000000000000000000 194 24 8 0 11111111000000000000000000000000 195 25 7 0 11111110000000000000000000000000 196 26 6 0 11111100000000000000000000000000 197 27 5 0 11111000000000000000000000000000 198 28 4 0 11110000000000000000000000000000 199 29 3 0 11100000000000000000000000000000 200 30 2 0 11000000000000000000000000000000 201 31 1 0 10000000000000000000000000000000 202 203first 1 bit should move left 1 position each line 204 0 0 -1 00000000000000000000000000000000 205 1 0 31 00000000000000000000000000000001 206 2 0 30 00000000000000000000000000000011 207 3 0 29 00000000000000000000000000000111 208 4 0 28 00000000000000000000000000001111 209 5 0 27 00000000000000000000000000011111 210 6 0 26 00000000000000000000000000111111 211 7 0 25 00000000000000000000000001111111 212 8 0 24 00000000000000000000000011111111 213 9 0 23 00000000000000000000000111111111 214 10 0 22 00000000000000000000001111111111 215 11 0 21 00000000000000000000011111111111 216 12 0 20 00000000000000000000111111111111 217 13 0 19 00000000000000000001111111111111 218 14 0 18 00000000000000000011111111111111 219 15 0 17 00000000000000000111111111111111 220 16 0 16 00000000000000001111111111111111 221 17 0 15 00000000000000011111111111111111 222 18 0 14 00000000000000111111111111111111 223 19 0 13 00000000000001111111111111111111 224 20 0 12 00000000000011111111111111111111 225 21 0 11 00000000000111111111111111111111 226 22 0 10 00000000001111111111111111111111 227 23 0 9 00000000011111111111111111111111 228 24 0 8 00000000111111111111111111111111 229 25 0 7 00000001111111111111111111111111 230 26 0 6 00000011111111111111111111111111 231 27 0 5 00000111111111111111111111111111 232 28 0 4 00001111111111111111111111111111 233 29 0 3 00011111111111111111111111111111 234 30 0 2 00111111111111111111111111111111 235 31 0 1 01111111111111111111111111111111 236 2370 bit should move right 1 position each line 238 0 0 1 01111111111111111111111111111111 239 1 1 0 10111111111111111111111111111111 240 2 2 0 11011111111111111111111111111111 241 3 3 0 11101111111111111111111111111111 242 4 4 0 11110111111111111111111111111111 243 5 5 0 11111011111111111111111111111111 244 6 6 0 11111101111111111111111111111111 245 7 7 0 11111110111111111111111111111111 246 8 8 0 11111111011111111111111111111111 247 9 9 0 11111111101111111111111111111111 248 10 10 0 11111111110111111111111111111111 249 11 11 0 11111111111011111111111111111111 250 12 12 0 11111111111101111111111111111111 251 13 13 0 11111111111110111111111111111111 252 14 14 0 11111111111111011111111111111111 253 15 15 0 11111111111111101111111111111111 254 16 16 0 11111111111111110111111111111111 255 17 17 0 11111111111111111011111111111111 256 18 18 0 11111111111111111101111111111111 257 19 19 0 11111111111111111110111111111111 258 20 20 0 11111111111111111111011111111111 259 21 21 0 11111111111111111111101111111111 260 22 22 0 11111111111111111111110111111111 261 23 23 0 11111111111111111111111011111111 262 24 24 0 11111111111111111111111101111111 263 25 25 0 11111111111111111111111110111111 264 26 26 0 11111111111111111111111111011111 265 27 27 0 11111111111111111111111111101111 266 28 28 0 11111111111111111111111111110111 267 29 29 0 11111111111111111111111111111011 268 30 30 0 11111111111111111111111111111101 269 31 31 0 11111111111111111111111111111110 270 2711 bit should move right 1 position each line 272 0 1 0 10000000000000000000000000000000 273 1 0 1 01000000000000000000000000000000 274 2 0 2 00100000000000000000000000000000 275 3 0 3 00010000000000000000000000000000 276 4 0 4 00001000000000000000000000000000 277 5 0 5 00000100000000000000000000000000 278 6 0 6 00000010000000000000000000000000 279 7 0 7 00000001000000000000000000000000 280 8 0 8 00000000100000000000000000000000 281 9 0 9 00000000010000000000000000000000 282 10 0 10 00000000001000000000000000000000 283 11 0 11 00000000000100000000000000000000 284 12 0 12 00000000000010000000000000000000 285 13 0 13 00000000000001000000000000000000 286 14 0 14 00000000000000100000000000000000 287 15 0 15 00000000000000010000000000000000 288 16 0 16 00000000000000001000000000000000 289 17 0 17 00000000000000000100000000000000 290 18 0 18 00000000000000000010000000000000 291 19 0 19 00000000000000000001000000000000 292 20 0 20 00000000000000000000100000000000 293 21 0 21 00000000000000000000010000000000 294 22 0 22 00000000000000000000001000000000 295 23 0 23 00000000000000000000000100000000 296 24 0 24 00000000000000000000000010000000 297 25 0 25 00000000000000000000000001000000 298 26 0 26 00000000000000000000000000100000 299 27 0 27 00000000000000000000000000010000 300 28 0 28 00000000000000000000000000001000 301 29 0 29 00000000000000000000000000000100 302 30 0 30 00000000000000000000000000000010 303 31 0 31 00000000000000000000000000000001 304