1#ifndef _utilities_h_INCLUDED
2#define _utilities_h_INCLUDED
11static inline int __builtin_clz(
unsigned x) {
13 _BitScanReverse(&r, x);
17static inline int __builtin_clzll(
unsigned long long x) {
20 _BitScanReverse64(&r, x);
23 int l = __builtin_clz((
unsigned)x) + 32;
24 int h = __builtin_clz((
unsigned)(x >> 32));
25 return !!((unsigned)(x >> 32)) ? h : l;
29static inline int __builtin_clzl(
unsigned long x) {
30 return sizeof(x) == 8 ? __builtin_clzll(x) : __builtin_clz((
unsigned)x);
40#define WORD_ALIGNMENT_MASK (sizeof (word) - 1)
41#define W2RD_ALIGNMENT_MASK (sizeof (w2rd) - 1)
43#define WORD_FORMAT PRIuPTR
45#define MAX_SIZE_T (~(size_t) 0)
47#define ASSUMED_LD_CACHE_LINE_BYTES 7u
49static inline word kissat_cache_lines (
word n,
size_t size) {
58 const word mask = (((
word) 1) << shift) - 1;
59 const word masked = n + mask;
60 const word res = masked >> shift;
64static inline double kissat_average (
double a,
double b) {
65 return b ? a / b : 0.0;
68static inline double kissat_percent (
double a,
double b) {
69 return kissat_average (100.0 * a, b);
72static inline bool kissat_aligned_word (
word word) {
76static inline bool kissat_aligned_pointer (
const void *
p) {
77 return kissat_aligned_word ((
word)
p);
80static inline word kissat_align_word (
word w) {
87static inline word kissat_align_w2rd (
word w) {
96static inline bool kissat_is_power_of_two (uint64_t w) {
97 return w && !(w & (w - 1));
100static inline bool kissat_is_zero_or_power_of_two (
word w) {
101 return !(w & (w - 1));
104static inline unsigned kissat_leading_zeroes_of_unsigned (
unsigned x) {
105 return x ? __builtin_clz (x) : sizeof (unsigned) * 8;
108static inline unsigned kissat_leading_zeroes_of_word (
word x) {
110 return sizeof (
word) * 8;
111 if (
sizeof (
word) ==
sizeof (
unsigned long long))
112 return __builtin_clzll (x);
113 if (
sizeof (
word) ==
sizeof (
unsigned long))
114 return __builtin_clzl (x);
115 return __builtin_clz (x);
118static inline unsigned kissat_log2_floor_of_word (
word x) {
119 return x ?
sizeof (
word) * 8 - 1 - kissat_leading_zeroes_of_word (x) : 0;
122static inline unsigned kissat_log2_ceiling_of_word (
word x) {
125 unsigned tmp = kissat_log2_floor_of_word (x);
126 return tmp + !!(x ^ (((
word) 1) << tmp));
129static inline unsigned kissat_leading_zeroes_of_uint64 (uint64_t x) {
131 return sizeof (uint64_t) * 8;
132 if (
sizeof (uint64_t) ==
sizeof (
unsigned long long))
133 return __builtin_clzll (x);
134 if (
sizeof (uint64_t) ==
sizeof (
unsigned long))
135 return __builtin_clzl (x);
136 return __builtin_clz (x);
139static inline unsigned kissat_log2_floor_of_uint64 (uint64_t x) {
140 return x ?
sizeof (uint64_t) * 8 - 1 - kissat_leading_zeroes_of_uint64 (x)
144static inline unsigned kissat_log2_ceiling_of_uint64 (uint64_t x) {
147 unsigned tmp = kissat_log2_floor_of_uint64 (x);
148 return tmp + !!(x ^ (((uint64_t) 1) << tmp));
151#define SWAP(TYPE, A, B) \
153 TYPE TMP_SWAP = (A); \
158#define MIN(A, B) ((A) > (B) ? (B) : (A))
160#define MAX(A, B) ((A) < (B) ? (B) : (A))
162#define ABS(A) (KISSAT_assert ((int) (A) != INT_MIN), (A) < 0 ? -(A) : (A))
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
#define KISSAT_assert(ignore)
unsigned __int64 word
DECLARATIONS ///.
ABC_NAMESPACE_HEADER_START typedef uintptr_t w2rd[2]
#define WORD_ALIGNMENT_MASK
#define W2RD_ALIGNMENT_MASK
#define ASSUMED_LD_CACHE_LINE_BYTES
bool kissat_has_suffix(const char *str, const char *suffix)