~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_create.cc

  • Committer: Mark Atwood
  • Date: 2011-09-14 03:30:42 UTC
  • mfrom: (2409.2.6 refactor7)
  • Revision ID: me@mark.atwood.name-20110914033042-2u0s8foaigvf62g2
mergeĀ lp:~olafvdspek/drizzle/refactor7

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
using namespace drizzled;
31
31
 
32
32
/*
 
33
  Next highest power of two
 
34
 
 
35
  SYNOPSIS
 
36
    my_round_up_to_next_power()
 
37
    v           Value to check
 
38
 
 
39
  RETURN
 
40
    Next or equal power of 2
 
41
    Note: 0 will return 0
 
42
 
 
43
  NOTES
 
44
    Algorithm by Sean Anderson, according to:
 
45
    http://graphics.stanford.edu/~seander/bithacks.html
 
46
    (Orignal code public domain)
 
47
 
 
48
    Comments shows how this works with 01100000000000000000000000001011
 
49
*/
 
50
 
 
51
static inline uint32_t my_round_up_to_next_power(uint32_t v)
 
52
{
 
53
  v--;                  /* 01100000000000000000000000001010 */
 
54
  v|= v >> 1;           /* 01110000000000000000000000001111 */
 
55
  v|= v >> 2;           /* 01111100000000000000000000001111 */
 
56
  v|= v >> 4;           /* 01111111110000000000000000001111 */
 
57
  v|= v >> 8;           /* 01111111111111111100000000001111 */
 
58
  v|= v >> 16;          /* 01111111111111111111111111111111 */
 
59
  return v+1;           /* 10000000000000000000000000000000 */
 
60
}
 
61
 
 
62
/*
33
63
  Old options is used when recreating database, from myisamchk
34
64
*/
35
65