diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2017-02-01 21:27:13 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2017-02-01 21:27:13 +0000 |
commit | 5875633c2a78fdb2db4ac621b093730962bc1f4d (patch) | |
tree | 40836774fe76d2a4a01ae0b2c9ea4c1b980d057e /include/my_bit.h | |
parent | 13c7839ba72d7b88767dbb016e8d60114e49c377 (diff) | |
download | mariadb-git-5875633c2a78fdb2db4ac621b093730962bc1f4d.tar.gz |
MDEV-11901 : MariaRocks on Windows
fixed compilation, disabled unix-only tests (the ones that use bash
etc).
Changed plugin library name to ha_rocksdb.dll/so
Diffstat (limited to 'include/my_bit.h')
-rw-r--r-- | include/my_bit.h | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/include/my_bit.h b/include/my_bit.h index a50403c312d..218829ba747 100644 --- a/include/my_bit.h +++ b/include/my_bit.h @@ -25,7 +25,6 @@ C_MODE_START -extern const char _my_bits_nbits[256]; extern const uchar _my_bits_reverse_table[256]; /* @@ -40,37 +39,32 @@ static inline uint my_bit_log2(ulong value) return bit; } -static inline uint my_count_bits(ulonglong v) + +/* +Count bits in 32bit integer + + Algorithm by Sean Anderson, according to: + http://graphics.stanford.edu/~seander/bithacks.html + under "Counting bits set, in parallel" + + (Orignal code public domain). +*/ +static inline uint my_count_bits_uint32(uint32 v) { -#if SIZEOF_LONG_LONG > 4 - /* The following code is a bit faster on 16 bit machines than if we would - only shift v */ - ulong v2=(ulong) (v >> 32); - return (uint) (uchar) (_my_bits_nbits[(uchar) v] + - _my_bits_nbits[(uchar) (v >> 8)] + - _my_bits_nbits[(uchar) (v >> 16)] + - _my_bits_nbits[(uchar) (v >> 24)] + - _my_bits_nbits[(uchar) (v2)] + - _my_bits_nbits[(uchar) (v2 >> 8)] + - _my_bits_nbits[(uchar) (v2 >> 16)] + - _my_bits_nbits[(uchar) (v2 >> 24)]); -#else - return (uint) (uchar) (_my_bits_nbits[(uchar) v] + - _my_bits_nbits[(uchar) (v >> 8)] + - _my_bits_nbits[(uchar) (v >> 16)] + - _my_bits_nbits[(uchar) (v >> 24)]); -#endif + v = v - ((v >> 1) & 0x55555555); + v = (v & 0x33333333) + ((v >> 2) & 0x33333333); + return (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; } -static inline uint my_count_bits_uint32(uint32 v) + +static inline uint my_count_bits(ulonglong x) { - return (uint) (uchar) (_my_bits_nbits[(uchar) v] + - _my_bits_nbits[(uchar) (v >> 8)] + - _my_bits_nbits[(uchar) (v >> 16)] + - _my_bits_nbits[(uchar) (v >> 24)]); + return my_count_bits_uint32((uint32)x) + my_count_bits_uint32((uint32)(x >> 32)); } + + /* Next highest power of two |