List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:February 18 2011 12:10pm
Subject:Re: bzr commit into mysql-trunk branch (jon.hauglid:3672) Bug#11752069
View as plain text  
LGTM

On Thu, Feb 17, 2011 at 6:09 PM, Jon Olav Hauglid <jon.hauglid@stripped>wrote:

> #At file:///export/home/x/mysql-trunk-bug11752069_refactor/ based on
> revid:tor.didriksen@stripped
>
>  3672 Jon Olav Hauglid  2011-02-17
>      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-17 17:09:47 +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)
>  {
>
>
>
> --
> MySQL Code Commits Mailing List
> For list archives: http://lists.mysql.com/commits
> To unsubscribe:
> http://lists.mysql.com/commits?unsub=1
>

Thread
bzr commit into mysql-trunk branch (jon.hauglid:3672) Bug#11752069Jon Olav Hauglid17 Feb
  • Re: bzr commit into mysql-trunk branch (jon.hauglid:3672) Bug#11752069Tor Didriksen18 Feb