Lines Matching +full:8 +full:bit

16 #define BIT_INDEX(bit)  ((3 - ((bit >> 3) & 0x3)) + 4*(bit >> 5))  argument
18 #define BIT_INDEX(bit) (bit >> 3) argument
20 #define BIT_VAL(bit) (1 << (bit & 0x7)) argument
57 num_bundles = ROUND_UP(ROUND_UP(num_bits, 8) / 8, sizeof(uint32_t)) in validate_bitarray_define()
131 size_t bit, bundle_idx, bit_idx_in_bundle; in test_bitarray_set_clear() local
140 for (bit = 0U; bit < ba.num_bits; ++bit) { in test_bitarray_set_clear()
141 bundle_idx = bit / (sizeof(ba.bundles[0]) * 8); in test_bitarray_set_clear()
142 bit_idx_in_bundle = bit % (sizeof(ba.bundles[0]) * 8); in test_bitarray_set_clear()
144 ret = sys_bitarray_set_bit(&ba, bit); in test_bitarray_set_clear()
146 "sys_bitarray_set_bit failed on bit %d", bit); in test_bitarray_set_clear()
147 zassert_equal(ba.bundles[bundle_idx], BIT(bit_idx_in_bundle), in test_bitarray_set_clear()
148 "sys_bitarray_set_bit did not set bit %d\n", bit); in test_bitarray_set_clear()
149 zassert_not_equal(sys_bitfield_test_bit((mem_addr_t)ba.bundles, bit), in test_bitarray_set_clear()
150 0, "sys_bitarray_set_bit did not set bit %d\n", bit); in test_bitarray_set_clear()
152 ret = sys_bitarray_test_bit(&ba, bit, &bit_val); in test_bitarray_set_clear()
154 "sys_bitarray_test_bit failed at bit %d", bit); in test_bitarray_set_clear()
156 "sys_bitarray_test_bit did not detect bit %d\n", bit); in test_bitarray_set_clear()
158 ret = sys_bitarray_clear_bit(&ba, bit); in test_bitarray_set_clear()
160 "sys_bitarray_clear_bit failed at bit %d", bit); in test_bitarray_set_clear()
162 "sys_bitarray_clear_bit did not clear bit %d\n", bit); in test_bitarray_set_clear()
163 zassert_equal(sys_bitfield_test_bit((mem_addr_t)ba.bundles, bit), in test_bitarray_set_clear()
164 0, "sys_bitarray_set_bit did not set bit %d\n", bit); in test_bitarray_set_clear()
166 ret = sys_bitarray_test_bit(&ba, bit, &bit_val); in test_bitarray_set_clear()
168 "sys_bitarray_test_bit failed at bit %d", bit); in test_bitarray_set_clear()
170 "sys_bitarray_test_bit erroneously detected bit %d\n", in test_bitarray_set_clear()
171 bit); in test_bitarray_set_clear()
173 ret = sys_bitarray_test_and_set_bit(&ba, bit, &bit_val); in test_bitarray_set_clear()
175 "sys_bitarray_test_and_set_bit failed at bit %d", bit); in test_bitarray_set_clear()
177 "sys_bitarray_test_and_set_bit erroneously detected bit %d\n", in test_bitarray_set_clear()
178 bit); in test_bitarray_set_clear()
179 zassert_equal(ba.bundles[bundle_idx], BIT(bit_idx_in_bundle), in test_bitarray_set_clear()
180 "sys_bitarray_test_and_set_bit did not set bit %d\n", bit); in test_bitarray_set_clear()
181 zassert_not_equal(sys_bitfield_test_bit((mem_addr_t)ba.bundles, bit), in test_bitarray_set_clear()
182 0, "sys_bitarray_set_bit did not set bit %d\n", bit); in test_bitarray_set_clear()
184 ret = sys_bitarray_test_and_set_bit(&ba, bit, &bit_val); in test_bitarray_set_clear()
186 "sys_bitarray_test_and_set_bit failed at bit %d", bit); in test_bitarray_set_clear()
188 "sys_bitarray_test_and_set_bit did not detect bit %d\n", in test_bitarray_set_clear()
189 bit); in test_bitarray_set_clear()
190 zassert_equal(ba.bundles[bundle_idx], BIT(bit_idx_in_bundle), in test_bitarray_set_clear()
191 "sys_bitarray_test_and_set_bit cleared bit %d\n", bit); in test_bitarray_set_clear()
192 zassert_not_equal(sys_bitfield_test_bit((mem_addr_t)ba.bundles, bit), in test_bitarray_set_clear()
193 0, "sys_bitarray_set_bit did not set bit %d\n", bit); in test_bitarray_set_clear()
195 ret = sys_bitarray_test_and_clear_bit(&ba, bit, &bit_val); in test_bitarray_set_clear()
197 "sys_bitarray_test_and_clear_bit failed at bit %d", bit); in test_bitarray_set_clear()
199 "sys_bitarray_test_and_clear_bit did not detect bit %d\n", in test_bitarray_set_clear()
200 bit); in test_bitarray_set_clear()
202 "sys_bitarray_test_and_clear_bit did not clear bit %d\n", in test_bitarray_set_clear()
203 bit); in test_bitarray_set_clear()
204 zassert_equal(sys_bitfield_test_bit((mem_addr_t)ba.bundles, bit), in test_bitarray_set_clear()
205 0, "sys_bitarray_set_bit did not set bit %d\n", bit); in test_bitarray_set_clear()
207 ret = sys_bitarray_test_and_clear_bit(&ba, bit, &bit_val); in test_bitarray_set_clear()
209 "sys_bitarray_test_and_clear_bit failed at bit %d", bit); in test_bitarray_set_clear()
211 "sys_bitarray_test_and_clear_bit erroneously detected bit %d\n", in test_bitarray_set_clear()
212 bit); in test_bitarray_set_clear()
214 "sys_bitarray_test_and_clear_bit set bit %d\n", in test_bitarray_set_clear()
215 bit); in test_bitarray_set_clear()
216 zassert_equal(sys_bitfield_test_bit((mem_addr_t)ba.bundles, bit), in test_bitarray_set_clear()
217 0, "sys_bitarray_set_bit did not set bit %d\n", bit); in test_bitarray_set_clear()
221 * total bits in bit array. Also needs to make sure bits in test_bitarray_set_clear()
288 printk("Testing bit array alloc and free with predefined patterns\n"); in alloc_and_free_predefined()
372 size_t bit; in alloc_and_free_loop() local
379 printk("Testing bit array alloc and free with divisor %d\n", divisor); in alloc_and_free_loop()
381 for (bit = 0U; bit < ba.num_bits; ++bit) { in alloc_and_free_loop()
384 "bit count expeceted %u, got %u (at bit %u)", in alloc_and_free_loop()
385 expected_popcnt, cur_popcnt, bit); in alloc_and_free_loop()
388 num_bits = (ba.num_bits - bit) / divisor; in alloc_and_free_loop()
393 "sys_bitarray_free() should fail but not (bit %u)", in alloc_and_free_loop()
394 bit); in alloc_and_free_loop()
397 "sys_bitarray_alloc() failed (%d) at bit %u", in alloc_and_free_loop()
398 ret, bit); in alloc_and_free_loop()
399 zassert_equal(offset, bit, in alloc_and_free_loop()
401 bit, offset); in alloc_and_free_loop()
408 "bit count expeceted %u, got %u (at bit %u)", in alloc_and_free_loop()
409 expected_popcnt, cur_popcnt, bit); in alloc_and_free_loop()
411 /* Free all but the first bit of allocated region */ in alloc_and_free_loop()
412 ret = sys_bitarray_free(&ba, (num_bits - 1), (bit + 1)); in alloc_and_free_loop()
415 "sys_bitarray_free() should fail but not (bit %u)", in alloc_and_free_loop()
416 bit); in alloc_and_free_loop()
419 "sys_bitarray_free() failed (%d) at bit %u", in alloc_and_free_loop()
420 ret, (bit + 1)); in alloc_and_free_loop()
435 /* Make sure number of bits is multiple of 8 */ in alloc_and_free_interval()
438 printk("Testing bit array interval alloc and free\n"); in alloc_and_free_interval()
440 /* Pre-populate the bits so that 4-bit already allocated, in alloc_and_free_interval()
449 for (cnt = 0; cnt <= (ba.num_bits / 8); cnt++) { in alloc_and_free_interval()
452 if (cnt == (ba.num_bits / 8)) { in alloc_and_free_interval()
469 "bit count expeceted %u, got %u (cnt %u)", in alloc_and_free_interval()
473 expected_offset += 8; in alloc_and_free_interval()
518 printk("Testing bit array region bit tests\n"); in test_bitarray_region_set_clear()
526 zassert_true(sys_bitarray_is_region_set(&ba, 8, 32), NULL); in test_bitarray_region_set_clear()
532 zassert_false(sys_bitarray_is_region_cleared(&ba, 8, 32), NULL); in test_bitarray_region_set_clear()
541 zassert_true(sys_bitarray_is_region_cleared(&ba, 8, 32), NULL); in test_bitarray_region_set_clear()
547 zassert_false(sys_bitarray_is_region_set(&ba, 8, 32), NULL); in test_bitarray_region_set_clear()
553 zassert_false(sys_bitarray_is_region_set(&ba, 8, 120), NULL); in test_bitarray_region_set_clear()
554 zassert_false(sys_bitarray_is_region_cleared(&ba, 8, 120), NULL); in test_bitarray_region_set_clear()
556 printk("Testing bit array region bit manipulations\n"); in test_bitarray_region_set_clear()
602 ret = sys_bitarray_set_region(&ba, 8, 120); in test_bitarray_region_set_clear()
612 ret = sys_bitarray_clear_region(&ba, 8, 120); in test_bitarray_region_set_clear()
622 * bit and least significiant bit work as expected.
629 unsigned int bit; in test_ffs() local
661 /* equivalent class testing, each bit means a class */ in test_ffs()
662 for (bit = 0; bit < 32 ; bit++) { in test_ffs()
663 value = 1UL << bit; in test_ffs()
664 zassert_equal(find_msb_set(value), bit + 1, "MSB is not matched"); in test_ffs()
665 zassert_equal(find_lsb_set(value), bit + 1, "LSB is not matched"); in test_ffs()