From f82cf6a4b360a8a35438bd105ff403fc7d2c7b26 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: Sat, 17 May 2025 14:36:57 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=20=D0=B4=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B8=20`=5FFILE=5FOFFSET=5FBITS`=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20Android.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/essentials.h | 8 -------- src/lck-posix.c | 9 +++++---- src/osal.h | 7 +++++++ src/preface.h | 13 ++++++++----- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/essentials.h b/src/essentials.h index 7a76b27c..a48ac86f 100644 --- a/src/essentials.h +++ b/src/essentials.h @@ -28,14 +28,6 @@ typedef struct iov_ctx iov_ctx_t; #include "osal.h" -#if UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul || defined(_WIN64) -#define MDBX_WORDBITS 64 -#define MDBX_WORDBITS_LN2 6 -#else -#define MDBX_WORDBITS 32 -#define MDBX_WORDBITS_LN2 5 -#endif /* MDBX_WORDBITS */ - #include "options.h" #include "atomics-types.h" diff --git a/src/lck-posix.c b/src/lck-posix.c index 1fb502a1..7d728eb1 100644 --- a/src/lck-posix.c +++ b/src/lck-posix.c @@ -93,10 +93,11 @@ __cold static void choice_fcntl(void) { static int lck_op(const mdbx_filehandle_t fd, int cmd, const int lck, const off_t offset, off_t len) { STATIC_ASSERT(sizeof(off_t) >= sizeof(void *) && sizeof(off_t) >= sizeof(size_t)); -#ifdef __ANDROID_API__ - STATIC_ASSERT_MSG((sizeof(off_t) * 8 == MDBX_WORDBITS), "The bitness of system `off_t` type is mismatch. Please " - "fix build and/or NDK configuration."); -#endif /* Android */ +#if defined(__ANDROID_API__) && __ANDROID_API__ < 24 + STATIC_ASSERT_MSG((sizeof(off_t) * CHAR_BIT == MDBX_WORDBITS), + "The bitness of system `off_t` type is mismatch. Please " + "fix build and/or NDK configuration."); +#endif /* Android && API < 24 */ assert(offset >= 0 && len > 0); assert((uint64_t)offset < (uint64_t)INT64_MAX && (uint64_t)len < (uint64_t)INT64_MAX && (uint64_t)(offset + len) > (uint64_t)offset); diff --git a/src/osal.h b/src/osal.h index 06f58c60..b286f037 100644 --- a/src/osal.h +++ b/src/osal.h @@ -193,7 +193,14 @@ typedef struct osal_mmap { #elif defined(__ANDROID_API__) #if __ANDROID_API__ < 24 +/* https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html + * https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */ #define MDBX_HAVE_PWRITEV 0 +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS != MDBX_WORDBITS +#error "_FILE_OFFSET_BITS != MDBX_WORDBITS and __ANDROID_API__ < 24" (_FILE_OFFSET_BITS != MDBX_WORDBITS) +#elif defined(__FILE_OFFSET_BITS) && __FILE_OFFSET_BITS != MDBX_WORDBITS +#error "__FILE_OFFSET_BITS != MDBX_WORDBITS and __ANDROID_API__ < 24" (__FILE_OFFSET_BITS != MDBX_WORDBITS) +#endif #else #define MDBX_HAVE_PWRITEV 1 #endif diff --git a/src/preface.h b/src/preface.h index 5f43b67e..85e59830 100644 --- a/src/preface.h +++ b/src/preface.h @@ -433,11 +433,6 @@ __extern_C key_t ftok(const char *, int); #if __ANDROID_API__ >= 21 #include #endif -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS != MDBX_WORDBITS -#error "_FILE_OFFSET_BITS != MDBX_WORDBITS" (_FILE_OFFSET_BITS != MDBX_WORDBITS) -#elif defined(__FILE_OFFSET_BITS) && __FILE_OFFSET_BITS != MDBX_WORDBITS -#error "__FILE_OFFSET_BITS != MDBX_WORDBITS" (__FILE_OFFSET_BITS != MDBX_WORDBITS) -#endif #endif /* Android */ #if defined(HAVE_SYS_STAT_H) || __has_include() @@ -522,6 +517,14 @@ __extern_C key_t ftok(const char *, int); #endif #endif /* __BYTE_ORDER__ || __ORDER_LITTLE_ENDIAN__ || __ORDER_BIG_ENDIAN__ */ +#if UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul || defined(_WIN64) +#define MDBX_WORDBITS 64 +#define MDBX_WORDBITS_LN2 6 +#else +#define MDBX_WORDBITS 32 +#define MDBX_WORDBITS_LN2 5 +#endif /* MDBX_WORDBITS */ + /*----------------------------------------------------------------------------*/ /* Availability of CMOV or equivalent */