From: Jon Olav Hauglid Date: February 18 2011 2:05pm Subject: bzr push into mysql-trunk branch (jon.hauglid:3678 to 3679) Bug#11752069 List-Archive: http://lists.mysql.com/commits/131635 X-Bug: 11752069 Message-Id: <201102181407.p1IE7Ft2031769@rcsinet13.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 3678 Alexander Barkov 2011-02-18 [merge] Merging from mysql-trunk === 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) { No bundle (reason: useless for push emails).