#include <type_traits>
-#ifndef DIV_ROUND_UP
-#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
-#endif
-
template<typename T, typename U>
constexpr inline std::make_unsigned_t<std::common_type_t<T, U>> div_round_up(T n, U d) {
return (n + d - 1) / d;
}
-#ifndef ROUND_UP_TO
-#define ROUND_UP_TO(n, d) ((n)%(d) ? ((n)+(d)-(n)%(d)) : (n))
-#endif
-
template<typename T, typename U>
constexpr inline std::make_unsigned_t<std::common_type_t<T, U>> round_up_to(T n, U d) {
return (n % d ? (n + d - n % d) : n);
}
-#ifndef SHIFT_ROUND_UP
-#define SHIFT_ROUND_UP(x,y) (((x)+(1<<(y))-1) >> (y))
-#endif
-
template<typename T, typename U>
constexpr inline std::make_unsigned_t<std::common_type_t<T, U>> shift_round_up(T x, U y) {
return (x + (1 << y) - 1) >> y;
assert(min_alloc_size && isp2(min_alloc_size));
assert(mem_cap);
- total = ROUND_UP_TO(total, min_alloc_size);
+ total = round_up_to(total, min_alloc_size);
granularity = total * BLOOM_FILTER_TABLE_SIZE * 2 / mem_cap;
if (!granularity) {
granularity = min_alloc_size;
} else {
- granularity = ROUND_UP_TO(granularity, min_alloc_size);
+ granularity = round_up_to(granularity, min_alloc_size);
}
uint64_t entries = p2roundup(total, granularity) / granularity;