14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
Handling of unsigned char arrays as large bitmaps.
17
Handling of uchar arrays as large bitmaps.
19
19
API limitations (or, rather asserted safety assumptions,
20
20
to encourage correct programming)
62
62
map->last_word_ptr= map->bitmap + no_words_in_map(map)-1;
63
63
switch (no_bytes_in_map(map) & 3) {
65
map->last_word_mask= UINT32_MAX;
65
map->last_word_mask= ~0U;
69
map->last_word_mask= UINT32_MAX;
69
map->last_word_mask= ~0U;
74
map->last_word_mask= 0;
74
map->last_word_mask= 0U;
99
bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint32_t n_bits,
100
bool thread_safe __attribute__((unused)))
99
my_bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
100
my_bool thread_safe __attribute__((unused)))
102
DBUG_ENTER("bitmap_init");
104
uint32_t size_in_bytes= bitmap_buffer_size(n_bits);
105
uint size_in_bytes= bitmap_buffer_size(n_bits);
108
109
size_in_bytes= ALIGN_SIZE(size_in_bytes);
122
assert(thread_safe == 0);
123
DBUG_ASSERT(thread_safe == 0);
125
126
map->bitmap= buf;
126
127
map->n_bits= n_bits;
127
128
create_last_word_mask(map);
128
129
bitmap_clear_all(map);
133
134
void bitmap_free(MY_BITMAP *map)
136
DBUG_ENTER("bitmap_free");
138
140
pthread_mutex_destroy(map->mutex);
139
free((char*) map->bitmap);
141
my_free((char*) map->bitmap, MYF(0));
159
bool bitmap_fast_test_and_set(MY_BITMAP *map, uint32_t bitmap_bit)
161
my_bool bitmap_fast_test_and_set(MY_BITMAP *map, uint bitmap_bit)
161
unsigned char *value= ((unsigned char*) map->bitmap) + (bitmap_bit / 8);
162
unsigned char bit= 1 << ((bitmap_bit) & 7);
163
unsigned char res= (*value) & bit;
163
uchar *value= ((uchar*) map->bitmap) + (bitmap_bit / 8);
164
uchar bit= 1 << ((bitmap_bit) & 7);
165
uchar res= (*value) & bit;
182
bool bitmap_test_and_set(MY_BITMAP *map, uint32_t bitmap_bit)
184
my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit)
185
assert(map->bitmap && bitmap_bit < map->n_bits);
187
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
186
188
bitmap_lock(map);
187
189
res= bitmap_fast_test_and_set(map, bitmap_bit);
188
190
bitmap_unlock(map);
205
bool bitmap_fast_test_and_clear(MY_BITMAP *map, uint32_t bitmap_bit)
207
my_bool bitmap_fast_test_and_clear(MY_BITMAP *map, uint bitmap_bit)
207
unsigned char *byte= (unsigned char*) map->bitmap + (bitmap_bit / 8);
208
unsigned char bit= 1 << ((bitmap_bit) & 7);
209
unsigned char res= (*byte) & bit;
209
uchar *byte= (uchar*) map->bitmap + (bitmap_bit / 8);
210
uchar bit= 1 << ((bitmap_bit) & 7);
211
uchar res= (*byte) & bit;
215
bool bitmap_test_and_clear(MY_BITMAP *map, uint32_t bitmap_bit)
217
my_bool bitmap_test_and_clear(MY_BITMAP *map, uint bitmap_bit)
218
assert(map->bitmap && bitmap_bit < map->n_bits);
220
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
219
221
bitmap_lock(map);
220
222
res= bitmap_fast_test_and_clear(map, bitmap_bit);
221
223
bitmap_unlock(map);
226
uint32_t bitmap_set_next(MY_BITMAP *map)
228
uint bitmap_set_next(MY_BITMAP *map)
231
DBUG_ASSERT(map->bitmap);
230
232
if ((bit_found= bitmap_get_first(map)) != MY_BIT_NONE)
231
233
bitmap_set_bit(map, bit_found);
232
234
return bit_found;
236
void bitmap_set_prefix(MY_BITMAP *map, uint32_t prefix_size)
238
void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size)
238
uint32_t prefix_bytes, prefix_bits, d;
239
unsigned char *m= (unsigned char *)map->bitmap;
240
uint prefix_bytes, prefix_bits, d;
241
uchar *m= (uchar *)map->bitmap;
241
assert(map->bitmap &&
242
(prefix_size <= map->n_bits || prefix_size == UINT32_MAX));
243
DBUG_ASSERT(map->bitmap &&
244
(prefix_size <= map->n_bits || prefix_size == (uint) ~0));
243
245
set_if_smaller(prefix_size, map->n_bits);
244
246
if ((prefix_bytes= prefix_size / 8))
245
247
memset(m, 0xff, prefix_bytes);
247
249
if ((prefix_bits= prefix_size & 7))
248
250
*m++= (1 << prefix_bits)-1;
249
251
if ((d= no_bytes_in_map(map)-prefix_bytes))
254
bool bitmap_is_prefix(const MY_BITMAP *map, uint32_t prefix_size)
256
my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size)
256
uint32_t prefix_bits= prefix_size & 0x7, res;
257
unsigned char *m= (unsigned char*)map->bitmap;
258
unsigned char *end_prefix= m+prefix_size/8;
260
assert(m && prefix_size <= map->n_bits);
258
uint prefix_bits= prefix_size & 0x7, res;
259
uchar *m= (uchar*)map->bitmap;
260
uchar *end_prefix= m+prefix_size/8;
262
DBUG_ASSERT(m && prefix_size <= map->n_bits);
261
263
end= m+no_bytes_in_map(map);
263
265
while (m < end_prefix)
281
bool bitmap_is_set_all(const MY_BITMAP *map)
283
my_bool bitmap_is_set_all(const MY_BITMAP *map)
283
285
my_bitmap_map *data_ptr= map->bitmap;
284
286
my_bitmap_map *end= map->last_word_ptr;
285
287
*map->last_word_ptr |= map->last_word_mask;
286
288
for (; data_ptr <= end; data_ptr++)
287
289
if (*data_ptr != 0xFFFFFFFF)
293
bool bitmap_is_clear_all(const MY_BITMAP *map)
295
my_bool bitmap_is_clear_all(const MY_BITMAP *map)
295
297
my_bitmap_map *data_ptr= map->bitmap;
296
298
my_bitmap_map *end;
297
299
if (*map->last_word_ptr & ~map->last_word_mask)
299
301
end= map->last_word_ptr;
300
302
for (; data_ptr < end; data_ptr++)
306
/* Return true if map1 is a subset of map2 */
308
/* Return TRUE if map1 is a subset of map2 */
308
bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
310
my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
310
312
my_bitmap_map *m1= map1->bitmap, *m2= map2->bitmap, *end;
312
assert(map1->bitmap && map2->bitmap &&
314
DBUG_ASSERT(map1->bitmap && map2->bitmap &&
313
315
map1->n_bits==map2->n_bits);
315
317
end= map1->last_word_ptr;
326
328
/* True if bitmaps has any common bits */
328
bool bitmap_is_overlapping(const MY_BITMAP *map1, const MY_BITMAP *map2)
330
my_bool bitmap_is_overlapping(const MY_BITMAP *map1, const MY_BITMAP *map2)
330
332
my_bitmap_map *m1= map1->bitmap, *m2= map2->bitmap, *end;
332
assert(map1->bitmap && map2->bitmap &&
334
DBUG_ASSERT(map1->bitmap && map2->bitmap &&
333
335
map1->n_bits==map2->n_bits);
335
337
end= map1->last_word_ptr;
347
349
void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2)
349
351
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
350
uint32_t len= no_words_in_map(map), len2 = no_words_in_map(map2);
352
assert(map->bitmap && map2->bitmap);
354
end= to+cmin(len,len2);
352
uint len= no_words_in_map(map), len2 = no_words_in_map(map2);
354
DBUG_ASSERT(map->bitmap && map2->bitmap);
356
end= to+min(len,len2);
355
357
*map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
357
359
*to++ &= *from++;
388
void bitmap_set_above(MY_BITMAP *map, uint32_t from_byte, uint32_t use_bit)
390
void bitmap_set_above(MY_BITMAP *map, uint from_byte, uint use_bit)
390
unsigned char use_byte= use_bit ? 0xff : 0;
391
unsigned char *to= (unsigned char *)map->bitmap + from_byte;
392
unsigned char *end= (unsigned char *)map->bitmap + (map->n_bits+7)/8;
392
uchar use_byte= use_bit ? 0xff : 0;
393
uchar *to= (uchar *)map->bitmap + from_byte;
394
uchar *end= (uchar *)map->bitmap + (map->n_bits+7)/8;
399
401
void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2)
401
403
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
402
assert(map->bitmap && map2->bitmap &&
404
DBUG_ASSERT(map->bitmap && map2->bitmap &&
403
405
map->n_bits==map2->n_bits);
405
407
end= map->last_word_ptr;
414
416
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
416
assert(map->bitmap && map2->bitmap &&
418
DBUG_ASSERT(map->bitmap && map2->bitmap &&
417
419
map->n_bits==map2->n_bits);
418
420
end= map->last_word_ptr;
425
427
void bitmap_xor(MY_BITMAP *map, const MY_BITMAP *map2)
427
429
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end= map->last_word_ptr;
428
assert(map->bitmap && map2->bitmap &&
430
DBUG_ASSERT(map->bitmap && map2->bitmap &&
429
431
map->n_bits==map2->n_bits);
430
432
while (to <= end)
431
433
*to++ ^= *from++;
447
uint32_t bitmap_bits_set(const MY_BITMAP *map)
449
uint bitmap_bits_set(const MY_BITMAP *map)
449
unsigned char *m= (unsigned char*)map->bitmap;
450
unsigned char *end= m + no_bytes_in_map(map);
451
uchar *m= (uchar*)map->bitmap;
452
uchar *end= m + no_bytes_in_map(map);
455
DBUG_ASSERT(map->bitmap);
454
456
*map->last_word_ptr&= ~map->last_word_mask; /*Reset last bits to zero*/
456
res+= my_count_bits_uint16(*m++);
458
res+= my_count_bits_ushort(*m++);
463
465
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
465
assert(map->bitmap && map2->bitmap &&
467
DBUG_ASSERT(map->bitmap && map2->bitmap &&
466
468
map->n_bits==map2->n_bits);
467
469
end= map->last_word_ptr;
468
470
while (to <= end)
473
uint32_t bitmap_get_first_set(const MY_BITMAP *map)
475
uint bitmap_get_first_set(const MY_BITMAP *map)
475
unsigned char *byte_ptr;
477
479
my_bitmap_map *data_ptr, *end= map->last_word_ptr;
481
DBUG_ASSERT(map->bitmap);
480
482
data_ptr= map->bitmap;
481
483
*map->last_word_ptr &= ~map->last_word_mask;
494
496
if (*byte_ptr & (1 << k))
495
497
return (i*32) + (j*8) + k;
503
505
return MY_BIT_NONE;
507
uint32_t bitmap_get_first(const MY_BITMAP *map)
509
uint bitmap_get_first(const MY_BITMAP *map)
509
unsigned char *byte_ptr;
511
513
my_bitmap_map *data_ptr, *end= map->last_word_ptr;
515
DBUG_ASSERT(map->bitmap);
514
516
data_ptr= map->bitmap;
515
517
*map->last_word_ptr|= map->last_word_mask;
528
530
if (!(*byte_ptr & (1 << k)))
529
531
return (i*32) + (j*8) + k;
537
539
return MY_BIT_NONE;
541
uint32_t bitmap_lock_set_next(MY_BITMAP *map)
543
uint bitmap_lock_set_next(MY_BITMAP *map)
544
546
bitmap_lock(map);
545
547
bit_found= bitmap_set_next(map);
546
548
bitmap_unlock(map);
551
void bitmap_lock_clear_bit(MY_BITMAP *map, uint32_t bitmap_bit)
553
void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit)
553
555
bitmap_lock(map);
554
assert(map->bitmap && bitmap_bit < map->n_bits);
556
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
555
557
bitmap_clear_bit(map, bitmap_bit);
556
558
bitmap_unlock(map);
561
bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint32_t prefix_size)
563
my_bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint prefix_size)
564
566
bitmap_lock((MY_BITMAP *)map);
565
567
res= bitmap_is_prefix(map, prefix_size);
566
568
bitmap_unlock((MY_BITMAP *)map);
595
bool bitmap_lock_is_clear_all(const MY_BITMAP *map)
597
my_bool bitmap_lock_is_clear_all(const MY_BITMAP *map)
598
600
bitmap_lock((MY_BITMAP *)map);
599
601
res= bitmap_is_clear_all(map);
600
602
bitmap_unlock((MY_BITMAP *)map);
605
bool bitmap_lock_is_set_all(const MY_BITMAP *map)
607
my_bool bitmap_lock_is_set_all(const MY_BITMAP *map)
608
610
bitmap_lock((MY_BITMAP *)map);
609
611
res= bitmap_is_set_all(map);
610
612
bitmap_unlock((MY_BITMAP *)map);
615
bool bitmap_lock_is_set(const MY_BITMAP *map, uint32_t bitmap_bit)
617
my_bool bitmap_lock_is_set(const MY_BITMAP *map, uint bitmap_bit)
618
assert(map->bitmap && bitmap_bit < map->n_bits);
620
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
619
621
bitmap_lock((MY_BITMAP *)map);
620
622
res= bitmap_is_set(map, bitmap_bit);
621
623
bitmap_unlock((MY_BITMAP *)map);
626
bool bitmap_lock_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
628
my_bool bitmap_lock_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
629
631
bitmap_lock((MY_BITMAP *)map1);
630
632
bitmap_lock((MY_BITMAP *)map2);
631
633
res= bitmap_is_subset(map1, map2);
638
bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
640
my_bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
642
assert(map1->bitmap && map2->bitmap &&
644
DBUG_ASSERT(map1->bitmap && map2->bitmap &&
643
645
map1->n_bits==map2->n_bits);
644
646
bitmap_lock((MY_BITMAP *)map1);
645
647
bitmap_lock((MY_BITMAP *)map2);
688
690
Number of set bits in the bitmap.
690
uint32_t bitmap_lock_bits_set(const MY_BITMAP *map)
692
uint bitmap_lock_bits_set(const MY_BITMAP *map)
693
695
bitmap_lock((MY_BITMAP *)map);
696
DBUG_ASSERT(map->bitmap);
695
697
res= bitmap_bits_set(map);
696
698
bitmap_unlock((MY_BITMAP *)map);
706
708
Number of first unset bit in the bitmap or MY_BIT_NONE if all bits are set.
708
uint32_t bitmap_lock_get_first(const MY_BITMAP *map)
710
uint bitmap_lock_get_first(const MY_BITMAP *map)
711
713
bitmap_lock((MY_BITMAP*)map);
712
714
res= bitmap_get_first(map);
713
715
bitmap_unlock((MY_BITMAP*)map);
718
uint32_t bitmap_lock_get_first_set(const MY_BITMAP *map)
720
uint bitmap_lock_get_first_set(const MY_BITMAP *map)
721
723
bitmap_lock((MY_BITMAP*)map);
722
724
res= bitmap_get_first_set(map);
723
725
bitmap_unlock((MY_BITMAP*)map);
728
void bitmap_lock_set_bit(MY_BITMAP *map, uint32_t bitmap_bit)
730
void bitmap_lock_set_bit(MY_BITMAP *map, uint bitmap_bit)
730
assert(map->bitmap && bitmap_bit < map->n_bits);
732
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
731
733
bitmap_lock(map);
732
734
bitmap_set_bit(map, bitmap_bit);
733
735
bitmap_unlock(map);
737
void bitmap_lock_flip_bit(MY_BITMAP *map, uint32_t bitmap_bit)
739
void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit)
739
assert(map->bitmap && bitmap_bit < map->n_bits);
741
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
740
742
bitmap_lock(map);
741
743
bitmap_flip_bit(map, bitmap_bit);
742
744
bitmap_unlock(map);
747
uint32_t get_rand_bit(uint32_t bitsize)
749
uint get_rand_bit(uint bitsize)
749
751
return (rand() % bitsize);
752
bool test_set_get_clear_bit(MY_BITMAP *map, uint32_t bitsize)
754
my_bool test_set_get_clear_bit(MY_BITMAP *map, uint bitsize)
754
uint32_t i, test_bit;
755
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
757
uint no_loops= bitsize > 128 ? 128 : bitsize;
756
758
for (i=0; i < no_loops; i++)
758
760
test_bit= get_rand_bit(bitsize);
763
765
if (bitmap_is_set(map, test_bit))
768
770
printf("Error in set bit, bit %u, bitsize = %u", test_bit, bitsize);
771
773
printf("Error in clear bit, bit %u, bitsize = %u", test_bit, bitsize);
775
bool test_flip_bit(MY_BITMAP *map, uint32_t bitsize)
777
my_bool test_flip_bit(MY_BITMAP *map, uint bitsize)
777
uint32_t i, test_bit;
778
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
780
uint no_loops= bitsize > 128 ? 128 : bitsize;
779
781
for (i=0; i < no_loops; i++)
781
783
test_bit= get_rand_bit(bitsize);
786
788
if (bitmap_is_set(map, test_bit))
791
793
printf("Error in flip bit 1, bit %u, bitsize = %u", test_bit, bitsize);
794
796
printf("Error in flip bit 2, bit %u, bitsize = %u", test_bit, bitsize);
798
bool test_operators(MY_BITMAP *map __attribute__((unused)),
799
uint32_t bitsize __attribute__((unused)))
804
bool test_get_all_bits(MY_BITMAP *map, uint32_t bitsize)
800
my_bool test_operators(MY_BITMAP *map __attribute__((unused)),
801
uint bitsize __attribute__((unused)))
806
my_bool test_get_all_bits(MY_BITMAP *map, uint bitsize)
807
809
bitmap_set_all(map);
808
810
if (!bitmap_is_set_all(map))
822
824
bitmap_clear_bit(map, i);
823
825
if (!bitmap_is_clear_all(map))
827
829
printf("Error in set_all, bitsize = %u", bitsize);
830
832
printf("Error in clear_all, bitsize = %u", bitsize);
833
835
printf("Error in bitmap_is_set_all, bitsize = %u", bitsize);
836
838
printf("Error in bitmap_is_clear_all, bitsize = %u", bitsize);
839
841
printf("Error in set_all through set_prefix, bitsize = %u", bitsize);
842
844
printf("Error in clear_all through set_prefix, bitsize = %u", bitsize);
846
bool test_compare_operators(MY_BITMAP *map, uint32_t bitsize)
848
my_bool test_compare_operators(MY_BITMAP *map, uint bitsize)
848
uint32_t i, j, test_bit1, test_bit2, test_bit3,test_bit4;
849
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
850
uint i, j, test_bit1, test_bit2, test_bit3,test_bit4;
851
uint no_loops= bitsize > 128 ? 128 : bitsize;
850
852
MY_BITMAP map2_obj, map3_obj;
851
853
MY_BITMAP *map2= &map2_obj, *map3= &map3_obj;
852
854
my_bitmap_map map2buf[1024];
853
855
my_bitmap_map map3buf[1024];
854
bitmap_init(&map2_obj, map2buf, bitsize, false);
855
bitmap_init(&map3_obj, map3buf, bitsize, false);
856
bitmap_init(&map2_obj, map2buf, bitsize, FALSE);
857
bitmap_init(&map3_obj, map3buf, bitsize, FALSE);
856
858
bitmap_clear_all(map2);
857
859
bitmap_clear_all(map3);
858
860
for (i=0; i < no_loops; i++)
926
928
bitmap_clear_all(map);
927
929
bitmap_clear_all(map3);
931
933
printf("intersect error bitsize=%u,size1=%u,size2=%u", bitsize,
932
934
test_bit1,test_bit2);
935
937
printf("union error bitsize=%u,size1=%u,size2=%u", bitsize,
936
938
test_bit1,test_bit2);
939
941
printf("xor error bitsize=%u,size1=%u,size2=%u", bitsize,
940
942
test_bit1,test_bit2);
943
945
printf("subtract error bitsize=%u,size1=%u,size2=%u", bitsize,
944
946
test_bit1,test_bit2);
947
949
printf("invert error bitsize=%u,size=%u", bitsize,
952
bool test_count_bits_set(MY_BITMAP *map, uint32_t bitsize)
954
my_bool test_count_bits_set(MY_BITMAP *map, uint bitsize)
954
uint32_t i, bit_count=0, test_bit;
955
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
956
uint i, bit_count=0, test_bit;
957
uint no_loops= bitsize > 128 ? 128 : bitsize;
956
958
for (i=0; i < no_loops; i++)
958
960
test_bit=get_rand_bit(bitsize);
967
969
if (bitmap_bits_set(map) != bit_count)
971
973
printf("No bits set bitsize = %u", bitsize);
974
976
printf("Wrong count of bits set, bitsize = %u", bitsize);
978
bool test_get_first_bit(MY_BITMAP *map, uint32_t bitsize)
980
my_bool test_get_first_bit(MY_BITMAP *map, uint bitsize)
980
uint32_t i, test_bit;
981
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
983
uint no_loops= bitsize > 128 ? 128 : bitsize;
982
984
for (i=0; i < no_loops; i++)
984
986
test_bit=get_rand_bit(bitsize);
992
994
bitmap_clear_all(map);
996
998
printf("get_first_set error bitsize=%u,prefix_size=%u",bitsize,test_bit);
999
1001
printf("get_first error bitsize= %u, prefix_size= %u",bitsize,test_bit);
1003
bool test_get_next_bit(MY_BITMAP *map, uint32_t bitsize)
1005
my_bool test_get_next_bit(MY_BITMAP *map, uint bitsize)
1005
uint32_t i, j, test_bit;
1006
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
1007
uint i, j, test_bit;
1008
uint no_loops= bitsize > 128 ? 128 : bitsize;
1007
1009
for (i=0; i < no_loops; i++)
1009
1011
test_bit=get_rand_bit(bitsize);
1014
1016
bitmap_clear_all(map);
1018
1020
printf("get_next error bitsize= %u, prefix_size= %u", bitsize,test_bit);
1022
bool test_prefix(MY_BITMAP *map, uint32_t bitsize)
1024
my_bool test_prefix(MY_BITMAP *map, uint bitsize)
1024
uint32_t i, j, test_bit;
1025
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
1026
uint i, j, test_bit;
1027
uint no_loops= bitsize > 128 ? 128 : bitsize;
1026
1028
for (i=0; i < no_loops; i++)
1028
1030
test_bit=get_rand_bit(bitsize);
1042
1044
bitmap_clear_all(map);
1046
1048
printf("prefix1 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
1049
1051
printf("prefix2 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
1052
1054
printf("prefix3 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
1057
bool do_test(uint32_t bitsize)
1059
my_bool do_test(uint bitsize)
1060
1062
my_bitmap_map buf[1024];
1061
if (bitmap_init(&map, buf, bitsize, false))
1063
if (bitmap_init(&map, buf, bitsize, FALSE))
1063
1065
printf("init error for bitsize %d", bitsize);