diff options
author | unknown <mronstrom@mysql.com> | 2005-06-06 08:59:00 +0200 |
---|---|---|
committer | unknown <mronstrom@mysql.com> | 2005-06-06 08:59:00 +0200 |
commit | 81a13dd16c37e5ef97850e7f728a8cc4038c1e69 (patch) | |
tree | 6632f533481048b24b136c42f48dadb76edd1462 /include/my_bitmap.h | |
parent | db5c15f60e32c6e3c07d3e0ad91dcdc23601a0dd (diff) | |
download | mariadb-git-81a13dd16c37e5ef97850e7f728a8cc4038c1e69.tar.gz |
Patch for bugs in bitmap (endian issue)
Diffstat (limited to 'include/my_bitmap.h')
-rw-r--r-- | include/my_bitmap.h | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 503818a5e12..e6e985d92d7 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -84,15 +84,50 @@ extern void bitmap_lock_invert(MY_BITMAP *map); #define no_bytes_in_map(map) (((map)->n_bits + 7)/8) #define no_words_in_map(map) (((map)->n_bits + 31)/32) #define bytes_word_aligned(bytes) (4*((bytes + 3)/4)) -#define bitmap_set_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 32] |= (1 << ((BIT) & 31))) -#define bitmap_flip_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 32] ^= (1 << ((BIT) & 31))) -#define bitmap_clear_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 32] &= ~ (1 << ((BIT) & 31))) -#define bitmap_is_set(MAP, BIT) ((MAP)->bitmap[(BIT) / 32] & (1 << ((BIT) & 31))) +#define _bitmap_set_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \ + |= (1 << ((BIT) & 7))) +#define _bitmap_flip_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \ + ^= (1 << ((BIT) & 7))) +#define _bitmap_clear_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \ + &= ~ (1 << ((BIT) & 7))) +#define _bitmap_is_set(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \ + & (1 << ((BIT) & 7))) +#ifndef DBUG_OFF +inline uint32 +bitmap_set_bit(MY_BITMAP *map,uint bit) +{ + DBUG_ASSERT(bit < (map)->n_bits); + return _bitmap_set_bit(map,bit); +} +inline uint32 +bitmap_flip_bit(MY_BITMAP *map,uint bit) +{ + DBUG_ASSERT(bit < (map)->n_bits); + return _bitmap_flip_bit(map,bit); +} +inline uint32 +bitmap_clear_bit(MY_BITMAP *map,uint bit) +{ + DBUG_ASSERT(bit < (map)->n_bits); + return _bitmap_clear_bit(map,bit); +} +inline uint32 +bitmap_is_set(const MY_BITMAP *map,uint bit) +{ + DBUG_ASSERT(bit < (map)->n_bits); + return _bitmap_is_set(map,bit); +} +#else +#define bitmap_set_bit(MAP, BIT) _bitmap_set_bit(MAP, BIT) +#define bitmap_flip_bit(MAP, BIT) _bitmap_flip_bit(MAP, BIT) +#define bitmap_clear_bit(MAP, BIT) _bitmap_clear_bit(MAP, BIT) +#define bitmap_is_set(MAP, BIT) _bitmap_is_set(MAP, BIT) +#endif #define bitmap_cmp(MAP1, MAP2) \ (memcmp((MAP1)->bitmap, (MAP2)->bitmap, 4*no_words_in_map((MAP1)))==0) #define bitmap_clear_all(MAP) \ - memset((MAP)->bitmap, 0, 4*no_words_in_map((MAP))); \ - *(MAP)->last_word_ptr|= (MAP)->last_word_mask + { memset((MAP)->bitmap, 0, 4*no_words_in_map((MAP))); \ + *(MAP)->last_word_ptr|= (MAP)->last_word_mask; } #define bitmap_set_all(MAP) \ (memset((MAP)->bitmap, 0xFF, 4*no_words_in_map((MAP)))) |