/******************************************************************************* ******************************************************************************* ******************************************************************************* * * * #### ##### ##### # #### # # #### * # # # # # # # # ## # # * # # # # # # # # # # # #### * # # ##### # # # # # # # # * # # # # # # # # ## # # * #### # # # #### # # #### * * */ /* using fcntl(F_FULLFSYNC) with 5-10 times slowdown */ #define MDBX_OSX_WANNA_DURABILITY 0 /* using fsync() with chance of data lost on power failure */ #define MDBX_OSX_WANNA_SPEED 1 #ifndef MDBX_OSX_SPEED_INSTEADOF_DURABILITY #define MDBX_OSX_SPEED_INSTEADOF_DURABILITY MDBX_OSX_WANNA_DURABILITY #endif /* MDBX_OSX_SPEED_INSTEADOF_DURABILITY */ /* Controls checking PID against reuse DB environment after the fork() */ #ifndef MDBX_TXN_CHECKPID #if defined(MADV_DONTFORK) || defined(_WIN32) || defined(_WIN64) /* PID check could be ommited: * - on Linux when madvise(MADV_DONTFORK) is available. i.e. after the fork() * mapped pages will not be available for child process. * - in Windows where fork() not available. */ #define MDBX_TXN_CHECKPID 0 #else #define MDBX_TXN_CHECKPID 1 #endif #define MDBX_TXN_CHECKPID_CONFIG "AUTO=" STRINGIFY(MDBX_TXN_CHECKPID) #else #define MDBX_TXN_CHECKPID_CONFIG STRINGIFY(MDBX_TXN_CHECKPID) #endif /* MDBX_TXN_CHECKPID */ /* Controls checking transaction owner thread against misuse transactions from * other threads. */ #ifndef MDBX_TXN_CHECKOWNER #define MDBX_TXN_CHECKOWNER 1 #define MDBX_TXN_CHECKOWNER_CONFIG "AUTO=" STRINGIFY(MDBX_TXN_CHECKOWNER) #else #define MDBX_TXN_CHECKOWNER_CONFIG STRINGIFY(MDBX_TXN_CHECKOWNER) #endif /* MDBX_TXN_CHECKOWNER */ /* Does a system have battery-backed Real-Time Clock or just a fake. */ #ifndef MDBX_TRUST_RTC #if defined(__linux__) || defined(__gnu_linux__) || defined(__NetBSD__) || \ defined(__OpenBSD__) #define MDBX_TRUST_RTC 0 /* a lot of embedded systems have a fake RTC */ #else #define MDBX_TRUST_RTC 1 #endif #define MDBX_TRUST_RTC_CONFIG "AUTO=" STRINGIFY(MDBX_TRUST_RTC) #else #define MDBX_TRUST_RTC_CONFIG STRINGIFY(MDBX_TRUST_RTC) #endif /* MDBX_TRUST_RTC */ //------------------------------------------------------------------------------ #define MDBX_LOCKING_WIN32FILES -1 /* Win32 File Locking API */ #define MDBX_LOCKING_SYSV 5 /* SystemV IPC semaphores */ #define MDBX_LOCKING_POSIX1988 1988 /* POSIX-1 Shared anonymous semaphores */ #define MDBX_LOCKING_POSIX2001 2001 /* POSIX-2001 Shared Mutexes */ #define MDBX_LOCKING_POSIX2008 2008 /* POSIX-2008 Robust Mutexes */ #define MDBX_LOCKING_BENAPHORE 1995 /* BeOS Benaphores, aka Futexes */ #if defined(_WIN32) || defined(_WIN64) #define MDBX_LOCKING MDBX_LOCKING_WIN32FILES #else #ifndef MDBX_LOCKING #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_LOCKING=2001. */ #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_LOCKING MDBX_LOCKING_POSIX2008 #else #define MDBX_LOCKING MDBX_LOCKING_POSIX2001 #endif #elif defined(__sun) || defined(__SVR4) || defined(__svr4__) #define MDBX_LOCKING MDBX_LOCKING_POSIX1988 #else #define MDBX_LOCKING MDBX_LOCKING_SYSV #endif #define MDBX_LOCKING_CONFIG "AUTO=" STRINGIFY(MDBX_LOCKING) #else #define MDBX_LOCKING_CONFIG STRINGIFY(MDBX_LOCKING) #endif /* MDBX_LOCKING */ #endif /* !Windows */ #ifndef MDBX_USE_OFDLOCKS #if defined(F_OFD_SETLK) && defined(F_OFD_SETLKW) && defined(F_OFD_GETLK) && \ !defined(MDBX_SAFE4QEMU) && \ !defined(__sun) /* OFD-lock are broken on Solaris */ #define MDBX_USE_OFDLOCKS 1 #else #define MDBX_USE_OFDLOCKS 0 #endif #define MDBX_USE_OFDLOCKS_CONFIG "AUTO=" STRINGIFY(MDBX_USE_OFDLOCKS) #else #define MDBX_USE_OFDLOCKS_CONFIG STRINGIFY(MDBX_USE_OFDLOCKS) #endif /* MDBX_USE_OFDLOCKS */ //------------------------------------------------------------------------------ #ifndef MDBX_CPU_WRITEBACK_IS_COHERENT #if defined(__ia32__) || defined(__e2k__) || defined(__hppa) || \ defined(__hppa__) #define MDBX_CPU_WRITEBACK_IS_COHERENT 1 #else #define MDBX_CPU_WRITEBACK_IS_COHERENT 0 #endif #endif /* MDBX_CPU_WRITEBACK_IS_COHERENT */ #ifndef MDBX_CPU_CACHE_MMAP_NONCOHERENT #if defined(__mips) || defined(__mips__) || defined(__mips64) || \ defined(__mips64__) || defined(_M_MRX000) || defined(_MIPS_) || \ defined(__MWERKS__) || defined(__sgi) /* MIPS has cache coherency issues. */ #define MDBX_CPU_CACHE_MMAP_NONCOHERENT 1 #else /* LY: assume no relevant mmap/dcache issues. */ #define MDBX_CPU_CACHE_MMAP_NONCOHERENT 0 #endif #endif /* MDBX_CPU_CACHE_MMAP_NONCOHERENT */ #ifndef MDBX_64BIT_ATOMIC #if MDBX_WORDBITS >= 64 #define MDBX_64BIT_ATOMIC 1 #else #define MDBX_64BIT_ATOMIC 0 #endif #define MDBX_64BIT_ATOMIC_CONFIG "AUTO=" STRINGIFY(MDBX_64BIT_ATOMIC) #else #define MDBX_64BIT_ATOMIC_CONFIG STRINGIFY(MDBX_64BIT_ATOMIC) #endif /* MDBX_64BIT_ATOMIC */ #ifndef MDBX_64BIT_CAS #if defined(ATOMIC_LLONG_LOCK_FREE) #if ATOMIC_LLONG_LOCK_FREE > 1 #define MDBX_64BIT_CAS 1 #else #define MDBX_64BIT_CAS 0 #endif #elif defined(__GCC_ATOMIC_LLONG_LOCK_FREE) #if __GCC_ATOMIC_LLONG_LOCK_FREE > 1 #define MDBX_64BIT_CAS 1 #else #define MDBX_64BIT_CAS 0 #endif #elif defined(__CLANG_ATOMIC_LLONG_LOCK_FREE) #if __CLANG_ATOMIC_LLONG_LOCK_FREE > 1 #define MDBX_64BIT_CAS 1 #else #define MDBX_64BIT_CAS 0 #endif #elif defined(_MSC_VER) || defined(__APPLE__) #define MDBX_64BIT_CAS 1 #else #define MDBX_64BIT_CAS MDBX_64BIT_ATOMIC #endif #define MDBX_64BIT_CAS_CONFIG "AUTO=" STRINGIFY(MDBX_64BIT_CAS) #else #define MDBX_64BIT_CAS_CONFIG STRINGIFY(MDBX_64BIT_CAS) #endif /* MDBX_64BIT_CAS */ #if !defined(MDBX_UNALIGNED_OK) #if defined(_MSC_VER) #define MDBX_UNALIGNED_OK 1 /* avoid MSVC misoptimization */ #elif __CLANG_PREREQ(5, 0) || __GNUC_PREREQ(5, 0) #define MDBX_UNALIGNED_OK 0 /* expecting optimization is well done */ #elif (defined(__ia32__) || defined(__ARM_FEATURE_UNALIGNED)) && \ !defined(__ALIGNED__) #define MDBX_UNALIGNED_OK 1 #else #define MDBX_UNALIGNED_OK 0 #endif #endif /* MDBX_UNALIGNED_OK */ #ifndef MDBX_CACHELINE_SIZE #if defined(SYSTEM_CACHE_ALIGNMENT_SIZE) #define MDBX_CACHELINE_SIZE SYSTEM_CACHE_ALIGNMENT_SIZE #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) #define MDBX_CACHELINE_SIZE 128 #else #define MDBX_CACHELINE_SIZE 64 #endif #endif /* MDBX_CACHELINE_SIZE */ /******************************************************************************* ******************************************************************************* ******************************************************************************/