5#ifndef V8_BIGINT_UTIL_H_
6#define V8_BIGINT_UTIL_H_
19#define DIV_CEIL(x, y) (((x)-1) / (y) + 1)
25inline constexpr int RoundUp(
int x,
int y) {
return (
x +
y - 1) & -
y; }
31 requires(std::is_unsigned<T>::value &&
sizeof(
T) == 8)
33#if __GNUC__ || __clang__
34 return value == 0 ? 64 : __builtin_clzll(value);
36 unsigned long index = 0;
37 return _BitScanReverse64(&index, value) ? 63 -
index : 64;
39#error Unsupported compiler.
44#if __GNUC__ || __clang__
45 return value == 0 ? 32 : __builtin_clz(value);
47 unsigned long index = 0;
48 return _BitScanReverse(&index, value) ? 31 -
index : 32;
50#error Unsupported compiler.
55#if __GNUC__ || __clang__
56 return value == 0 ? 32 : __builtin_ctz(value);
58 unsigned long index = 0;
59 return _BitScanForward(&index, value) ?
index : 32;
61#error Unsupported compiler.
70 return value > 0 && (value & (value - 1)) == 0;
constexpr int BitLength(int n)
constexpr int CountTrailingZeros(uint32_t value)
constexpr int CountLeadingZeros(T value)
constexpr bool IsPowerOfTwo(int value)
constexpr int RoundUp(int x, int y)