From 6a7499c8fc9d329940eb38897d348c41b4e63f3d Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 8 Nov 2019 16:57:54 +0300 Subject: [PATCH] mdbx: refine POSIX-options detection. --- src/elements/internals.h | 19 ++++++++----------- test/osal-unix.cc | 3 ++- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/elements/internals.h b/src/elements/internals.h index 7eb3f2eb..e907728b 100644 --- a/src/elements/internals.h +++ b/src/elements/internals.h @@ -207,20 +207,17 @@ #define MDBX_USE_MUTEXES -1 /* Windows don't support POSIX */ #else #ifndef MDBX_USE_MUTEXES -#if defined(__linux__) || defined(__gnu_linux__) || defined(__FreeBSD__) || \ - defined(__APPLE__) || \ - (defined(_POSIX_THREAD_PROCESS_SHARED) && \ - _POSIX_THREAD_PROCESS_SHARED > 0) +#if defined(_POSIX_THREAD_PROCESS_SHARED) && \ + _POSIX_THREAD_PROCESS_SHARED >= 200112L && !defined(__FreeBSD__) /* Some platforms define the EOWNERDEAD error code even though they * don't support Robust Mutexes. If doubt compile with -MDBX_USE_MUTEXES=1. */ -#if defined(EOWNERDEAD) && _POSIX_C_SOURCE >= 200809L && \ - (!defined(__GLIBC__) || /* LY: glibc before 2.10 has a troubles with \ - Robust mutexes. */ \ - __GLIBC_PREREQ(2, 10)) && \ - (defined(PTHREAD_MUTEX_ROBUST) || defined(PTHREAD_MUTEX_ROBUST_NP) || \ - defined(PTHREAD_MUTEX_STALLED_NP) || defined(__GLIBC__) || \ - (!defined(__ANDROID__) && !defined(__APPLE__))) +#if defined(EOWNERDEAD) && _POSIX_THREAD_PROCESS_SHARED >= 200809L && \ + (defined(_POSIX_THREAD_ROBUST_PRIO_INHERIT) || \ + defined(_POSIX_THREAD_ROBUST_PRIO_PROTECT) || \ + defined(PTHREAD_MUTEX_ROBUST) || defined(PTHREAD_MUTEX_ROBUST_NP)) && \ + (!defined(__GLIBC__) || \ + __GLIBC_PREREQ(2, 10) /* troubles with Robust mutexes before 2.10 */) #define MDBX_USE_MUTEXES 2 /* use robust shared pthread mutexes */ #else #define MDBX_USE_MUTEXES 1 /* use shared pthread mutexes */ diff --git a/test/osal-unix.cc b/test/osal-unix.cc index 93d29e53..eb6f58d8 100644 --- a/test/osal-unix.cc +++ b/test/osal-unix.cc @@ -388,7 +388,8 @@ void osal_udelay(unsigned us) { static unsigned threshold_us; if (threshold_us == 0) { -#ifdef CLOCK_PROCESS_CPUTIME_ID +#if defined(_POSIX_CPUTIME) && _POSIX_CPUTIME > -1 && \ + defined(CLOCK_PROCESS_CPUTIME_ID) if (clock_getres(CLOCK_PROCESS_CPUTIME_ID, &ts)) { int rc = errno; log_warning("clock_getres(CLOCK_PROCESS_CPUTIME_ID), failed errno %d",