mdbx: перемещение и доработка проверки _FILE_OFFSET_BITS для Android.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2025-05-17 14:36:57 +03:00
parent 60c0483987
commit f82cf6a4b3
4 changed files with 20 additions and 17 deletions

View File

@ -28,14 +28,6 @@
typedef struct iov_ctx iov_ctx_t; typedef struct iov_ctx iov_ctx_t;
#include "osal.h" #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 "options.h"
#include "atomics-types.h" #include "atomics-types.h"

View File

@ -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 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)); STATIC_ASSERT(sizeof(off_t) >= sizeof(void *) && sizeof(off_t) >= sizeof(size_t));
#ifdef __ANDROID_API__ #if defined(__ANDROID_API__) && __ANDROID_API__ < 24
STATIC_ASSERT_MSG((sizeof(off_t) * 8 == MDBX_WORDBITS), "The bitness of system `off_t` type is mismatch. Please " STATIC_ASSERT_MSG((sizeof(off_t) * CHAR_BIT == MDBX_WORDBITS),
"fix build and/or NDK configuration."); "The bitness of system `off_t` type is mismatch. Please "
#endif /* Android */ "fix build and/or NDK configuration.");
#endif /* Android && API < 24 */
assert(offset >= 0 && len > 0); assert(offset >= 0 && len > 0);
assert((uint64_t)offset < (uint64_t)INT64_MAX && (uint64_t)len < (uint64_t)INT64_MAX && assert((uint64_t)offset < (uint64_t)INT64_MAX && (uint64_t)len < (uint64_t)INT64_MAX &&
(uint64_t)(offset + len) > (uint64_t)offset); (uint64_t)(offset + len) > (uint64_t)offset);

View File

@ -193,7 +193,14 @@ typedef struct osal_mmap {
#elif defined(__ANDROID_API__) #elif defined(__ANDROID_API__)
#if __ANDROID_API__ < 24 #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 #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 #else
#define MDBX_HAVE_PWRITEV 1 #define MDBX_HAVE_PWRITEV 1
#endif #endif

View File

@ -433,11 +433,6 @@ __extern_C key_t ftok(const char *, int);
#if __ANDROID_API__ >= 21 #if __ANDROID_API__ >= 21
#include <sys/sendfile.h> #include <sys/sendfile.h>
#endif #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 */ #endif /* Android */
#if defined(HAVE_SYS_STAT_H) || __has_include(<sys/stat.h>) #if defined(HAVE_SYS_STAT_H) || __has_include(<sys/stat.h>)
@ -522,6 +517,14 @@ __extern_C key_t ftok(const char *, int);
#endif #endif
#endif /* __BYTE_ORDER__ || __ORDER_LITTLE_ENDIAN__ || __ORDER_BIG_ENDIAN__ */ #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 */ /* Availability of CMOV or equivalent */