Lines Matching +full:0 +full:- +full:1023
1 // SPDX-License-Identifier: GPL-2.0-only
27 BITMAP_FROM_U64(0x0000ffff),
28 BITMAP_FROM_U64(0xffff0000),
29 BITMAP_FROM_U64(0x55555555),
30 BITMAP_FROM_U64(0xaaaaaaaa),
31 BITMAP_FROM_U64(0x11111111),
32 BITMAP_FROM_U64(0x22222222),
33 BITMAP_FROM_U64(0xffffffff),
34 BITMAP_FROM_U64(0xfffffffe),
35 BITMAP_FROM_U64(0x3333333311111111ULL),
36 BITMAP_FROM_U64(0xffffffff77777777ULL),
37 BITMAP_FROM_U64(0),
41 BITMAP_FROM_U64(0x3333333311111111ULL),
42 BITMAP_FROM_U64(0xffffffff77777777ULL),
47 BITMAP_FROM_U64(0x008000020020212eULL),
49 /* exp3_0_1 = (exp2[0] & ~exp2_to_exp3_mask) | (exp2[1] & exp2_to_exp3_mask) */
51 BITMAP_FROM_U64(0x33b3333311313137ULL),
53 /* exp3_1_0 = (exp2[1] & ~exp2_to_exp3_mask) | (exp2[0] & exp2_to_exp3_mask) */
55 BITMAP_FROM_U64(0xff7fffff77575751ULL),
137 pr_warn("[%s:%u] bit offset for clump out-of-bounds: expected less than %u, got %u\n", in __check_eq_clump8()
144 …("[%s:%u] bit offset for zero clump: expected nonzero clump, got bit offset %u with clump value 0", in __check_eq_clump8()
150 pr_warn("[%s:%u] expected clump value of 0x%lX, got clump value of 0x%lX", in __check_eq_clump8()
160 int result = 0; \
181 memset(bmap, 0xff, 128); in test_zero_clear()
183 expect_eq_pbl("0-22", bmap, 23); in test_zero_clear()
184 expect_eq_pbl("0-1023", bmap, 1024); in test_zero_clear()
186 /* single-word bitmaps */ in test_zero_clear()
187 bitmap_clear(bmap, 0, 9); in test_zero_clear()
188 expect_eq_pbl("9-1023", bmap, 1024); in test_zero_clear()
191 expect_eq_pbl("64-1023", bmap, 1024); in test_zero_clear()
195 expect_eq_pbl("64-78,98-1023", bmap, 1024); in test_zero_clear()
198 expect_eq_pbl("128-1023", bmap, 1024); in test_zero_clear()
210 memset(bmap, 0x00, 128); in test_fill_set()
215 /* single-word bitmaps */ in test_fill_set()
216 bitmap_set(bmap, 0, 9); in test_fill_set()
217 expect_eq_pbl("0-8", bmap, 1024); in test_fill_set()
220 expect_eq_pbl("0-63", bmap, 1024); in test_fill_set()
224 expect_eq_pbl("0-63,79-97", bmap, 1024); in test_fill_set()
227 expect_eq_pbl("0-127", bmap, 1024); in test_fill_set()
231 expect_eq_pbl("0-1023", bmap, 1024); in test_fill_set()
242 /* single-word bitmaps */ in test_copy()
243 bitmap_set(bmap1, 0, 19); in test_copy()
245 expect_eq_pbl("0-18", bmap2, 1024); in test_copy()
247 bitmap_set(bmap2, 0, 23); in test_copy()
249 expect_eq_pbl("0-18", bmap2, 1024); in test_copy()
251 /* multi-word bitmaps */ in test_copy()
252 bitmap_set(bmap1, 0, 109); in test_copy()
254 expect_eq_pbl("0-108", bmap2, 1024); in test_copy()
258 expect_eq_pbl("0-108", bmap2, 1024); in test_copy()
260 /* the following tests assume a 32- or 64-bit arch (even 128b in test_copy()
265 bitmap_copy(bmap2, bmap1, 109); /* ... but 0-padded til word length */ in test_copy()
266 expect_eq_pbl("0-108,128-1023", bmap2, 1024); in test_copy()
270 expect_eq_pbl("0-108,128-1023", bmap2, 1024); in test_copy()
284 bitmap_replace(bmap, &exp2[0 * nlongs], &exp2[1 * nlongs], exp2_to_exp3_mask, nbits); in test_replace()
288 bitmap_replace(bmap, &exp2[1 * nlongs], &exp2[0 * nlongs], exp2_to_exp3_mask, nbits); in test_replace()
292 bitmap_replace(bmap, &exp2[0 * nlongs], &exp2[1 * nlongs], exp2_to_exp3_mask, nbits); in test_replace()
296 bitmap_replace(bmap, &exp2[1 * nlongs], &exp2[0 * nlongs], exp2_to_exp3_mask, nbits); in test_replace()
300 #define PARSE_TIME 0x1
301 #define NO_LEN 0x2
314 {0, "0", &exp1[0], 8, 0},
315 {0, "1", &exp1[1 * step], 8, 0},
316 {0, "0-15", &exp1[2 * step], 32, 0},
317 {0, "16-31", &exp1[3 * step], 32, 0},
318 {0, "0-31:1/2", &exp1[4 * step], 32, 0},
319 {0, "1-31:1/2", &exp1[5 * step], 32, 0},
320 {0, "0-31:1/4", &exp1[6 * step], 32, 0},
321 {0, "1-31:1/4", &exp1[7 * step], 32, 0},
322 {0, "0-31:4/4", &exp1[8 * step], 32, 0},
323 {0, "1-31:4/4", &exp1[9 * step], 32, 0},
324 {0, "0-31:1/4,32-63:2/4", &exp1[10 * step], 64, 0},
325 {0, "0-31:3/4,32-63:4/4", &exp1[11 * step], 64, 0},
326 {0, " ,, 0-31:3/4 ,, 32-63:4/4 ,, ", &exp1[11 * step], 64, 0},
328 {0, "0-31:1/4,32-63:2/4,64-95:3/4,96-127:4/4", exp2, 128, 0},
330 {0, "0-2047:128/256", NULL, 2048, PARSE_TIME},
332 {0, "", &exp1[12 * step], 8, 0},
333 {0, "\n", &exp1[12 * step], 8, 0},
334 {0, ",, ,, , , ,", &exp1[12 * step], 8, 0},
335 {0, " , ,, , , ", &exp1[12 * step], 8, 0},
336 {0, " , ,, , , \n", &exp1[12 * step], 8, 0},
338 {-EINVAL, "-1", NULL, 8, 0},
339 {-EINVAL, "-0", NULL, 8, 0},
340 {-EINVAL, "10-1", NULL, 8, 0},
341 {-EINVAL, "0-31:", NULL, 8, 0},
342 {-EINVAL, "0-31:0", NULL, 8, 0},
343 {-EINVAL, "0-31:0/", NULL, 8, 0},
344 {-EINVAL, "0-31:0/0", NULL, 8, 0},
345 {-EINVAL, "0-31:1/0", NULL, 8, 0},
346 {-EINVAL, "0-31:10/1", NULL, 8, 0},
347 {-EOVERFLOW, "0-98765432123456789:10/1", NULL, 8, 0},
349 {-EINVAL, "a-31", NULL, 8, 0},
350 {-EINVAL, "0-a1", NULL, 8, 0},
351 {-EINVAL, "a-31:10/1", NULL, 8, 0},
352 {-EINVAL, "0-31:a/1", NULL, 8, 0},
353 {-EINVAL, "0-\n", NULL, 8, 0},
364 for (i = 0; i < ARRAY_SIZE(parselist_tests); i++) { in test_bitmap_parselist()
369 time = ktime_get() - time; in test_bitmap_parselist()
379 pr_err("parselist: %d: input is %s, result is 0x%lx, expected 0x%lx\n", in test_bitmap_parselist()
380 i, ptest.in, bmap[0], in test_bitmap_parselist()
394 BITMAP_FROM_U64(0),
396 BITMAP_FROM_U64(0xdeadbeef),
397 BITMAP_FROM_U64(0x100000000ULL),
401 BITMAP_FROM_U64(0x100000000ULL), BITMAP_FROM_U64(0xdeadbeef),
402 BITMAP_FROM_U64(0x100000000ULL), BITMAP_FROM_U64(0xbaadf00ddeadbeef),
403 BITMAP_FROM_U64(0x100000000ULL), BITMAP_FROM_U64(0x0badf00ddeadbeef),
407 {0, "", &parse_test[0 * step], 32, 0},
408 {0, " ", &parse_test[0 * step], 32, 0},
409 {0, "0", &parse_test[0 * step], 32, 0},
410 {0, "0\n", &parse_test[0 * step], 32, 0},
411 {0, "1", &parse_test[1 * step], 32, 0},
412 {0, "deadbeef", &parse_test[2 * step], 32, 0},
413 {0, "1,0", &parse_test[3 * step], 33, 0},
414 {0, "deadbeef,\n,0,1", &parse_test[2 * step], 96, 0},
416 {0, "deadbeef,1,0", &parse_test2[0 * 2 * step], 96, 0},
417 {0, "baadf00d,deadbeef,1,0", &parse_test2[1 * 2 * step], 128, 0},
418 {0, "badf00d,deadbeef,1,0", &parse_test2[2 * 2 * step], 124, 0},
419 {0, "badf00d,deadbeef,1,0", &parse_test2[2 * 2 * step], 124, NO_LEN},
420 {0, " badf00d,deadbeef,1,0 ", &parse_test2[2 * 2 * step], 124, 0},
421 {0, " , badf00d,deadbeef,1,0 , ", &parse_test2[2 * 2 * step], 124, 0},
422 {0, " , badf00d, ,, ,,deadbeef,1,0 , ", &parse_test2[2 * 2 * step], 124, 0},
424 {-EINVAL, "goodfood,deadbeef,1,0", NULL, 128, 0},
425 {-EOVERFLOW, "3,0", NULL, 33, 0},
426 {-EOVERFLOW, "123badf00d,deadbeef,1,0", NULL, 128, 0},
427 {-EOVERFLOW, "badf00d,deadbeef,1,0", NULL, 90, 0},
428 {-EOVERFLOW, "fbadf00d,deadbeef,1,0", NULL, 95, 0},
429 {-EOVERFLOW, "badf00d,deadbeef,1,0", NULL, 100, 0},
440 for (i = 0; i < ARRAY_SIZE(parse_tests); i++) { in test_bitmap_parse()
446 time = ktime_get() - time; in test_bitmap_parse()
456 pr_err("parse: %d: input is %s, result is 0x%lx, expected 0x%lx\n", in test_bitmap_parse()
457 i, test.in, bmap[0], in test_bitmap_parse()
476 memset(arr, 0xa5, sizeof(arr)); in test_bitmap_arr32()
478 for (nbits = 0; nbits < EXP1_IN_BITS; ++nbits) { in test_bitmap_arr32()
490 if (nbits < EXP1_IN_BITS - 32) in test_bitmap_arr32()
492 0xa5a5a5a5); in test_bitmap_arr32()
502 for (start = 0; start < 1024; start += 8) { in test_mem_optimisations()
503 for (nbits = 0; nbits < 1024 - start; nbits += 8) { in test_mem_optimisations()
504 memset(bmap1, 0x5a, sizeof(bmap1)); in test_mem_optimisations()
505 memset(bmap2, 0x5a, sizeof(bmap2)); in test_mem_optimisations()
534 0x01, /* 1 bit set */
535 0x02, /* non-edge 1 bit set */
536 0x00, /* zero bits set */
537 0x38, /* 3 bits set across 4-bit boundary */
538 0x38, /* Repeated clump */
539 0x0F, /* 4 bits set */
540 0xFF, /* all bits set */
541 0x05, /* non-adjacent 2 bits set */
553 bitmap_set(bits, 0, 1); /* 0x01 */ in test_for_each_set_clump8()
554 bitmap_set(bits, 9, 1); /* 0x02 */ in test_for_each_set_clump8()
555 bitmap_set(bits, 27, 3); /* 0x28 */ in test_for_each_set_clump8()
556 bitmap_set(bits, 35, 3); /* 0x28 */ in test_for_each_set_clump8()
557 bitmap_set(bits, 40, 4); /* 0x0F */ in test_for_each_set_clump8()
558 bitmap_set(bits, 48, 8); /* 0xFF */ in test_for_each_set_clump8()
559 bitmap_set(bits, 56, 1); /* 0x05 - part 1 */ in test_for_each_set_clump8()
560 bitmap_set(bits, 58, 1); /* 0x05 - part 2 */ in test_for_each_set_clump8()
575 { 0, 0, 8, { 0x0000000aUL, }, { 0x0000000aUL, }, },
576 { 0, 0, 32, { 0xdadadeadUL, }, { 0xdadadeadUL, }, },
577 { 0, 3, 8, { 0x000000aaUL, }, { 0x00000015UL, }, },
578 { 3, 3, 8, { 0x000000aaUL, }, { 0x00000012UL, }, },
579 { 0, 1, 32, { 0xa5a5a5a5UL, }, { 0x52d2d2d2UL, }, },
580 { 0, 8, 32, { 0xdeadc0deUL, }, { 0x00deadc0UL, }, },
581 { 1, 1, 32, { 0x5a5a5a5aUL, }, { 0x2d2d2d2cUL, }, },
582 { 0, 15, 32, { 0xa5a5a5a5UL, }, { 0x00014b4bUL, }, },
583 { 0, 16, 32, { 0xa5a5a5a5UL, }, { 0x0000a5a5UL, }, },
584 { 15, 15, 32, { 0xa5a5a5a5UL, }, { 0x000125a5UL, }, },
585 { 15, 16, 32, { 0xa5a5a5a5UL, }, { 0x0000a5a5UL, }, },
586 { 16, 15, 32, { 0xa5a5a5a5UL, }, { 0x0001a5a5UL, }, },
589 { 0xa5a5a5a5UL, 0xa5a5a5a5UL, },
590 { 0xa5a5a5a5UL, 0xa5a5a5a5UL, },
592 { 1, BITS_PER_LONG - 1, BITS_PER_LONG,
593 { 0xa5a5a5a5UL, 0xa5a5a5a5UL, },
594 { 0x00000001UL, 0x00000001UL, },
597 { 0, BITS_PER_LONG * 2, BITS_PER_LONG * 2 + 1,
598 { 0xa5a5a5a5UL, 0x00000001UL, 0x00000001UL, 0x00000001UL },
599 { 0x00000001UL, },
602 { 0x0000ffffUL, 0x5a5a5a5aUL, 0x5a5a5a5aUL, 0x5a5a5a5aUL },
603 { 0x2d2dffffUL, },
609 unsigned long b[5], *in = &b[1], *out = &b[0]; /* Partial overlap */ in test_bitmap_cut()
612 for (i = 0; i < ARRAY_SIZE(test_cut); i++) { in test_bitmap_cut()
615 memcpy(in, t->in, sizeof(t->in)); in test_bitmap_cut()
617 bitmap_cut(out, in, t->first, t->cut, t->nbits); in test_bitmap_cut()
619 expect_eq_bitmap(t->expected, out, t->nbits); in test_bitmap_cut()