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;
86
86
static inline void bitmap_lock(MY_BITMAP *map __attribute__((unused)))
89
90
pthread_mutex_lock(map->mutex);
92
94
static inline void bitmap_unlock(MY_BITMAP *map __attribute__((unused)))
95
98
pthread_mutex_unlock(map->mutex);
99
bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint32_t n_bits,
100
bool thread_safe __attribute__((unused)))
103
my_bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
104
my_bool thread_safe __attribute__((unused)))
106
DBUG_ENTER("bitmap_init");
104
uint32_t size_in_bytes= bitmap_buffer_size(n_bits);
109
uint size_in_bytes= bitmap_buffer_size(n_bits);
108
114
size_in_bytes= ALIGN_SIZE(size_in_bytes);
109
115
extra= sizeof(pthread_mutex_t);
112
119
if (!(buf= (my_bitmap_map*) my_malloc(size_in_bytes+extra, MYF(MY_WME))))
116
124
map->mutex= (pthread_mutex_t *) ((char*) buf + size_in_bytes);
117
125
pthread_mutex_init(map->mutex, MY_MUTEX_INIT_FAST);
122
assert(thread_safe == 0);
132
DBUG_ASSERT(thread_safe == 0);
125
136
map->bitmap= buf;
126
137
map->n_bits= n_bits;
127
138
create_last_word_mask(map);
128
139
bitmap_clear_all(map);
133
144
void bitmap_free(MY_BITMAP *map)
146
DBUG_ENTER("bitmap_free");
138
151
pthread_mutex_destroy(map->mutex);
139
free((char*) map->bitmap);
153
my_free((char*) map->bitmap, MYF(0));
159
bool bitmap_fast_test_and_set(MY_BITMAP *map, uint32_t bitmap_bit)
173
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;
175
uchar *value= ((uchar*) map->bitmap) + (bitmap_bit / 8);
176
uchar bit= 1 << ((bitmap_bit) & 7);
177
uchar res= (*value) & bit;
182
bool bitmap_test_and_set(MY_BITMAP *map, uint32_t bitmap_bit)
196
my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit)
185
assert(map->bitmap && bitmap_bit < map->n_bits);
199
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
186
200
bitmap_lock(map);
187
201
res= bitmap_fast_test_and_set(map, bitmap_bit);
188
202
bitmap_unlock(map);
205
bool bitmap_fast_test_and_clear(MY_BITMAP *map, uint32_t bitmap_bit)
219
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;
221
uchar *byte= (uchar*) map->bitmap + (bitmap_bit / 8);
222
uchar bit= 1 << ((bitmap_bit) & 7);
223
uchar res= (*byte) & bit;
215
bool bitmap_test_and_clear(MY_BITMAP *map, uint32_t bitmap_bit)
229
my_bool bitmap_test_and_clear(MY_BITMAP *map, uint bitmap_bit)
218
assert(map->bitmap && bitmap_bit < map->n_bits);
232
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
219
233
bitmap_lock(map);
220
234
res= bitmap_fast_test_and_clear(map, bitmap_bit);
221
235
bitmap_unlock(map);
226
uint32_t bitmap_set_next(MY_BITMAP *map)
240
uint bitmap_set_next(MY_BITMAP *map)
243
DBUG_ASSERT(map->bitmap);
230
244
if ((bit_found= bitmap_get_first(map)) != MY_BIT_NONE)
231
245
bitmap_set_bit(map, bit_found);
232
246
return bit_found;
236
void bitmap_set_prefix(MY_BITMAP *map, uint32_t prefix_size)
250
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;
252
uint prefix_bytes, prefix_bits, d;
253
uchar *m= (uchar *)map->bitmap;
241
assert(map->bitmap &&
242
(prefix_size <= map->n_bits || prefix_size == UINT32_MAX));
255
DBUG_ASSERT(map->bitmap &&
256
(prefix_size <= map->n_bits || prefix_size == (uint) ~0));
243
257
set_if_smaller(prefix_size, map->n_bits);
244
258
if ((prefix_bytes= prefix_size / 8))
245
259
memset(m, 0xff, prefix_bytes);
247
261
if ((prefix_bits= prefix_size & 7))
248
262
*m++= (1 << prefix_bits)-1;
249
263
if ((d= no_bytes_in_map(map)-prefix_bytes))
254
bool bitmap_is_prefix(const MY_BITMAP *map, uint32_t prefix_size)
268
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);
270
uint prefix_bits= prefix_size & 0x7, res;
271
uchar *m= (uchar*)map->bitmap;
272
uchar *end_prefix= m+prefix_size/8;
274
DBUG_ASSERT(m && prefix_size <= map->n_bits);
261
275
end= m+no_bytes_in_map(map);
263
277
while (m < end_prefix)
281
bool bitmap_is_set_all(const MY_BITMAP *map)
295
my_bool bitmap_is_set_all(const MY_BITMAP *map)
283
297
my_bitmap_map *data_ptr= map->bitmap;
284
298
my_bitmap_map *end= map->last_word_ptr;
285
299
*map->last_word_ptr |= map->last_word_mask;
286
300
for (; data_ptr <= end; data_ptr++)
287
301
if (*data_ptr != 0xFFFFFFFF)
293
bool bitmap_is_clear_all(const MY_BITMAP *map)
307
my_bool bitmap_is_clear_all(const MY_BITMAP *map)
295
309
my_bitmap_map *data_ptr= map->bitmap;
296
310
my_bitmap_map *end;
297
311
if (*map->last_word_ptr & ~map->last_word_mask)
299
313
end= map->last_word_ptr;
300
314
for (; data_ptr < end; data_ptr++)
306
/* Return true if map1 is a subset of map2 */
320
/* Return TRUE if map1 is a subset of map2 */
308
bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
322
my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
310
324
my_bitmap_map *m1= map1->bitmap, *m2= map2->bitmap, *end;
312
assert(map1->bitmap && map2->bitmap &&
326
DBUG_ASSERT(map1->bitmap && map2->bitmap &&
313
327
map1->n_bits==map2->n_bits);
315
329
end= map1->last_word_ptr;
326
340
/* True if bitmaps has any common bits */
328
bool bitmap_is_overlapping(const MY_BITMAP *map1, const MY_BITMAP *map2)
342
my_bool bitmap_is_overlapping(const MY_BITMAP *map1, const MY_BITMAP *map2)
330
344
my_bitmap_map *m1= map1->bitmap, *m2= map2->bitmap, *end;
332
assert(map1->bitmap && map2->bitmap &&
346
DBUG_ASSERT(map1->bitmap && map2->bitmap &&
333
347
map1->n_bits==map2->n_bits);
335
349
end= map1->last_word_ptr;
347
361
void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2)
349
363
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);
364
uint len= no_words_in_map(map), len2 = no_words_in_map(map2);
366
DBUG_ASSERT(map->bitmap && map2->bitmap);
368
end= to+min(len,len2);
355
369
*map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
357
371
*to++ &= *from++;
388
void bitmap_set_above(MY_BITMAP *map, uint32_t from_byte, uint32_t use_bit)
402
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;
404
uchar use_byte= use_bit ? 0xff : 0;
405
uchar *to= (uchar *)map->bitmap + from_byte;
406
uchar *end= (uchar *)map->bitmap + (map->n_bits+7)/8;
399
413
void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2)
401
415
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
402
assert(map->bitmap && map2->bitmap &&
416
DBUG_ASSERT(map->bitmap && map2->bitmap &&
403
417
map->n_bits==map2->n_bits);
405
419
end= map->last_word_ptr;
414
428
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
416
assert(map->bitmap && map2->bitmap &&
430
DBUG_ASSERT(map->bitmap && map2->bitmap &&
417
431
map->n_bits==map2->n_bits);
418
432
end= map->last_word_ptr;
425
439
void bitmap_xor(MY_BITMAP *map, const MY_BITMAP *map2)
427
441
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end= map->last_word_ptr;
428
assert(map->bitmap && map2->bitmap &&
442
DBUG_ASSERT(map->bitmap && map2->bitmap &&
429
443
map->n_bits==map2->n_bits);
430
444
while (to <= end)
431
445
*to++ ^= *from++;
447
uint32_t bitmap_bits_set(const MY_BITMAP *map)
461
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);
463
uchar *m= (uchar*)map->bitmap;
464
uchar *end= m + no_bytes_in_map(map);
467
DBUG_ASSERT(map->bitmap);
454
468
*map->last_word_ptr&= ~map->last_word_mask; /*Reset last bits to zero*/
456
res+= my_count_bits_uint16(*m++);
470
res+= my_count_bits_ushort(*m++);
463
477
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
465
assert(map->bitmap && map2->bitmap &&
479
DBUG_ASSERT(map->bitmap && map2->bitmap &&
466
480
map->n_bits==map2->n_bits);
467
481
end= map->last_word_ptr;
468
482
while (to <= end)
473
uint32_t bitmap_get_first_set(const MY_BITMAP *map)
487
uint bitmap_get_first_set(const MY_BITMAP *map)
475
unsigned char *byte_ptr;
477
491
my_bitmap_map *data_ptr, *end= map->last_word_ptr;
493
DBUG_ASSERT(map->bitmap);
480
494
data_ptr= map->bitmap;
481
495
*map->last_word_ptr &= ~map->last_word_mask;
494
508
if (*byte_ptr & (1 << k))
495
509
return (i*32) + (j*8) + k;
503
517
return MY_BIT_NONE;
507
uint32_t bitmap_get_first(const MY_BITMAP *map)
521
uint bitmap_get_first(const MY_BITMAP *map)
509
unsigned char *byte_ptr;
511
525
my_bitmap_map *data_ptr, *end= map->last_word_ptr;
527
DBUG_ASSERT(map->bitmap);
514
528
data_ptr= map->bitmap;
515
529
*map->last_word_ptr|= map->last_word_mask;
528
542
if (!(*byte_ptr & (1 << k)))
529
543
return (i*32) + (j*8) + k;
537
551
return MY_BIT_NONE;
541
uint32_t bitmap_lock_set_next(MY_BITMAP *map)
555
uint bitmap_lock_set_next(MY_BITMAP *map)
544
558
bitmap_lock(map);
545
559
bit_found= bitmap_set_next(map);
546
560
bitmap_unlock(map);
551
void bitmap_lock_clear_bit(MY_BITMAP *map, uint32_t bitmap_bit)
565
void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit)
553
567
bitmap_lock(map);
554
assert(map->bitmap && bitmap_bit < map->n_bits);
568
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
555
569
bitmap_clear_bit(map, bitmap_bit);
556
570
bitmap_unlock(map);
561
bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint32_t prefix_size)
575
my_bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint prefix_size)
564
578
bitmap_lock((MY_BITMAP *)map);
565
579
res= bitmap_is_prefix(map, prefix_size);
566
580
bitmap_unlock((MY_BITMAP *)map);
595
bool bitmap_lock_is_clear_all(const MY_BITMAP *map)
609
my_bool bitmap_lock_is_clear_all(const MY_BITMAP *map)
598
612
bitmap_lock((MY_BITMAP *)map);
599
613
res= bitmap_is_clear_all(map);
600
614
bitmap_unlock((MY_BITMAP *)map);
605
bool bitmap_lock_is_set_all(const MY_BITMAP *map)
619
my_bool bitmap_lock_is_set_all(const MY_BITMAP *map)
608
622
bitmap_lock((MY_BITMAP *)map);
609
623
res= bitmap_is_set_all(map);
610
624
bitmap_unlock((MY_BITMAP *)map);
615
bool bitmap_lock_is_set(const MY_BITMAP *map, uint32_t bitmap_bit)
629
my_bool bitmap_lock_is_set(const MY_BITMAP *map, uint bitmap_bit)
618
assert(map->bitmap && bitmap_bit < map->n_bits);
632
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
619
633
bitmap_lock((MY_BITMAP *)map);
620
634
res= bitmap_is_set(map, bitmap_bit);
621
635
bitmap_unlock((MY_BITMAP *)map);
626
bool bitmap_lock_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
640
my_bool bitmap_lock_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
629
643
bitmap_lock((MY_BITMAP *)map1);
630
644
bitmap_lock((MY_BITMAP *)map2);
631
645
res= bitmap_is_subset(map1, map2);
638
bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
652
my_bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
642
assert(map1->bitmap && map2->bitmap &&
656
DBUG_ASSERT(map1->bitmap && map2->bitmap &&
643
657
map1->n_bits==map2->n_bits);
644
658
bitmap_lock((MY_BITMAP *)map1);
645
659
bitmap_lock((MY_BITMAP *)map2);
688
702
Number of set bits in the bitmap.
690
uint32_t bitmap_lock_bits_set(const MY_BITMAP *map)
704
uint bitmap_lock_bits_set(const MY_BITMAP *map)
693
707
bitmap_lock((MY_BITMAP *)map);
708
DBUG_ASSERT(map->bitmap);
695
709
res= bitmap_bits_set(map);
696
710
bitmap_unlock((MY_BITMAP *)map);
706
720
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)
722
uint bitmap_lock_get_first(const MY_BITMAP *map)
711
725
bitmap_lock((MY_BITMAP*)map);
712
726
res= bitmap_get_first(map);
713
727
bitmap_unlock((MY_BITMAP*)map);
718
uint32_t bitmap_lock_get_first_set(const MY_BITMAP *map)
732
uint bitmap_lock_get_first_set(const MY_BITMAP *map)
721
735
bitmap_lock((MY_BITMAP*)map);
722
736
res= bitmap_get_first_set(map);
723
737
bitmap_unlock((MY_BITMAP*)map);
728
void bitmap_lock_set_bit(MY_BITMAP *map, uint32_t bitmap_bit)
742
void bitmap_lock_set_bit(MY_BITMAP *map, uint bitmap_bit)
730
assert(map->bitmap && bitmap_bit < map->n_bits);
744
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
731
745
bitmap_lock(map);
732
746
bitmap_set_bit(map, bitmap_bit);
733
747
bitmap_unlock(map);
737
void bitmap_lock_flip_bit(MY_BITMAP *map, uint32_t bitmap_bit)
751
void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit)
739
assert(map->bitmap && bitmap_bit < map->n_bits);
753
DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
740
754
bitmap_lock(map);
741
755
bitmap_flip_bit(map, bitmap_bit);
742
756
bitmap_unlock(map);
747
uint32_t get_rand_bit(uint32_t bitsize)
761
uint get_rand_bit(uint bitsize)
749
763
return (rand() % bitsize);
752
bool test_set_get_clear_bit(MY_BITMAP *map, uint32_t bitsize)
766
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;
769
uint no_loops= bitsize > 128 ? 128 : bitsize;
756
770
for (i=0; i < no_loops; i++)
758
772
test_bit= get_rand_bit(bitsize);
763
777
if (bitmap_is_set(map, test_bit))
768
782
printf("Error in set bit, bit %u, bitsize = %u", test_bit, bitsize);
771
785
printf("Error in clear bit, bit %u, bitsize = %u", test_bit, bitsize);
775
bool test_flip_bit(MY_BITMAP *map, uint32_t bitsize)
789
bool test_flip_bit(MY_BITMAP *map, uint bitsize)
777
uint32_t i, test_bit;
778
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
792
uint no_loops= bitsize > 128 ? 128 : bitsize;
779
793
for (i=0; i < no_loops; i++)
781
795
test_bit= get_rand_bit(bitsize);
786
800
if (bitmap_is_set(map, test_bit))
791
805
printf("Error in flip bit 1, bit %u, bitsize = %u", test_bit, bitsize);
794
808
printf("Error in flip bit 2, bit %u, bitsize = %u", test_bit, bitsize);
798
812
bool test_operators(MY_BITMAP *map __attribute__((unused)),
799
uint32_t bitsize __attribute__((unused)))
813
uint bitsize __attribute__((unused)))
804
bool test_get_all_bits(MY_BITMAP *map, uint32_t bitsize)
818
bool test_get_all_bits(MY_BITMAP *map, uint bitsize)
807
821
bitmap_set_all(map);
808
822
if (!bitmap_is_set_all(map))
822
836
bitmap_clear_bit(map, i);
823
837
if (!bitmap_is_clear_all(map))
827
841
printf("Error in set_all, bitsize = %u", bitsize);
830
844
printf("Error in clear_all, bitsize = %u", bitsize);
833
847
printf("Error in bitmap_is_set_all, bitsize = %u", bitsize);
836
850
printf("Error in bitmap_is_clear_all, bitsize = %u", bitsize);
839
853
printf("Error in set_all through set_prefix, bitsize = %u", bitsize);
842
856
printf("Error in clear_all through set_prefix, bitsize = %u", bitsize);
846
bool test_compare_operators(MY_BITMAP *map, uint32_t bitsize)
860
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;
862
uint i, j, test_bit1, test_bit2, test_bit3,test_bit4;
863
uint no_loops= bitsize > 128 ? 128 : bitsize;
850
864
MY_BITMAP map2_obj, map3_obj;
851
865
MY_BITMAP *map2= &map2_obj, *map3= &map3_obj;
852
866
my_bitmap_map map2buf[1024];
853
867
my_bitmap_map map3buf[1024];
854
bitmap_init(&map2_obj, map2buf, bitsize, false);
855
bitmap_init(&map3_obj, map3buf, bitsize, false);
868
bitmap_init(&map2_obj, map2buf, bitsize, FALSE);
869
bitmap_init(&map3_obj, map3buf, bitsize, FALSE);
856
870
bitmap_clear_all(map2);
857
871
bitmap_clear_all(map3);
858
872
for (i=0; i < no_loops; i++)
926
940
bitmap_clear_all(map);
927
941
bitmap_clear_all(map3);
931
945
printf("intersect error bitsize=%u,size1=%u,size2=%u", bitsize,
932
946
test_bit1,test_bit2);
935
949
printf("union error bitsize=%u,size1=%u,size2=%u", bitsize,
936
950
test_bit1,test_bit2);
939
953
printf("xor error bitsize=%u,size1=%u,size2=%u", bitsize,
940
954
test_bit1,test_bit2);
943
957
printf("subtract error bitsize=%u,size1=%u,size2=%u", bitsize,
944
958
test_bit1,test_bit2);
947
961
printf("invert error bitsize=%u,size=%u", bitsize,
952
bool test_count_bits_set(MY_BITMAP *map, uint32_t bitsize)
966
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;
968
uint i, bit_count=0, test_bit;
969
uint no_loops= bitsize > 128 ? 128 : bitsize;
956
970
for (i=0; i < no_loops; i++)
958
972
test_bit=get_rand_bit(bitsize);
967
981
if (bitmap_bits_set(map) != bit_count)
971
985
printf("No bits set bitsize = %u", bitsize);
974
988
printf("Wrong count of bits set, bitsize = %u", bitsize);
978
bool test_get_first_bit(MY_BITMAP *map, uint32_t bitsize)
992
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;
995
uint no_loops= bitsize > 128 ? 128 : bitsize;
982
996
for (i=0; i < no_loops; i++)
984
998
test_bit=get_rand_bit(bitsize);
992
1006
bitmap_clear_all(map);
996
1010
printf("get_first_set error bitsize=%u,prefix_size=%u",bitsize,test_bit);
999
1013
printf("get_first error bitsize= %u, prefix_size= %u",bitsize,test_bit);
1003
bool test_get_next_bit(MY_BITMAP *map, uint32_t bitsize)
1017
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;
1019
uint i, j, test_bit;
1020
uint no_loops= bitsize > 128 ? 128 : bitsize;
1007
1021
for (i=0; i < no_loops; i++)
1009
1023
test_bit=get_rand_bit(bitsize);
1014
1028
bitmap_clear_all(map);
1018
1032
printf("get_next error bitsize= %u, prefix_size= %u", bitsize,test_bit);
1022
bool test_prefix(MY_BITMAP *map, uint32_t bitsize)
1036
bool test_prefix(MY_BITMAP *map, uint bitsize)
1024
uint32_t i, j, test_bit;
1025
uint32_t no_loops= bitsize > 128 ? 128 : bitsize;
1038
uint i, j, test_bit;
1039
uint no_loops= bitsize > 128 ? 128 : bitsize;
1026
1040
for (i=0; i < no_loops; i++)
1028
1042
test_bit=get_rand_bit(bitsize);
1042
1056
bitmap_clear_all(map);
1046
1060
printf("prefix1 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
1049
1063
printf("prefix2 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
1052
1066
printf("prefix3 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
1057
bool do_test(uint32_t bitsize)
1071
bool do_test(uint bitsize)
1060
1074
my_bitmap_map buf[1024];
1061
if (bitmap_init(&map, buf, bitsize, false))
1075
if (bitmap_init(&map, buf, bitsize, FALSE))
1063
1077
printf("init error for bitsize %d", bitsize);