List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:February 18 2011 2:05pm
Subject:bzr commit into mysql-trunk branch (jon.hauglid:3679) Bug#11752069
View as plain text  
#At file:///export/home/x/mysql-trunk-bug11752069_refactor/ based on revid:alexander.barkov@stripped

 3679 Jon Olav Hauglid	2011-02-18
      Followup to Bug #11752069 (former bug 43152)
      Assertion `bitmap_is_set_all(&table->s->all_set)' failed in
      handler::ha_reset
      
      This patch refactors four my_bitmap functions that were macros
      in non-DEBUG builds and inline functions in DEBUG builds.
      The patch changes them to only have inline function implementations.
      
      This simplifies code, makes non-DEBUG and DEBUG builds more similar
      and removes bug-prone macros.

    modified:
      include/my_bitmap.h
=== modified file 'include/my_bitmap.h'
--- a/include/my_bitmap.h	2011-02-16 16:19:28 +0000
+++ b/include/my_bitmap.h	2011-02-18 14:05:12 +0000
@@ -71,57 +71,34 @@ extern void bitmap_lock_clear_bit(MY_BIT
 #define bitmap_buffer_size(bits) (((bits)+31)/32)*4
 #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) (((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) (uint) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
-                                         & (1 << ((BIT) & 7)))
-/*
-  WARNING!
-
-  The below symbols are inline functions in DEBUG builds and macros in
-  non-DEBUG builds. The latter evaluate their 'bit' argument twice.
-
-  NEVER use an increment/decrement operator with the 'bit' argument.
-  It would work with DEBUG builds, but fails later in production builds!
-
-  FORBIDDEN: bitmap_set_bit($my_bitmap, (field++)->field_index);
-*/
-#ifndef DBUG_OFF
-static inline void
-bitmap_set_bit(MY_BITMAP *map,uint bit)
+
+static inline void bitmap_set_bit(MY_BITMAP *map, uint bit)
 {
-  DBUG_ASSERT(bit < (map)->n_bits);
-  _bitmap_set_bit(map,bit);
+  DBUG_ASSERT(bit < map->n_bits);
+  ((uchar*)map->bitmap)[bit / 8] |= (1 << (bit & 7));
 }
-static inline void
-bitmap_flip_bit(MY_BITMAP *map,uint bit)
+
+
+static inline void bitmap_flip_bit(MY_BITMAP *map, uint bit)
 {
-  DBUG_ASSERT(bit < (map)->n_bits);
-  _bitmap_flip_bit(map,bit);
+  DBUG_ASSERT(bit < map->n_bits);
+  ((uchar*)map->bitmap)[bit / 8] ^= (1 << (bit & 7));
 }
-static inline void
-bitmap_clear_bit(MY_BITMAP *map,uint bit)
+
+
+static inline void bitmap_clear_bit(MY_BITMAP *map, uint bit)
 {
-  DBUG_ASSERT(bit < (map)->n_bits);
-  _bitmap_clear_bit(map,bit);
+  DBUG_ASSERT(bit < map->n_bits);
+  ((uchar*)map->bitmap)[bit / 8] &= ~(1 << (bit & 7));
 }
-static inline uint
-bitmap_is_set(const MY_BITMAP *map,uint bit)
+
+
+static inline my_bool bitmap_is_set(const MY_BITMAP *map, uint bit)
 {
-  DBUG_ASSERT(bit < (map)->n_bits);
-  return _bitmap_is_set(map,bit);
+  DBUG_ASSERT(bit < map->n_bits);
+  return ((uchar*)map->bitmap)[bit / 8] & (1 << (bit & 7));
 }
-#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
+
 
 static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
 {


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20110218140512-5fg5fvi4txfkhrub.bundle
Thread
bzr commit into mysql-trunk branch (jon.hauglid:3679) Bug#11752069Jon Olav Hauglid18 Feb