~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/my_bit.h

  • Committer: Monty Taylor
  • Date: 2008-07-05 10:49:39 UTC
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: monty@inaugust.com-20080705104939-72e6upltbm3aq0lw
Changes so that client/ builds cleanly with no warnings.
Commented out -Wunreachable-code for now, because there is too much of it
with all the #ifdef'd members. We'll add it back in for a second pass over
the code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
  This can be used to divide a number with value by doing a shift instead
14
14
*/
15
15
 
16
 
STATIC_INLINE uint my_bit_log2(ulong value)
 
16
static inline uint my_bit_log2(ulong value)
17
17
{
18
18
  uint bit;
19
19
  for (bit=0 ; value > 1 ; value>>=1, bit++) ;
20
20
  return bit;
21
21
}
22
22
 
23
 
STATIC_INLINE uint my_count_bits(ulonglong v)
 
23
static inline uint my_count_bits(ulonglong v)
24
24
{
25
25
#if SIZEOF_LONG_LONG > 4
26
26
  /* The following code is a bit faster on 16 bit machines than if we would
42
42
#endif
43
43
}
44
44
 
45
 
STATIC_INLINE uint my_count_bits_ushort(ushort v)
 
45
static inline uint my_count_bits_ushort(ushort v)
46
46
{
47
47
  return _my_bits_nbits[v];
48
48
}
67
67
    Comments shows how this works with 01100000000000000000000000001011
68
68
*/
69
69
 
70
 
STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v)
 
70
static inline uint32 my_round_up_to_next_power(uint32 v)
71
71
{
72
72
  v--;                  /* 01100000000000000000000000001010 */
73
73
  v|= v >> 1;           /* 01110000000000000000000000001111 */
78
78
  return v+1;           /* 10000000000000000000000000000000 */
79
79
}
80
80
 
81
 
STATIC_INLINE uint32 my_clear_highest_bit(uint32 v)
 
81
static inline uint32 my_clear_highest_bit(uint32 v)
82
82
{
83
83
  uint32 w=v >> 1;
84
84
  w|= w >> 1;
89
89
  return v & w;
90
90
}
91
91
 
92
 
STATIC_INLINE uint32 my_reverse_bits(uint32 key)
 
92
static inline uint32 my_reverse_bits(uint32 key)
93
93
{
94
94
  return
95
95
    (_my_bits_reverse_table[ key      & 255] << 24) |