mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-20 05:28:21 +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 */
|
* 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) {
|
static __pure_function unsigned log2n(size_t value) {
|
||||||
assert(value > 0 && value < INT32_MAX && is_powerof2(value));
|
assert(value > 0 && value < INT32_MAX && is_powerof2(value));
|
||||||
assert((value & -(int32_t)value) == value);
|
assert((value & -(int32_t)value) == value);
|
||||||
|
@ -1318,3 +1318,14 @@ static __maybe_unused __inline void mdbx_jitter4testing(bool tiny) {
|
|||||||
(void)tiny;
|
(void)tiny;
|
||||||
#endif
|
#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…
x
Reference in New Issue
Block a user