17 #ifndef CS_LLVM_SUPPORT_MATHEXTRAS_H
18 #define CS_LLVM_SUPPORT_MATHEXTRAS_H
20 #if defined(_WIN32_WCE) && (_WIN32_WCE < 0x800)
22 #elif defined(_MSC_VER)
27 #if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
49 return x == (
x & (~0ULL >> (64 -
N)));
62 return Value && ((Value + 1) & Value) == 0;
69 return Value && ((Value + 1) & Value) == 0;
88 return Value && !(Value & (Value - 1));
99 #if !defined(__ppc__) && !defined(__ppc64__)
100 if (!Value)
return 32;
102 Count = __builtin_clz(Value);
105 if (!Value)
return 32;
108 for (Shift = 32 >> 1; Shift; Shift >>= 1) {
136 #if !defined(__ppc__) && !defined(__ppc64__)
137 if (!Value)
return 64;
139 Count = __builtin_clzll(Value);
143 if (
sizeof(
long) ==
sizeof(
int64_t))
145 if (!Value)
return 64;
148 for (Shift = 64 >> 1; Shift; Shift >>= 1) {
192 return Value ? __builtin_ctz(Value) : 32;
194 static const unsigned Mod37BitPosition[] = {
195 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13,
196 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9,
202 return Mod37BitPosition[((1 + ~Value) & Value) % 37];
220 return Value ? __builtin_ctzll(Value) : 64;
222 static const unsigned Mod67Position[] = {
223 64, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 59, 41, 19, 24, 54,
224 4, 64, 13, 10, 17, 62, 60, 28, 42, 30, 20, 51, 25, 44, 55,
225 47, 5, 32, 65, 38, 14, 22, 11, 58, 18, 53, 63, 9, 61, 27,
226 29, 50, 43, 46, 31, 37, 21, 57, 52, 8, 26, 49, 45, 36, 56,
227 7, 48, 35, 6, 34, 33, 0
232 return Mod67Position[((1 + ~Value) & Value) % 67];
249 return __builtin_popcount(Value);
251 uint32_t v = Value - ((Value >> 1) & 0x55555555);
252 v = (
v & 0x33333333) + ((
v >> 2) & 0x33333333);
253 return (((
v + (
v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
261 return __builtin_popcountll(Value);
263 uint64_t v = Value - ((Value >> 1) & 0x5555555555555555ULL);
264 v = (
v & 0x3333333333333333ULL) + ((
v >> 2) & 0x3333333333333333ULL);
265 v = (
v + (
v >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
266 return (
uint64_t)((
v * 0x0101010101010101ULL) >> 56);
363 return (
A |
B) & (1 + ~(
A |
B));
388 return ((Value + Align - 1) / Align) * Align;
402 return (
x < 0) ? -
x :
x;
427 const unsigned bits =
sizeof(
x) * 8;
int bits(struct state *s, int need)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count