mdbx: move is_powerof2() and roundup_powerof2() into header.

This commit is contained in:
Leonid Yuriev 2020-02-02 20:41:04 +03:00
parent e475db7ade
commit 6009bac1ed
2 changed files with 11 additions and 10 deletions

View File

@ -40,16 +40,6 @@
/*------------------------------------------------------------------------------
* Internal inlines */
static __pure_function __always_inline bool is_powerof2(size_t x) {
return (x & (x - 1)) == 0;
}
static __pure_function __always_inline size_t
roundup_powerof2(size_t value, size_t granularity) {
assert(is_powerof2(granularity));
return (value + granularity - 1) & ~(granularity - 1);
}
static __pure_function unsigned log2n(size_t value) {
assert(value > 0 && value < INT32_MAX && is_powerof2(value));
assert((value & -(int32_t)value) == value);

View File

@ -1318,3 +1318,14 @@ static __maybe_unused __inline void mdbx_jitter4testing(bool tiny) {
(void)tiny;
#endif
}
static __pure_function __always_inline __maybe_unused bool
is_powerof2(size_t x) {
return (x & (x - 1)) == 0;
}
static __pure_function __always_inline __maybe_unused size_t
roundup_powerof2(size_t value, size_t granularity) {
assert(is_powerof2(granularity));
return (value + granularity - 1) & ~(granularity - 1);
}