summaryrefslogtreecommitdiff
path: root/include/my_bitmap.h
diff options
context:
space:
mode:
authorunknown <mronstrom@mysql.com>2005-06-06 08:59:00 +0200
committerunknown <mronstrom@mysql.com>2005-06-06 08:59:00 +0200
commit81a13dd16c37e5ef97850e7f728a8cc4038c1e69 (patch)
tree6632f533481048b24b136c42f48dadb76edd1462 /include/my_bitmap.h
parentdb5c15f60e32c6e3c07d3e0ad91dcdc23601a0dd (diff)
downloadmariadb-git-81a13dd16c37e5ef97850e7f728a8cc4038c1e69.tar.gz
Patch for bugs in bitmap (endian issue)
Diffstat (limited to 'include/my_bitmap.h')
-rw-r--r--include/my_bitmap.h47
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))))