From 4607184999437a29ffbc8acae446401c7ade44d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Tue, 17 Dec 2024 18:52:08 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=BC=D0=B0=D0=BA=D1=80=D0=BE=D1=81=20?= =?UTF-8?q?`osal=5Fmalloc=5Fusable=5Fsize()`=20=D0=B2=D0=BC=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=BE=20=D0=BD=D0=B5=D0=BF=D0=BE=D1=81=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D0=B5=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20`malloc=5Fusable=5Fsize()`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dpl.c | 6 +++--- src/osal.h | 8 ++++---- src/pnl.c | 18 +++++++++--------- src/txl.c | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/dpl.c b/src/dpl.c index 6055ea7b..8e0c5dab 100644 --- a/src/dpl.c +++ b/src/dpl.c @@ -41,9 +41,9 @@ dpl_t *dpl_reserve(MDBX_txn *txn, size_t size) { size_t bytes = dpl_size2bytes((size < PAGELIST_LIMIT) ? size : PAGELIST_LIMIT); dpl_t *const dl = osal_realloc(txn->tw.dirtylist, bytes); if (likely(dl)) { -#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size) - bytes = malloc_usable_size(dl); -#endif /* malloc_usable_size */ +#ifdef osal_malloc_usable_size + bytes = osal_malloc_usable_size(dl); +#endif /* osal_malloc_usable_size */ dl->detent = dpl_bytes2size(bytes); tASSERT(txn, txn->tw.dirtylist == nullptr || dl->length <= dl->detent); txn->tw.dirtylist = dl; diff --git a/src/osal.h b/src/osal.h index 5a049a24..c82f8af1 100644 --- a/src/osal.h +++ b/src/osal.h @@ -153,12 +153,12 @@ typedef pthread_mutex_t osal_fastmutex_t; #endif /* Platform */ #if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size) -/* malloc_usable_size() already provided */ +#define osal_malloc_usable_size(ptr) malloc_usable_size(ptr) #elif defined(__APPLE__) -#define malloc_usable_size(ptr) malloc_size(ptr) +#define osal_malloc_usable_size(ptr) malloc_size(ptr) #elif defined(_MSC_VER) && !MDBX_WITHOUT_MSVC_CRT -#define malloc_usable_size(ptr) _msize(ptr) -#endif /* malloc_usable_size */ +#define osal_malloc_usable_size(ptr) _msize(ptr) +#endif /* osal_malloc_usable_size */ /*----------------------------------------------------------------------------*/ /* OS abstraction layer stuff */ diff --git a/src/pnl.c b/src/pnl.c index d40fe7e5..9ad5f9bd 100644 --- a/src/pnl.c +++ b/src/pnl.c @@ -7,9 +7,9 @@ MDBX_INTERNAL pnl_t pnl_alloc(size_t size) { size_t bytes = pnl_size2bytes(size); pnl_t pnl = osal_malloc(bytes); if (likely(pnl)) { -#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size) - bytes = malloc_usable_size(pnl); -#endif /* malloc_usable_size */ +#ifdef osal_malloc_usable_size + bytes = osal_malloc_usable_size(pnl); +#endif /* osal_malloc_usable_size */ pnl[0] = pnl_bytes2size(bytes); assert(pnl[0] >= size); pnl += 1; @@ -33,9 +33,9 @@ MDBX_INTERNAL void pnl_shrink(pnl_t __restrict *__restrict ppnl) { size_t bytes = pnl_size2bytes(MDBX_PNL_INITIAL * 2); pnl_t pnl = osal_realloc(*ppnl - 1, bytes); if (likely(pnl)) { -#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size) - bytes = malloc_usable_size(pnl); -#endif /* malloc_usable_size */ +#ifdef osal_malloc_usable_size + bytes = osal_malloc_usable_size(pnl); +#endif /* osal_malloc_usable_size */ *pnl = pnl_bytes2size(bytes); *ppnl = pnl + 1; } @@ -57,9 +57,9 @@ MDBX_INTERNAL int pnl_reserve(pnl_t __restrict *__restrict ppnl, const size_t wa size_t bytes = pnl_size2bytes(size); pnl_t pnl = osal_realloc(*ppnl - 1, bytes); if (likely(pnl)) { -#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size) - bytes = malloc_usable_size(pnl); -#endif /* malloc_usable_size */ +#ifdef osal_malloc_usable_size + bytes = osal_malloc_usable_size(pnl); +#endif /* osal_malloc_usable_size */ *pnl = pnl_bytes2size(bytes); assert(*pnl >= wanna); *ppnl = pnl + 1; diff --git a/src/txl.c b/src/txl.c index 024b099f..d2296740 100644 --- a/src/txl.c +++ b/src/txl.c @@ -21,9 +21,9 @@ MDBX_INTERNAL txl_t txl_alloc(void) { size_t bytes = txl_size2bytes(txl_initial); txl_t txl = osal_malloc(bytes); if (likely(txl)) { -#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size) - bytes = malloc_usable_size(txl); -#endif /* malloc_usable_size */ +#ifdef osal_malloc_usable_size + bytes = osal_malloc_usable_size(txl); +#endif /* osal_malloc_usable_size */ txl[0] = txl_bytes2size(bytes); assert(txl[0] >= txl_initial); txl += 1; @@ -52,9 +52,9 @@ MDBX_INTERNAL int txl_reserve(txl_t __restrict *__restrict ptxl, const size_t wa size_t bytes = txl_size2bytes(size); txl_t txl = osal_realloc(*ptxl - 1, bytes); if (likely(txl)) { -#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size) - bytes = malloc_usable_size(txl); -#endif /* malloc_usable_size */ +#ifdef osal_malloc_usable_size + bytes = osal_malloc_usable_size(txl); +#endif /* osal_malloc_usable_size */ *txl = txl_bytes2size(bytes); assert(*txl >= wanna); *ptxl = txl + 1;