19 return (
int)num_bits_on[x];
27 #if defined(__GNUC__) && defined(__POPCNT__) 28 return __builtin_popcount((
unsigned int) x);
30 return (
int)num_bits_on[x & 0xffff] + (int)num_bits_on[(x >> 16) & 0xffff];
39 #if defined(__GNUC__) && defined(__POPCNT__) 40 return __builtin_popcountll((
unsigned long long) x);
130 #if defined(_MSC_VER) 131 unsigned long result;
132 return (_BitScanForward(&result, (
unsigned long) x) == 0) ? -1 : result;
133 #elif defined(__GNUC__) 134 return __builtin_ffs((
int) x) - 1;
140 uint16_t w = (x & (~x + 1));
141 return (
int)num_bits_on[w - 1];
151 #if defined(_MSC_VER) 152 unsigned long result;
153 return (_BitScanForward(&result, (
unsigned long) x) == 0) ? -1 : result;
154 #elif defined(__GNUC__) 155 return __builtin_ffs((
int) x) - 1;
161 uint32_t w = (x & (~x + 1));
172 #if defined(_MSC_VER) && defined(_M_X64) 173 unsigned long result;
174 return (_BitScanForward64(&result, (
unsigned __int64) x) == 0) ? -1 : result;
175 #elif defined(__GNUC__) 176 return __builtin_ffsll((
long long) x) - 1;
182 uint64_t w = (x & (~x + 1));
193 #if defined(_MSC_VER) 194 unsigned long result;
195 return (_BitScanReverse(&result, (
unsigned long) x) == 0) ? -1 : result;
196 #elif defined(__GNUC__) 197 return (x == 0) ? -1 : 31 - __builtin_clz((
unsigned int) x);
210 #if defined(_MSC_VER) 211 unsigned long result;
212 return (_BitScanReverse(&result, (
unsigned long) x) == 0) ? -1 : result;
213 #elif defined(__GNUC__) 214 return (x == 0) ? -1 : 31 - __builtin_clz((
unsigned int) x);
227 #if defined(_MSC_VER) && defined(_M_X64) 228 unsigned long result;
229 return (_BitScanReverse64(&result, (
unsigned __int64) x) == 0) ? -1 : result;
230 #elif defined(__GNUC__) 231 return (x == 0) ? -1 : 63 - __builtin_clzll((
unsigned long long) x);
int get_next_higher_bit(uint16_t x)
Returns the smallest power of 2 greater than x.
int count_bits_in_word(uint16_t x)
Returns the number of 1 bits in the indicated word.
uint16_t flood_bits_down(uint16_t x)
Returns a value such that every bit at or below the highest bit in x is 1.
int get_highest_on_bit(uint16_t x)
Returns the index of the highest 1 bit in the word.
uint16_t flood_bits_up(uint16_t x)
Returns a value such that every bit at or above the highest bit in x is 1.
int get_lowest_on_bit(uint16_t x)
Returns the index of the lowest 1 bit in the word.