mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +08:00
mdbx: move is_powerof2() and roundup_powerof2() into header.
This commit is contained in:
parent
e475db7ade
commit
6009bac1ed
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user