~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to include/my_bitmap.h

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
 
1
/*
 
2
   Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
#ifndef _my_bitmap_h_
17
19
#define _my_bitmap_h_
149
151
 
150
152
static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
151
153
{
152
 
  *(map1)->last_word_ptr|= (map1)->last_word_mask;
153
 
  *(map2)->last_word_ptr|= (map2)->last_word_mask;
154
 
  return memcmp((map1)->bitmap, (map2)->bitmap, 4*no_words_in_map((map1)))==0;
 
154
  if (memcmp(map1->bitmap, map2->bitmap, 4*(no_words_in_map(map1)-1)) != 0)
 
155
    return FALSE;
 
156
  return ((*map1->last_word_ptr | map1->last_word_mask) ==
 
157
          (*map2->last_word_ptr | map2->last_word_mask));
155
158
}
156
159
 
157
160
#define bitmap_clear_all(MAP) \
159
162
#define bitmap_set_all(MAP) \
160
163
  (memset((MAP)->bitmap, 0xFF, 4*no_words_in_map((MAP))))
161
164
 
162
 
/**
163
 
   check, set and clear a bit of interest of an integer.
164
 
 
165
 
   If the bit is out of range @retval -1. Otherwise
166
 
   bit_is_set   @return 0 or 1 reflecting the bit is set or not;
167
 
   bit_do_set   @return 1 (bit is set 1)
168
 
   bit_do_clear @return 0 (bit is cleared to 0)
169
 
*/
170
 
 
171
 
#define bit_is_set(I,B)   (sizeof(I) * CHAR_BIT > (B) ?                 \
172
 
                           (((I) & (ULL(1) << (B))) == 0 ? 0 : 1) : -1)
173
 
#define bit_do_set(I,B)   (sizeof(I) * CHAR_BIT > (B) ?         \
174
 
                           ((I) |= (ULL(1) << (B)), 1) : -1)
175
 
#define bit_do_clear(I,B) (sizeof(I) * CHAR_BIT > (B) ?         \
176
 
                           ((I) &= ~(ULL(1) << (B)), 0) : -1)
177
 
 
178
165
#ifdef  __cplusplus
179
166
}
180
167
#endif