mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 01:24:12 +08:00
mdbx: split-off mdbx-options into options.h
.
This commit is contained in:
parent
7d0206d2cf
commit
fe40af160d
@ -231,6 +231,7 @@ dist/@tmp-shared_internals.inc: src/elements/version.c $(ALLOY_DEPS) $(lastword
|
||||
-e 's|#include "../../mdbx.h"|@INCLUDE "mdbx.h"|' \
|
||||
-e '/#include "defs.h"/r src/elements/defs.h' \
|
||||
-e '/#include "osal.h"/r src/elements/osal.h' \
|
||||
-e '/#include "options.h"/r src/elements/options.h' \
|
||||
src/elements/internals.h > $@
|
||||
|
||||
dist/mdbx.c: dist/@tmp-shared_internals.inc $(lastword $(MAKEFILE_LIST))
|
||||
|
@ -25,7 +25,7 @@ else()
|
||||
set(LIBMDBX_OSAL posix)
|
||||
endif()
|
||||
set(LIBMDBX_SOURCES
|
||||
elements/defs.h elements/internals.h elements/osal.h
|
||||
elements/options.h elements/defs.h elements/internals.h elements/osal.h
|
||||
elements/core.c elements/osal.c elements/lck-${LIBMDBX_OSAL}.c)
|
||||
endif()
|
||||
list(APPEND LIBMDBX_SOURCES ../mdbx.h
|
||||
|
@ -33,12 +33,6 @@
|
||||
# undef NDEBUG
|
||||
#endif
|
||||
|
||||
#define MDBX_OSX_WANNA_DURABILITY 0 /* using fcntl(F_FULLFSYNC) with 5-10 times slowdown */
|
||||
#define MDBX_OSX_WANNA_SPEED 1 /* using fsync() with chance of data lost on power failure */
|
||||
#ifndef MDBX_OSX_SPEED_INSTEADOF_DURABILITY
|
||||
# define MDBX_OSX_SPEED_INSTEADOF_DURABILITY MDBX_OSX_WANNA_DURABILITY
|
||||
#endif
|
||||
|
||||
#ifdef MDBX_ALLOY
|
||||
/* Amalgamated build */
|
||||
# define MDBX_INTERNAL_FUNC static
|
||||
@ -152,41 +146,43 @@
|
||||
# endif
|
||||
#endif /* -Walignment-reduction-ignored */
|
||||
|
||||
#include "osal.h"
|
||||
|
||||
/* *INDENT-ON* */
|
||||
/* clang-format on */
|
||||
|
||||
/* 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 */
|
||||
#include "osal.h"
|
||||
|
||||
#define mdbx_sourcery_anchor XCONCAT(mdbx_sourcery_, MDBX_BUILD_SOURCERY)
|
||||
#if defined(MDBX_TOOLS)
|
||||
extern LIBMDBX_API const char *const mdbx_sourcery_anchor;
|
||||
#endif
|
||||
|
||||
#include "options.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Cache coherence and invalidation */
|
||||
|
||||
#if MDBX_CPU_WRITEBACK_IS_COHERENT
|
||||
#define mdbx_flush_noncoherent_cpu_writeback() mdbx_compiler_barrier()
|
||||
#else
|
||||
#define mdbx_flush_noncoherent_cpu_writeback() mdbx_memory_barrier()
|
||||
#endif
|
||||
|
||||
static __maybe_unused __inline void
|
||||
mdbx_invalidate_mmap_noncoherent_cache(void *addr, size_t nbytes) {
|
||||
#if MDBX_CPU_CACHE_MMAP_NONCOHERENT
|
||||
#ifdef DCACHE
|
||||
/* MIPS has cache coherency issues.
|
||||
* Note: for any nbytes >= on-chip cache size, entire is flushed. */
|
||||
cacheflush(addr, nbytes, DCACHE);
|
||||
#else
|
||||
#error "Oops, cacheflush() not available"
|
||||
#endif /* DCACHE */
|
||||
#else /* MDBX_CPU_CACHE_MMAP_NONCOHERENT */
|
||||
(void)addr;
|
||||
(void)nbytes;
|
||||
#endif /* MDBX_CPU_CACHE_MMAP_NONCOHERENT */
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Basic constants and types */
|
||||
|
||||
@ -1246,7 +1242,7 @@ typedef struct MDBX_node {
|
||||
uint16_t mn_hi, mn_lo; /* part of data size or pgno */
|
||||
};
|
||||
};
|
||||
#endif
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
|
||||
/* mdbx_node Flags */
|
||||
#define F_BIGDATA 0x01 /* data put on overflow page */
|
||||
|
203
src/elements/options.h
Normal file
203
src/elements/options.h
Normal file
@ -0,0 +1,203 @@
|
||||
/*******************************************************************************
|
||||
*******************************************************************************
|
||||
*******************************************************************************
|
||||
*
|
||||
*
|
||||
* #### ##### ##### # #### # # ####
|
||||
* # # # # # # # # ## # #
|
||||
* # # # # # # # # # # # ####
|
||||
* # # ##### # # # # # # # #
|
||||
* # # # # # # # # ## # #
|
||||
* #### # # # #### # # ####
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/* 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 */
|
||||
|
||||
/*******************************************************************************
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
@ -274,24 +274,17 @@ typedef pthread_mutex_t mdbx_fastmutex_t;
|
||||
#endif /* __amd64__ */
|
||||
#endif /* all x86 */
|
||||
|
||||
#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 */
|
||||
|
||||
#if (-6 & 5) || CHAR_BIT != 8 || UINT_MAX < 0xffffffff || ULONG_MAX % 0xFFFF
|
||||
#error \
|
||||
"Sanity checking failed: Two's complement, reasonably sized integer types"
|
||||
#endif
|
||||
|
||||
#if UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul
|
||||
#define MDBX_WORDBITS 64
|
||||
#else
|
||||
#define MDBX_WORDBITS 32
|
||||
#endif /* MDBX_WORDBITS */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Compiler's includes for builtins/intrinsics */
|
||||
|
||||
@ -401,6 +394,15 @@ typedef pthread_mutex_t mdbx_fastmutex_t;
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Memory/Compiler barriers, cache coherence */
|
||||
|
||||
#if __has_include(<sys/cachectl.h>)
|
||||
#include <sys/cachectl.h>
|
||||
#elif defined(__mips) || defined(__mips__) || defined(__mips64) || \
|
||||
defined(__mips64__) || defined(_M_MRX000) || defined(_MIPS_) || \
|
||||
defined(__MWERKS__) || defined(__sgi)
|
||||
/* MIPS should have explicit cache control */
|
||||
#include <sys/cachectl.h>
|
||||
#endif
|
||||
|
||||
static __maybe_unused __inline void mdbx_compiler_barrier(void) {
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
__asm__ __volatile__("" ::: "memory");
|
||||
@ -459,71 +461,6 @@ static __maybe_unused __inline void mdbx_memory_barrier(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Cache coherence and invalidation */
|
||||
|
||||
#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_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 */
|
||||
|
||||
#if MDBX_CPU_WRITEBACK_IS_COHERENT
|
||||
#define mdbx_flush_noncoherent_cpu_writeback() mdbx_compiler_barrier()
|
||||
#else
|
||||
#define mdbx_flush_noncoherent_cpu_writeback() mdbx_memory_barrier()
|
||||
#endif
|
||||
|
||||
#if __has_include(<sys/cachectl.h>)
|
||||
#include <sys/cachectl.h>
|
||||
#elif defined(__mips) || defined(__mips__) || defined(__mips64) || \
|
||||
defined(__mips64__) || defined(_M_MRX000) || defined(_MIPS_) || \
|
||||
defined(__MWERKS__) || defined(__sgi)
|
||||
/* MIPS should have explicit cache control */
|
||||
#include <sys/cachectl.h>
|
||||
#endif
|
||||
|
||||
#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 /* ndef MDBX_CPU_CACHE_MMAP_NONCOHERENT */
|
||||
|
||||
static __maybe_unused __inline void
|
||||
mdbx_invalidate_mmap_noncoherent_cache(void *addr, size_t nbytes) {
|
||||
#if MDBX_CPU_CACHE_MMAP_NONCOHERENT
|
||||
#ifdef DCACHE
|
||||
/* MIPS has cache coherency issues.
|
||||
* Note: for any nbytes >= on-chip cache size, entire is flushed. */
|
||||
cacheflush(addr, nbytes, DCACHE);
|
||||
#else
|
||||
#error "Oops, cacheflush() not available"
|
||||
#endif /* DCACHE */
|
||||
#else /* MDBX_CPU_CACHE_MMAP_NONCOHERENT */
|
||||
(void)addr;
|
||||
(void)nbytes;
|
||||
#endif /* MDBX_CPU_CACHE_MMAP_NONCOHERENT */
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* libc compatibility stuff */
|
||||
|
||||
@ -954,114 +891,3 @@ MDBX_INTERNAL_VAR MDBX_OfferVirtualMemory mdbx_OfferVirtualMemory;
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#if UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul
|
||||
#define MDBX_WORDBITS 64
|
||||
#else
|
||||
#define MDBX_WORDBITS 32
|
||||
#endif /* MDBX_WORDBITS */
|
||||
|
||||
#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 */
|
||||
|
||||
#define MDBX_LOCKING_WIN32FILES -1
|
||||
#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 */
|
||||
|
||||
/* 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 */
|
||||
|
@ -91,6 +91,8 @@
|
||||
#define __thread __declspec(thread)
|
||||
#endif /* __thread */
|
||||
|
||||
#include "../src/elements/options.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#pragma warning(disable : 4201) /* nonstandard extension used : \
|
||||
|
Loading…
x
Reference in New Issue
Block a user