18 #define HAVE_BITSCAN_FORWARD
19 #define HAVE_BITSCAN_REVERSE
22 #if defined(HAVE__BUILTIN_CTZ)
23 #define HAVE_BITSCAN_FORWARD
26 #if defined(HAVE__BUILTIN_CLZ)
27 #define HAVE_BITSCAN_REVERSE
43 #ifdef HAVE__BUILTIN_CLZ
46 return 31 - __builtin_clz(
word);
47 #elif defined(_MSC_VER)
51 non_zero = _BitScanReverse(&result,
word);
59 while ((
word >> shift) == 0)
73 #ifdef HAVE__BUILTIN_CLZ
76 #if defined(HAVE_LONG_INT_64)
77 return 63 - __builtin_clzl(
word);
78 #elif defined(HAVE_LONG_LONG_INT_64)
79 return 63 - __builtin_clzll(
word);
81 #error must have a working 64-bit integer datatype
84 #elif defined(_MSC_VER)
88 non_zero = _BitScanReverse64(&result,
word);
96 while ((
word >> shift) == 0)
111 #ifdef HAVE__BUILTIN_CTZ
114 return __builtin_ctz(
word);
115 #elif defined(_MSC_VER)
116 unsigned long result;
119 non_zero = _BitScanForward(&result,
word);
127 while ((
word & 255) == 0)
144 #ifdef HAVE__BUILTIN_CTZ
147 #if defined(HAVE_LONG_INT_64)
148 return __builtin_ctzl(
word);
149 #elif defined(HAVE_LONG_LONG_INT_64)
150 return __builtin_ctzll(
word);
152 #error must have a working 64-bit integer datatype
155 #elif defined(_MSC_VER)
156 unsigned long result;
159 non_zero = _BitScanForward64(&result,
word);
167 while ((
word & 255) == 0)
194 if ((num & (num - 1)) == 0)
217 if ((num & (num - 1)) == 0)
281 #if defined(_MSC_VER) && defined(_M_AMD64)
282 #define HAVE_X86_64_POPCNTQ
291 #ifdef HAVE_X86_64_POPCNTQ
292 #if defined(HAVE__GET_CPUID) || defined(HAVE__CPUID)
293 #define TRY_POPCNT_FAST 1
297 #ifdef TRY_POPCNT_FAST
318 return (
word >> n) | (
word << (32 - n));
324 return (
word << n) | (
word >> (32 - n));
329 #if SIZEOF_SIZE_T == 4
330 #define pg_leftmost_one_pos_size_t pg_leftmost_one_pos32
331 #define pg_nextpower2_size_t pg_nextpower2_32
332 #define pg_prevpower2_size_t pg_prevpower2_32
334 #define pg_leftmost_one_pos_size_t pg_leftmost_one_pos64
335 #define pg_nextpower2_size_t pg_nextpower2_64
336 #define pg_prevpower2_size_t pg_prevpower2_64
Assert(fmt[strlen(fmt) - 1] !='\n')
PGDLLIMPORT const uint8 pg_number_of_ones[256]
static uint32 pg_rotate_left32(uint32 word, int n)
static int pg_rightmost_one_pos64(uint64 word)
static uint32 pg_nextpower2_32(uint32 num)
static uint64 pg_ceil_log2_64(uint64 num)
static uint32 pg_rotate_right32(uint32 word, int n)
int pg_popcount64(uint64 word)
int pg_popcount32(uint32 word)
static int pg_rightmost_one_pos32(uint32 word)
static uint64 pg_nextpower2_64(uint64 num)
static int pg_leftmost_one_pos32(uint32 word)
PGDLLIMPORT const uint8 pg_rightmost_one_pos[256]
static uint32 pg_ceil_log2_32(uint32 num)
static uint32 pg_prevpower2_32(uint32 num)
static uint64 pg_prevpower2_64(uint64 num)
uint64 pg_popcount(const char *buf, int bytes)
PGDLLIMPORT const uint8 pg_leftmost_one_pos[256]
static int pg_leftmost_one_pos64(uint64 word)
static void word(struct vars *v, int dir, struct state *lp, struct state *rp)