20 #define MY_BIT_NONE (~(uint) 0)
24 typedef uint32 my_bitmap_map;
28 my_bitmap_map *bitmap;
30 my_bitmap_map last_word_mask;
31 my_bitmap_map *last_word_ptr;
43 extern void create_last_word_mask(
MY_BITMAP *map);
44 extern my_bool bitmap_init(
MY_BITMAP *map, my_bitmap_map *
buf, uint n_bits,
46 extern my_bool bitmap_is_clear_all(
const MY_BITMAP *map);
47 extern my_bool bitmap_is_prefix(
const MY_BITMAP *map, uint prefix_size);
48 extern my_bool bitmap_is_set_all(
const MY_BITMAP *map);
50 extern my_bool bitmap_is_overlapping(
const MY_BITMAP *map1,
52 extern my_bool bitmap_test_and_set(
MY_BITMAP *map, uint bitmap_bit);
53 extern my_bool bitmap_test_and_clear(
MY_BITMAP *map, uint bitmap_bit);
54 extern my_bool bitmap_fast_test_and_set(
MY_BITMAP *map, uint bitmap_bit);
55 extern uint bitmap_set_next(
MY_BITMAP *map);
56 extern uint bitmap_get_first(
const MY_BITMAP *map);
57 extern uint bitmap_get_first_set(
const MY_BITMAP *map);
58 extern uint bitmap_get_next_set(
const MY_BITMAP *map, uint bitmap_bit);
59 extern uint bitmap_bits_set(
const MY_BITMAP *map);
61 extern void bitmap_set_above(
MY_BITMAP *map, uint from_byte, uint use_bit);
62 extern void bitmap_set_prefix(
MY_BITMAP *map, uint prefix_size);
67 extern void bitmap_invert(
MY_BITMAP *map);
70 extern uint bitmap_lock_set_next(
MY_BITMAP *map);
71 extern void bitmap_lock_clear_bit(
MY_BITMAP *map, uint bitmap_bit);
73 #define bitmap_buffer_size(bits) (((bits)+31)/32)*4
74 #define no_bytes_in_map(map) (((map)->n_bits + 7)/8)
75 #define no_words_in_map(map) (((map)->n_bits + 31)/32)
77 static inline void bitmap_set_bit(
MY_BITMAP *map, uint bit)
79 DBUG_ASSERT(bit < map->n_bits);
80 ((uchar*)map->bitmap)[bit / 8] |= (1 << (bit & 7));
84 static inline void bitmap_flip_bit(
MY_BITMAP *map, uint bit)
86 DBUG_ASSERT(bit < map->n_bits);
87 ((uchar*)map->bitmap)[bit / 8] ^= (1 << (bit & 7));
91 static inline void bitmap_clear_bit(
MY_BITMAP *map, uint bit)
93 DBUG_ASSERT(bit < map->n_bits);
94 ((uchar*)map->bitmap)[bit / 8] &= ~(1 << (bit & 7));
98 static inline my_bool bitmap_is_set(
const MY_BITMAP *map, uint bit)
100 DBUG_ASSERT(bit < map->n_bits);
101 return ((uchar*)map->bitmap)[bit / 8] & (1 << (bit & 7));
114 if (memcmp(map1->bitmap, map2->bitmap, 4*(no_words_in_map(map1)-1)) != 0)
116 return ((*map1->last_word_ptr | map1->last_word_mask) ==
117 (*map2->last_word_ptr | map2->last_word_mask));
120 #define bitmap_clear_all(MAP) \
121 { memset((MAP)->bitmap, 0, 4*no_words_in_map((MAP))); }
122 #define bitmap_set_all(MAP) \
123 (memset((MAP)->bitmap, 0xFF, 4*no_words_in_map((MAP))))