2019-11-13 20:14:17 +03:00
|
|
|
/*******************************************************************************
|
|
|
|
*******************************************************************************
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* #### ##### ##### # #### # # ####
|
|
|
|
* # # # # # # # # ## # #
|
|
|
|
* # # # # # # # # # # # ####
|
|
|
|
* # # ##### # # # # # # # #
|
|
|
|
* # # # # # # # # ## # #
|
|
|
|
* #### # # # #### # # ####
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-07-28 15:05:35 +03:00
|
|
|
/** \defgroup build_option Build options
|
|
|
|
* The libmdbx build options.
|
|
|
|
@{ */
|
|
|
|
|
|
|
|
#ifdef DOXYGEN
|
|
|
|
/* !!! Actually this is a fake definitions !!!
|
|
|
|
* !!! for documentation generation by Doxygen !!! */
|
|
|
|
|
|
|
|
/** Controls enabling of debugging features.
|
|
|
|
*
|
|
|
|
* - `MDBX_DEBUG = 0` (by default) Disables any debugging features at all,
|
|
|
|
* including logging and assertion controls.
|
|
|
|
* Logging level and corresponding debug flags changing
|
|
|
|
* by \ref mdbx_setup_debug() will not have effect.
|
|
|
|
* - `MDBX_DEBUG > 0` Enables code for the debugging features (logging,
|
|
|
|
* assertions checking and internal audit).
|
|
|
|
* Simultaneously sets the default logging level
|
|
|
|
* to the `MDBX_DEBUG` value.
|
|
|
|
* Also enables \ref MDBX_DBG_AUDIT if `MDBX_DEBUG >= 2`.
|
|
|
|
*
|
|
|
|
* \ingroup build_option */
|
|
|
|
#define MDBX_DEBUG 0...7
|
|
|
|
|
|
|
|
/** Disables using of GNU libc extensions. */
|
|
|
|
#define MDBX_DISABLE_GNU_SOURCE 0 or 1
|
|
|
|
|
|
|
|
#endif /* DOXYGEN */
|
|
|
|
|
|
|
|
/** Using fcntl(F_FULLFSYNC) with 5-10 times slowdown */
|
2019-11-13 20:14:17 +03:00
|
|
|
#define MDBX_OSX_WANNA_DURABILITY 0
|
2020-07-28 15:05:35 +03:00
|
|
|
/** Using fsync() with chance of data lost on power failure */
|
2019-11-13 20:14:17 +03:00
|
|
|
#define MDBX_OSX_WANNA_SPEED 1
|
|
|
|
|
|
|
|
#ifndef MDBX_OSX_SPEED_INSTEADOF_DURABILITY
|
2020-07-28 15:05:35 +03:00
|
|
|
/** Choices \ref MDBX_OSX_WANNA_DURABILITY or \ref MDBX_OSX_WANNA_SPEED
|
|
|
|
* for OSX & iOS */
|
2019-11-13 20:14:17 +03:00
|
|
|
#define MDBX_OSX_SPEED_INSTEADOF_DURABILITY MDBX_OSX_WANNA_DURABILITY
|
|
|
|
#endif /* MDBX_OSX_SPEED_INSTEADOF_DURABILITY */
|
|
|
|
|
2020-07-28 15:05:35 +03:00
|
|
|
/** Controls checking PID against reuse DB environment after the fork() */
|
2020-07-22 14:53:15 +03:00
|
|
|
#ifndef MDBX_ENV_CHECKPID
|
2019-11-13 20:14:17 +03:00
|
|
|
#if defined(MADV_DONTFORK) || defined(_WIN32) || defined(_WIN64)
|
2020-09-21 23:51:47 -04:00
|
|
|
/* PID check could be omitted:
|
2020-09-29 20:14:08 +03:00
|
|
|
* - on Linux when madvise(MADV_DONTFORK) is available, i.e. after the fork()
|
2019-11-13 20:14:17 +03:00
|
|
|
* mapped pages will not be available for child process.
|
|
|
|
* - in Windows where fork() not available. */
|
2020-07-22 14:53:15 +03:00
|
|
|
#define MDBX_ENV_CHECKPID 0
|
2019-11-13 20:14:17 +03:00
|
|
|
#else
|
2020-07-22 14:53:15 +03:00
|
|
|
#define MDBX_ENV_CHECKPID 1
|
2019-11-13 20:14:17 +03:00
|
|
|
#endif
|
2020-07-22 14:53:15 +03:00
|
|
|
#define MDBX_ENV_CHECKPID_CONFIG "AUTO=" STRINGIFY(MDBX_ENV_CHECKPID)
|
2019-11-13 20:14:17 +03:00
|
|
|
#else
|
2020-07-22 14:53:15 +03:00
|
|
|
#define MDBX_ENV_CHECKPID_CONFIG STRINGIFY(MDBX_ENV_CHECKPID)
|
|
|
|
#endif /* MDBX_ENV_CHECKPID */
|
2019-11-13 20:14:17 +03:00
|
|
|
|
2020-07-28 15:05:35 +03:00
|
|
|
/** Controls checking transaction owner thread against misuse transactions from
|
2019-11-13 20:14:17 +03:00
|
|
|
* 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 */
|
|
|
|
|
2020-07-28 15:05:35 +03:00
|
|
|
/** Does a system have battery-backed Real-Time Clock or just a fake. */
|
2019-11-13 20:14:17 +03:00
|
|
|
#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 */
|
|
|
|
|
2021-01-18 17:34:54 +03:00
|
|
|
/** Controls online database auto-compactification during write-transactions. */
|
|
|
|
#ifndef MDBX_ENABLE_REFUND
|
|
|
|
#define MDBX_ENABLE_REFUND 1
|
|
|
|
#endif
|
|
|
|
#if !(MDBX_ENABLE_REFUND == 0 || MDBX_ENABLE_REFUND == 1)
|
|
|
|
#error MDBX_ENABLE_REFUND must be defined as 0 or 1
|
|
|
|
#endif /* MDBX_ENABLE_REFUND */
|
|
|
|
|
2021-02-26 04:10:56 +03:00
|
|
|
/** Controls use of POSIX madvise() hints and friends. */
|
|
|
|
#ifndef MDBX_ENABLE_MADVISE
|
|
|
|
#define MDBX_ENABLE_MADVISE 1
|
|
|
|
#endif
|
|
|
|
#if !(MDBX_ENABLE_MADVISE == 0 || MDBX_ENABLE_MADVISE == 1)
|
|
|
|
#error MDBX_ENABLE_MADVISE must be defined as 0 or 1
|
|
|
|
#endif /* MDBX_ENABLE_MADVISE */
|
|
|
|
|
2021-02-07 02:35:44 +03:00
|
|
|
/** Disable some checks to reduce an overhead and detection probability of
|
|
|
|
* database corruption to a values closer to the LMDB. */
|
|
|
|
#ifndef MDBX_DISABLE_PAGECHECKS
|
|
|
|
#define MDBX_DISABLE_PAGECHECKS 0
|
|
|
|
#endif
|
|
|
|
#if !(MDBX_DISABLE_PAGECHECKS == 0 || MDBX_DISABLE_PAGECHECKS == 1)
|
|
|
|
#error MDBX_DISABLE_PAGECHECKS must be defined as 0 or 1
|
|
|
|
#endif /* MDBX_DISABLE_PAGECHECKS */
|
|
|
|
|
2021-01-20 13:05:32 +03:00
|
|
|
/** Controls sort order of internal page number lists.
|
|
|
|
* The database format depend on this option and libmdbx builded with different
|
|
|
|
* option value are incompatible. */
|
|
|
|
#ifndef MDBX_PNL_ASCENDING
|
|
|
|
#define MDBX_PNL_ASCENDING 0
|
|
|
|
#endif
|
|
|
|
#if !(MDBX_PNL_ASCENDING == 0 || MDBX_PNL_ASCENDING == 1)
|
|
|
|
#error MDBX_PNL_ASCENDING must be defined as 0 or 1
|
|
|
|
#endif /* MDBX_PNL_ASCENDING */
|
|
|
|
|
2019-11-13 20:14:17 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2020-07-28 15:05:35 +03:00
|
|
|
/** Win32 File Locking API for \ref MDBX_LOCKING */
|
|
|
|
#define MDBX_LOCKING_WIN32FILES -1
|
|
|
|
|
|
|
|
/** SystemV IPC semaphores for \ref MDBX_LOCKING */
|
|
|
|
#define MDBX_LOCKING_SYSV 5
|
|
|
|
|
|
|
|
/** POSIX-1 Shared anonymous semaphores for \ref MDBX_LOCKING */
|
|
|
|
#define MDBX_LOCKING_POSIX1988 1988
|
|
|
|
|
|
|
|
/** POSIX-2001 Shared Mutexes for \ref MDBX_LOCKING */
|
|
|
|
#define MDBX_LOCKING_POSIX2001 2001
|
|
|
|
|
|
|
|
/** POSIX-2008 Robust Mutexes for \ref MDBX_LOCKING */
|
|
|
|
#define MDBX_LOCKING_POSIX2008 2008
|
|
|
|
|
|
|
|
/** BeOS Benaphores, aka Futexes for \ref MDBX_LOCKING */
|
|
|
|
#define MDBX_LOCKING_BENAPHORE 1995
|
2019-11-13 20:14:17 +03:00
|
|
|
|
2020-07-28 15:05:35 +03:00
|
|
|
/** Advanced: Choices the locking implementation (autodetection by default). */
|
2019-11-13 20:14:17 +03:00
|
|
|
#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 && \
|
2020-04-13 22:46:55 +03:00
|
|
|
((defined(_POSIX_THREAD_ROBUST_PRIO_INHERIT) && \
|
|
|
|
_POSIX_THREAD_ROBUST_PRIO_INHERIT > 0) || \
|
|
|
|
(defined(_POSIX_THREAD_ROBUST_PRIO_PROTECT) && \
|
|
|
|
_POSIX_THREAD_ROBUST_PRIO_PROTECT > 0) || \
|
2019-11-13 20:14:17 +03:00
|
|
|
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 */
|
|
|
|
|
2020-07-28 15:05:35 +03:00
|
|
|
/** Advanced: Using POSIX OFD-locks (autodetection by default). */
|
2019-11-13 20:14:17 +03:00
|
|
|
#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 */
|
|
|
|
|
2020-09-20 20:16:26 +03:00
|
|
|
/** Advanced: Using sendfile() syscall (autodetection by default). */
|
|
|
|
#ifndef MDBX_USE_SENDFILE
|
2020-09-20 20:49:53 +03:00
|
|
|
#if ((defined(__linux__) || defined(__gnu_linux__)) && \
|
2020-09-27 12:50:13 +03:00
|
|
|
!defined(__ANDROID_API__)) || \
|
2020-09-20 20:49:53 +03:00
|
|
|
(defined(__ANDROID_API__) && __ANDROID_API__ >= 21)
|
2020-09-20 20:16:26 +03:00
|
|
|
#define MDBX_USE_SENDFILE 1
|
|
|
|
#else
|
|
|
|
#define MDBX_USE_SENDFILE 0
|
|
|
|
#endif
|
|
|
|
#endif /* MDBX_USE_SENDFILE */
|
|
|
|
|
|
|
|
/** Advanced: Using copy_file_range() syscall (autodetection by default). */
|
|
|
|
#ifndef MDBX_USE_COPYFILERANGE
|
2020-09-20 20:49:53 +03:00
|
|
|
#if __GLIBC_PREREQ(2, 27) && defined(_GNU_SOURCE)
|
2020-09-20 20:16:26 +03:00
|
|
|
#define MDBX_USE_COPYFILERANGE 1
|
|
|
|
#else
|
|
|
|
#define MDBX_USE_COPYFILERANGE 0
|
|
|
|
#endif
|
|
|
|
#endif /* MDBX_USE_COPYFILERANGE */
|
|
|
|
|
2020-09-21 03:03:20 +03:00
|
|
|
/** Advanced: Using sync_file_range() syscall (autodetection by default). */
|
|
|
|
#ifndef MDBX_USE_SYNCFILERANGE
|
2020-09-27 12:50:13 +03:00
|
|
|
#if ((defined(__linux__) || defined(__gnu_linux__)) && \
|
|
|
|
defined(SYNC_FILE_RANGE_WRITE) && !defined(__ANDROID_API__)) || \
|
2020-09-21 03:27:40 +03:00
|
|
|
(defined(__ANDROID_API__) && __ANDROID_API__ >= 26)
|
2020-09-21 03:03:20 +03:00
|
|
|
#define MDBX_USE_SYNCFILERANGE 1
|
|
|
|
#else
|
|
|
|
#define MDBX_USE_SYNCFILERANGE 0
|
|
|
|
#endif
|
|
|
|
#endif /* MDBX_USE_SYNCFILERANGE */
|
|
|
|
|
2019-11-13 20:14:17 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2019-11-13 22:12:09 +03:00
|
|
|
#ifndef MDBX_CPU_WRITEBACK_INCOHERENT
|
2019-11-13 20:14:17 +03:00
|
|
|
#if defined(__ia32__) || defined(__e2k__) || defined(__hppa) || \
|
2020-07-28 15:05:35 +03:00
|
|
|
defined(__hppa__) || defined(DOXYGEN)
|
2019-11-13 22:12:09 +03:00
|
|
|
#define MDBX_CPU_WRITEBACK_INCOHERENT 0
|
2019-11-13 20:14:17 +03:00
|
|
|
#else
|
2019-11-13 22:12:09 +03:00
|
|
|
#define MDBX_CPU_WRITEBACK_INCOHERENT 1
|
2019-11-13 20:14:17 +03:00
|
|
|
#endif
|
2019-11-13 22:12:09 +03:00
|
|
|
#endif /* MDBX_CPU_WRITEBACK_INCOHERENT */
|
2019-11-13 20:14:17 +03:00
|
|
|
|
2019-11-13 22:12:09 +03:00
|
|
|
#ifndef MDBX_MMAP_INCOHERENT_FILE_WRITE
|
|
|
|
#ifdef __OpenBSD__
|
|
|
|
#define MDBX_MMAP_INCOHERENT_FILE_WRITE 1
|
|
|
|
#else
|
|
|
|
#define MDBX_MMAP_INCOHERENT_FILE_WRITE 0
|
|
|
|
#endif
|
|
|
|
#endif /* MDBX_MMAP_INCOHERENT_FILE_WRITE */
|
|
|
|
|
|
|
|
#ifndef MDBX_MMAP_INCOHERENT_CPU_CACHE
|
2019-11-13 20:14:17 +03:00
|
|
|
#if defined(__mips) || defined(__mips__) || defined(__mips64) || \
|
|
|
|
defined(__mips64__) || defined(_M_MRX000) || defined(_MIPS_) || \
|
|
|
|
defined(__MWERKS__) || defined(__sgi)
|
|
|
|
/* MIPS has cache coherency issues. */
|
2019-11-13 22:12:09 +03:00
|
|
|
#define MDBX_MMAP_INCOHERENT_CPU_CACHE 1
|
2019-11-13 20:14:17 +03:00
|
|
|
#else
|
|
|
|
/* LY: assume no relevant mmap/dcache issues. */
|
2019-11-13 22:12:09 +03:00
|
|
|
#define MDBX_MMAP_INCOHERENT_CPU_CACHE 0
|
2019-11-13 20:14:17 +03:00
|
|
|
#endif
|
2019-11-13 22:12:09 +03:00
|
|
|
#endif /* MDBX_MMAP_INCOHERENT_CPU_CACHE */
|
2019-11-13 20:14:17 +03:00
|
|
|
|
|
|
|
#ifndef MDBX_64BIT_ATOMIC
|
2020-07-28 15:05:35 +03:00
|
|
|
#if MDBX_WORDBITS >= 64 || defined(DOXYGEN)
|
2019-11-13 20:14:17 +03:00
|
|
|
#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
|
2020-07-28 15:05:35 +03:00
|
|
|
#elif defined(_MSC_VER) || defined(__APPLE__) || defined(DOXYGEN)
|
2019-11-13 20:14:17 +03:00
|
|
|
#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 */
|
|
|
|
|
2020-07-28 15:05:35 +03:00
|
|
|
/** @} end of build options */
|
2019-11-13 20:14:17 +03:00
|
|
|
/*******************************************************************************
|
|
|
|
*******************************************************************************
|
|
|
|
******************************************************************************/
|