From 55f41f40a14f63b6efab516f2cd7fefe43d9668d Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sat, 24 Apr 2021 14:07:15 +0300 Subject: [PATCH] mdbx: rename `log2n_powerof2()`. Change-Id: I22290630186c5041b6ae242d0db1f5c5f36da4ec --- src/core.c | 6 +++--- src/internals.h | 3 ++- src/osal.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core.c b/src/core.c index a836afd1..72b727a5 100644 --- a/src/core.c +++ b/src/core.c @@ -417,7 +417,7 @@ static __inline size_t valsize_max(size_t pagesize, MDBX_db_flags_t flags) { if (flags & (MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_REVERSEDUP)) return keysize_max(pagesize, 0); - const unsigned page_ln2 = log2n(pagesize); + const unsigned page_ln2 = log2n_powerof2(pagesize); const size_t hard = 0x7FF00000ul; const size_t hard_pages = hard >> page_ln2; STATIC_ASSERT(MDBX_PGL_LIMIT <= MAX_PAGENO); @@ -10472,7 +10472,7 @@ static void __cold mdbx_setup_pagesize(MDBX_env *env, const size_t pagesize) { leaf_nodemax >= branch_nodemax && leaf_nodemax < (int)UINT16_MAX && leaf_nodemax % 2 == 0); env->me_leaf_nodemax = (unsigned)leaf_nodemax; - env->me_psize2log = (uint8_t)log2n(pagesize); + env->me_psize2log = (uint8_t)log2n_powerof2(pagesize); mdbx_assert(env, pgno2bytes(env, 1) == pagesize); mdbx_assert(env, bytes2pgno(env, pagesize + pagesize) == 2); @@ -11646,7 +11646,7 @@ __cold int mdbx_is_readahead_reasonable(size_t volume, intptr_t redundancy) { if (unlikely(err != MDBX_SUCCESS)) return err; - const int log2page = log2n(pagesize); + const int log2page = log2n_powerof2(pagesize); const intptr_t volume_pages = (volume + pagesize - 1) >> log2page; const intptr_t redundancy_pages = (redundancy < 0) ? -(intptr_t)((-redundancy + pagesize - 1) >> log2page) diff --git a/src/internals.h b/src/internals.h index 192e9607..33962ec3 100644 --- a/src/internals.h +++ b/src/internals.h @@ -1568,7 +1568,8 @@ ceil_powerof2(size_t value, size_t granularity) { return floor_powerof2(value + granularity - 1, granularity); } -MDBX_NOTHROW_CONST_FUNCTION static __maybe_unused unsigned log2n(size_t value) { +MDBX_NOTHROW_CONST_FUNCTION static __maybe_unused unsigned +log2n_powerof2(size_t value) { assert(value > 0 && value < INT32_MAX && is_powerof2(value)); assert((value & -(int32_t)value) == value); #if __GNUC_PREREQ(4, 1) || __has_builtin(__builtin_ctzl) diff --git a/src/osal.c b/src/osal.c index ac6dba88..0f03b850 100644 --- a/src/osal.c +++ b/src/osal.c @@ -2409,7 +2409,7 @@ __cold int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages, if (unlikely(pagesize < MIN_PAGESIZE || !is_powerof2(pagesize))) return MDBX_INCOMPATIBLE; - __maybe_unused const int log2page = log2n(pagesize); + __maybe_unused const int log2page = log2n_powerof2(pagesize); assert(pagesize == (INT64_C(1) << log2page)); (void)log2page;