From 1e3f63366559ee0dca5968eadade2c1f02398351 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 27 Sep 2020 12:50:13 +0300 Subject: [PATCH] mdbx: fix build with uclibc. Change-Id: I907fecd84b335a84d5f1dcaa44ac489c4dfb1907 --- .github/actions/spelling/expect.txt | 1 + src/options.h | 6 +++--- src/osal.c | 13 ++++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index b799ec73..cff28eaa 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -1623,6 +1623,7 @@ typename ubsan ubuntu ucf +UCLIBC UCRT udelay ue diff --git a/src/options.h b/src/options.h index a69128c2..c7ee36a4 100644 --- a/src/options.h +++ b/src/options.h @@ -165,7 +165,7 @@ /** Advanced: Using sendfile() syscall (autodetection by default). */ #ifndef MDBX_USE_SENDFILE #if ((defined(__linux__) || defined(__gnu_linux__)) && \ - __GLIBC_PREREQ(2, 3)) || \ + !defined(__ANDROID_API__)) || \ (defined(__ANDROID_API__) && __ANDROID_API__ >= 21) #define MDBX_USE_SENDFILE 1 #else @@ -184,8 +184,8 @@ /** Advanced: Using sync_file_range() syscall (autodetection by default). */ #ifndef MDBX_USE_SYNCFILERANGE -#if ((defined(__linux__) || defined(__gnu_linux__)) && __GLIBC_PREREQ(2, 6) && \ - defined(_GNU_SOURCE)) || \ +#if ((defined(__linux__) || defined(__gnu_linux__)) && \ + defined(SYNC_FILE_RANGE_WRITE) && !defined(__ANDROID_API__)) || \ (defined(__ANDROID_API__) && __ANDROID_API__ >= 26) #define MDBX_USE_SYNCFILERANGE 1 #else diff --git a/src/osal.c b/src/osal.c index 21a0230f..04ea5140 100644 --- a/src/osal.c +++ b/src/osal.c @@ -134,7 +134,18 @@ typedef struct _FILE_PROVIDER_EXTERNAL_INFO_V1 { /*----------------------------------------------------------------------------*/ -#if _POSIX_C_SOURCE > 200212 && \ +#if defined(__UCLIBC__) +__extern_C void __assert(const char *, const char *, unsigned int, const char *) +#ifdef __THROW + __THROW +#else + __nothrow +#endif /* __THROW */ + __noreturn; +#define __assert_fail(assertion, file, line, function) \ + __assert(assertion, file, line, function) + +#elif _POSIX_C_SOURCE > 200212 && \ /* workaround for avoid musl libc wrong prototype */ ( \ defined(__GLIBC__) || defined(__GNU_LIBRARY__)) /* Prototype should match libc runtime. ISO POSIX (2003) & LSB 1.x-3.x */