mirror of
https://github.com/isar/libmdbx.git
synced 2025-04-23 17:47:47 +08:00
mdbx: refine/rearrange build options.
Change-Id: Ic27bf2b1f22e7ed9e6a1db9a1ed2496b1bb1239b
This commit is contained in:
parent
6b6165cdeb
commit
161b00a4b6
2
.github/actions/spelling/expect.txt
vendored
2
.github/actions/spelling/expect.txt
vendored
@ -431,6 +431,7 @@ ENOTTY
|
|||||||
ent
|
ent
|
||||||
entbuf
|
entbuf
|
||||||
enum
|
enum
|
||||||
|
ENVCOPY
|
||||||
envflags
|
envflags
|
||||||
envinfo
|
envinfo
|
||||||
ENVLIST
|
ENVLIST
|
||||||
@ -1878,6 +1879,7 @@ workaround
|
|||||||
workflow
|
workflow
|
||||||
Wpedantic
|
Wpedantic
|
||||||
writeback
|
writeback
|
||||||
|
WRITEBUF
|
||||||
writefault
|
writefault
|
||||||
writefaultn
|
writefaultn
|
||||||
writemap
|
writemap
|
||||||
|
@ -431,10 +431,10 @@ recommended. Otherwise do not forget to add `ntdll.lib` to linking.
|
|||||||
|
|
||||||
Building by MinGW, MSYS or Cygwin is potentially possible. However,
|
Building by MinGW, MSYS or Cygwin is potentially possible. However,
|
||||||
these scripts are not tested and will probably require you to modify the
|
these scripts are not tested and will probably require you to modify the
|
||||||
CMakeLists.txt or Makefile respectively.
|
`CMakeLists.txt` or `Makefile` respectively.
|
||||||
|
|
||||||
It should be noted that in _libmdbx_ was efforts to resolve
|
It should be noted that in _libmdbx_ was efforts to resolve
|
||||||
runtime dependencies from CRT and other libraries Visual Studio.
|
runtime dependencies from CRT and other MSVC libraries.
|
||||||
For this is enough to define the `MDBX_WITHOUT_MSVC_CRT` during build.
|
For this is enough to define the `MDBX_WITHOUT_MSVC_CRT` during build.
|
||||||
|
|
||||||
An example of running a basic test script can be found in the
|
An example of running a basic test script can be found in the
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#cmakedefine ENABLE_GCOV
|
#cmakedefine ENABLE_GCOV
|
||||||
#cmakedefine ENABLE_ASAN
|
#cmakedefine ENABLE_ASAN
|
||||||
#cmakedefine ENABLE_UBSAN
|
#cmakedefine ENABLE_UBSAN
|
||||||
#cmakedefine MDBX_FORCE_ASSERTIONS
|
#cmakedefine01 MDBX_FORCE_ASSERTIONS
|
||||||
|
|
||||||
/* Common */
|
/* Common */
|
||||||
#cmakedefine01 MDBX_TXN_CHECKOWNER
|
#cmakedefine01 MDBX_TXN_CHECKOWNER
|
||||||
|
36
src/core.c
36
src/core.c
@ -18085,10 +18085,6 @@ int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data,
|
|||||||
|
|
||||||
/**** COPYING *****************************************************************/
|
/**** COPYING *****************************************************************/
|
||||||
|
|
||||||
#ifndef MDBX_WBUF
|
|
||||||
#define MDBX_WBUF ((size_t)1024 * 1024)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* State needed for a double-buffering compacting copy. */
|
/* State needed for a double-buffering compacting copy. */
|
||||||
typedef struct mdbx_copy {
|
typedef struct mdbx_copy {
|
||||||
MDBX_env *mc_env;
|
MDBX_env *mc_env;
|
||||||
@ -18253,7 +18249,8 @@ static __cold int mdbx_env_cwalk(mdbx_copy *my, pgno_t *pg, int flags) {
|
|||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto done;
|
goto done;
|
||||||
unsigned toggle = my->mc_head & 1;
|
unsigned toggle = my->mc_head & 1;
|
||||||
if (my->mc_wlen[toggle] + my->mc_env->me_psize > MDBX_WBUF) {
|
if (my->mc_wlen[toggle] + my->mc_env->me_psize >
|
||||||
|
((size_t)(MDBX_ENVCOPY_WRITEBUF))) {
|
||||||
rc = mdbx_env_cthr_toggle(my);
|
rc = mdbx_env_cthr_toggle(my);
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto done;
|
goto done;
|
||||||
@ -18321,7 +18318,8 @@ static __cold int mdbx_env_cwalk(mdbx_copy *my, pgno_t *pg, int flags) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned toggle = my->mc_head & 1;
|
unsigned toggle = my->mc_head & 1;
|
||||||
if (my->mc_wlen[toggle] + my->mc_wlen[toggle] > MDBX_WBUF) {
|
if (my->mc_wlen[toggle] + my->mc_wlen[toggle] >
|
||||||
|
((size_t)(MDBX_ENVCOPY_WRITEBUF))) {
|
||||||
rc = mdbx_env_cthr_toggle(my);
|
rc = mdbx_env_cthr_toggle(my);
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
goto done;
|
goto done;
|
||||||
@ -18445,9 +18443,9 @@ static __cold int mdbx_env_compact(MDBX_env *env, MDBX_txn *read_txn,
|
|||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
memset(data_buffer, 0, MDBX_WBUF * 2);
|
memset(data_buffer, 0, ((size_t)(MDBX_ENVCOPY_WRITEBUF)) * 2);
|
||||||
ctx.mc_wbuf[0] = data_buffer;
|
ctx.mc_wbuf[0] = data_buffer;
|
||||||
ctx.mc_wbuf[1] = data_buffer + MDBX_WBUF;
|
ctx.mc_wbuf[1] = data_buffer + ((size_t)(MDBX_ENVCOPY_WRITEBUF));
|
||||||
ctx.mc_next_pgno = NUM_METAS;
|
ctx.mc_next_pgno = NUM_METAS;
|
||||||
ctx.mc_env = env;
|
ctx.mc_env = env;
|
||||||
ctx.mc_fd = fd;
|
ctx.mc_fd = fd;
|
||||||
@ -18511,10 +18509,12 @@ static __cold int mdbx_env_compact(MDBX_env *env, MDBX_txn *read_txn,
|
|||||||
return mdbx_ftruncate(fd, whole_size);
|
return mdbx_ftruncate(fd, whole_size);
|
||||||
|
|
||||||
const size_t used_size = pgno2bytes(env, meta->mm_geo.next);
|
const size_t used_size = pgno2bytes(env, meta->mm_geo.next);
|
||||||
memset(data_buffer, 0, MDBX_WBUF);
|
memset(data_buffer, 0, ((size_t)(MDBX_ENVCOPY_WRITEBUF)));
|
||||||
for (size_t offset = used_size; offset < whole_size;) {
|
for (size_t offset = used_size; offset < whole_size;) {
|
||||||
const size_t chunk =
|
const size_t chunk =
|
||||||
(MDBX_WBUF < whole_size - offset) ? MDBX_WBUF : whole_size - offset;
|
(((size_t)(MDBX_ENVCOPY_WRITEBUF)) < whole_size - offset)
|
||||||
|
? ((size_t)(MDBX_ENVCOPY_WRITEBUF))
|
||||||
|
: whole_size - offset;
|
||||||
/* copy to avoid EFAULT in case swapped-out */
|
/* copy to avoid EFAULT in case swapped-out */
|
||||||
int rc = mdbx_write(fd, data_buffer, chunk);
|
int rc = mdbx_write(fd, data_buffer, chunk);
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
@ -18606,7 +18606,9 @@ static __cold int mdbx_env_copy_asis(MDBX_env *env, MDBX_txn *read_txn,
|
|||||||
|
|
||||||
/* fallback to portable */
|
/* fallback to portable */
|
||||||
const size_t chunk =
|
const size_t chunk =
|
||||||
(MDBX_WBUF < used_size - offset) ? MDBX_WBUF : used_size - offset;
|
(((size_t)(MDBX_ENVCOPY_WRITEBUF)) < used_size - offset)
|
||||||
|
? ((size_t)(MDBX_ENVCOPY_WRITEBUF))
|
||||||
|
: used_size - offset;
|
||||||
/* copy to avoid EFAULT in case swapped-out */
|
/* copy to avoid EFAULT in case swapped-out */
|
||||||
memcpy(data_buffer, env->me_map + offset, chunk);
|
memcpy(data_buffer, env->me_map + offset, chunk);
|
||||||
rc = mdbx_write(fd, data_buffer, chunk);
|
rc = mdbx_write(fd, data_buffer, chunk);
|
||||||
@ -18618,11 +18620,13 @@ static __cold int mdbx_env_copy_asis(MDBX_env *env, MDBX_txn *read_txn,
|
|||||||
if (!dest_is_pipe)
|
if (!dest_is_pipe)
|
||||||
rc = mdbx_ftruncate(fd, whole_size);
|
rc = mdbx_ftruncate(fd, whole_size);
|
||||||
else {
|
else {
|
||||||
memset(data_buffer, 0, MDBX_WBUF);
|
memset(data_buffer, 0, ((size_t)(MDBX_ENVCOPY_WRITEBUF)));
|
||||||
for (size_t offset = used_size;
|
for (size_t offset = used_size;
|
||||||
rc == MDBX_SUCCESS && offset < whole_size;) {
|
rc == MDBX_SUCCESS && offset < whole_size;) {
|
||||||
const size_t chunk =
|
const size_t chunk =
|
||||||
(MDBX_WBUF < whole_size - offset) ? MDBX_WBUF : whole_size - offset;
|
(((size_t)(MDBX_ENVCOPY_WRITEBUF)) < whole_size - offset)
|
||||||
|
? ((size_t)(MDBX_ENVCOPY_WRITEBUF))
|
||||||
|
: whole_size - offset;
|
||||||
/* copy to avoid EFAULT in case swapped-out */
|
/* copy to avoid EFAULT in case swapped-out */
|
||||||
rc = mdbx_write(fd, data_buffer, chunk);
|
rc = mdbx_write(fd, data_buffer, chunk);
|
||||||
offset += chunk;
|
offset += chunk;
|
||||||
@ -18651,7 +18655,9 @@ __cold int mdbx_env_copy2fd(MDBX_env *env, mdbx_filehandle_t fd,
|
|||||||
|
|
||||||
const size_t buffer_size =
|
const size_t buffer_size =
|
||||||
pgno_align2os_bytes(env, NUM_METAS) +
|
pgno_align2os_bytes(env, NUM_METAS) +
|
||||||
ceil_powerof2(((flags & MDBX_CP_COMPACT) ? MDBX_WBUF * 2 : MDBX_WBUF),
|
ceil_powerof2(((flags & MDBX_CP_COMPACT)
|
||||||
|
? ((size_t)(MDBX_ENVCOPY_WRITEBUF)) * 2
|
||||||
|
: ((size_t)(MDBX_ENVCOPY_WRITEBUF))),
|
||||||
env->me_os_psize);
|
env->me_os_psize);
|
||||||
|
|
||||||
uint8_t *buffer = NULL;
|
uint8_t *buffer = NULL;
|
||||||
@ -21963,7 +21969,7 @@ __dll_export
|
|||||||
#ifdef MDBX_USE_VALGRIND
|
#ifdef MDBX_USE_VALGRIND
|
||||||
" MDBX_USE_VALGRIND=YES"
|
" MDBX_USE_VALGRIND=YES"
|
||||||
#endif /* MDBX_USE_VALGRIND */
|
#endif /* MDBX_USE_VALGRIND */
|
||||||
#ifdef MDBX_FORCE_ASSERTIONS
|
#if MDBX_FORCE_ASSERTIONS
|
||||||
" MDBX_FORCE_ASSERTIONS=YES"
|
" MDBX_FORCE_ASSERTIONS=YES"
|
||||||
#endif /* MDBX_FORCE_ASSERTIONS */
|
#endif /* MDBX_FORCE_ASSERTIONS */
|
||||||
#ifdef _GNU_SOURCE
|
#ifdef _GNU_SOURCE
|
||||||
|
168
src/internals.h
168
src/internals.h
@ -21,33 +21,20 @@
|
|||||||
#define MDBX_DEPRECATED
|
#define MDBX_DEPRECATED
|
||||||
#endif /* xMDBX_TOOLS */
|
#endif /* xMDBX_TOOLS */
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
/* clang-format off */
|
|
||||||
|
|
||||||
/* In case the MDBX_DEBUG is undefined set it corresponding to NDEBUG */
|
|
||||||
#ifndef MDBX_DEBUG
|
|
||||||
# ifdef NDEBUG
|
|
||||||
# define MDBX_DEBUG 0
|
|
||||||
# else
|
|
||||||
# define MDBX_DEBUG 1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Undefine the NDEBUG if debugging is enforced by MDBX_DEBUG */
|
|
||||||
#if MDBX_DEBUG
|
|
||||||
# undef NDEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef xMDBX_ALLOY
|
#ifdef xMDBX_ALLOY
|
||||||
/* Amalgamated build */
|
/* Amalgamated build */
|
||||||
# define MDBX_INTERNAL_FUNC static
|
#define MDBX_INTERNAL_FUNC static
|
||||||
# define MDBX_INTERNAL_VAR static
|
#define MDBX_INTERNAL_VAR static
|
||||||
#else
|
#else
|
||||||
/* Non-amalgamated build */
|
/* Non-amalgamated build */
|
||||||
# define MDBX_INTERNAL_FUNC
|
#define MDBX_INTERNAL_FUNC
|
||||||
# define MDBX_INTERNAL_VAR extern
|
#define MDBX_INTERNAL_VAR extern
|
||||||
#endif /* xMDBX_ALLOY */
|
#endif /* xMDBX_ALLOY */
|
||||||
|
|
||||||
|
/** Disables using GNU/Linux libc extensions.
|
||||||
|
* \ingroup build_option
|
||||||
|
* \note This option couldn't be moved to the options.h since dependant
|
||||||
|
* control macros/defined should be prepared before include the options.h */
|
||||||
#ifndef MDBX_DISABLE_GNU_SOURCE
|
#ifndef MDBX_DISABLE_GNU_SOURCE
|
||||||
#define MDBX_DISABLE_GNU_SOURCE 0
|
#define MDBX_DISABLE_GNU_SOURCE 0
|
||||||
#endif
|
#endif
|
||||||
@ -55,13 +42,13 @@
|
|||||||
#undef _GNU_SOURCE
|
#undef _GNU_SOURCE
|
||||||
#elif (defined(__linux__) || defined(__gnu_linux__)) && !defined(_GNU_SOURCE)
|
#elif (defined(__linux__) || defined(__gnu_linux__)) && !defined(_GNU_SOURCE)
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#endif
|
#endif /* MDBX_DISABLE_GNU_SOURCE */
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Should be defined before any includes */
|
/* Should be defined before any includes */
|
||||||
#ifndef _FILE_OFFSET_BITS
|
#ifndef _FILE_OFFSET_BITS
|
||||||
# define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -69,107 +56,117 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# if _MSC_FULL_VER < 190024234
|
#if _MSC_FULL_VER < 190024234
|
||||||
/* Actually libmdbx was not tested with compilers older than 19.00.24234 (Visual Studio 2015 Update 3).
|
/* Actually libmdbx was not tested with compilers older than 19.00.24234 (Visual
|
||||||
* But you could remove this #error and try to continue at your own risk.
|
* Studio 2015 Update 3). But you could remove this #error and try to continue
|
||||||
* In such case please don't rise up an issues related ONLY to old compilers.
|
* at your own risk. In such case please don't rise up an issues related ONLY to
|
||||||
|
* old compilers.
|
||||||
*/
|
*/
|
||||||
# error "At least \"Microsoft C/C++ Compiler\" version 19.00.24234 (Visual Studio 2015 Update 3) is required."
|
#error \
|
||||||
# endif
|
"At least \"Microsoft C/C++ Compiler\" version 19.00.24234 (Visual Studio 2015 Update 3) is required."
|
||||||
# ifndef _CRT_SECURE_NO_WARNINGS
|
#endif
|
||||||
# define _CRT_SECURE_NO_WARNINGS
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
# endif
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
#if _MSC_VER > 1800
|
#if _MSC_VER > 1800
|
||||||
# pragma warning(disable : 4464) /* relative include path contains '..' */
|
#pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||||
#endif
|
#endif
|
||||||
#if _MSC_VER > 1913
|
#if _MSC_VER > 1913
|
||||||
# pragma warning(disable : 5045) /* Compiler will insert Spectre mitigation... */
|
#pragma warning(disable : 5045) /* Compiler will insert Spectre mitigation... \
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
#pragma warning(disable : 4710) /* 'xyz': function not inlined */
|
#pragma warning(disable : 4710) /* 'xyz': function not inlined */
|
||||||
#pragma warning(disable : 4711) /* function 'xyz' selected for automatic inline expansion */
|
#pragma warning(disable : 4711) /* function 'xyz' selected for automatic \
|
||||||
#pragma warning(disable : 4201) /* nonstandard extension used : nameless struct / union */
|
inline expansion */
|
||||||
|
#pragma warning( \
|
||||||
|
disable : 4201) /* nonstandard extension used : nameless struct / union */
|
||||||
#pragma warning(disable : 4702) /* unreachable code */
|
#pragma warning(disable : 4702) /* unreachable code */
|
||||||
#pragma warning(disable : 4706) /* assignment within conditional expression */
|
#pragma warning(disable : 4706) /* assignment within conditional expression */
|
||||||
#pragma warning(disable : 4127) /* conditional expression is constant */
|
#pragma warning(disable : 4127) /* conditional expression is constant */
|
||||||
#pragma warning(disable : 4324) /* 'xyz': structure was padded due to alignment specifier */
|
#pragma warning(disable : 4324) /* 'xyz': structure was padded due to \
|
||||||
|
alignment specifier */
|
||||||
#pragma warning(disable : 4310) /* cast truncates constant value */
|
#pragma warning(disable : 4310) /* cast truncates constant value */
|
||||||
#pragma warning(disable : 4820) /* bytes padding added after data member for alignment */
|
#pragma warning( \
|
||||||
#pragma warning(disable : 4548) /* expression before comma has no effect; expected expression with side - effect */
|
disable : 4820) /* bytes padding added after data member for alignment */
|
||||||
#pragma warning(disable : 4366) /* the result of the unary '&' operator may be unaligned */
|
#pragma warning(disable : 4548) /* expression before comma has no effect; \
|
||||||
#pragma warning(disable : 4200) /* nonstandard extension used: zero-sized array in struct/union */
|
expected expression with side - effect */
|
||||||
#pragma warning(disable : 4204) /* nonstandard extension used: non-constant aggregate initializer */
|
#pragma warning(disable : 4366) /* the result of the unary '&' operator may be \
|
||||||
#pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
unaligned */
|
||||||
|
#pragma warning(disable : 4200) /* nonstandard extension used: zero-sized \
|
||||||
|
array in struct/union */
|
||||||
|
#pragma warning(disable : 4204) /* nonstandard extension used: non-constant \
|
||||||
|
aggregate initializer */
|
||||||
|
#pragma warning( \
|
||||||
|
disable : 4505) /* unreferenced local function has been removed */
|
||||||
#endif /* _MSC_VER (warnings) */
|
#endif /* _MSC_VER (warnings) */
|
||||||
|
|
||||||
#include "../mdbx.h"
|
#include "../mdbx.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
#if defined(__GNUC__) && !__GNUC_PREREQ(4,2)
|
#if defined(__GNUC__) && !__GNUC_PREREQ(4, 2)
|
||||||
/* Actually libmdbx was not tested with compilers older than GCC 4.2.
|
/* Actually libmdbx was not tested with compilers older than GCC 4.2.
|
||||||
* But you could ignore this warning at your own risk.
|
* But you could ignore this warning at your own risk.
|
||||||
* In such case please don't rise up an issues related ONLY to old compilers.
|
* In such case please don't rise up an issues related ONLY to old compilers.
|
||||||
*/
|
*/
|
||||||
# warning "libmdbx required GCC >= 4.2"
|
#warning "libmdbx required GCC >= 4.2"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__clang__) && !__CLANG_PREREQ(3,8)
|
#if defined(__clang__) && !__CLANG_PREREQ(3, 8)
|
||||||
/* Actually libmdbx was not tested with CLANG older than 3.8.
|
/* Actually libmdbx was not tested with CLANG older than 3.8.
|
||||||
* But you could ignore this warning at your own risk.
|
* But you could ignore this warning at your own risk.
|
||||||
* In such case please don't rise up an issues related ONLY to old compilers.
|
* In such case please don't rise up an issues related ONLY to old compilers.
|
||||||
*/
|
*/
|
||||||
# warning "libmdbx required CLANG >= 3.8"
|
#warning "libmdbx required CLANG >= 3.8"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2,12)
|
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 12)
|
||||||
/* Actually libmdbx was not tested with something older than glibc 2.12.
|
/* Actually libmdbx was not tested with something older than glibc 2.12.
|
||||||
* But you could ignore this warning at your own risk.
|
* But you could ignore this warning at your own risk.
|
||||||
* In such case please don't rise up an issues related ONLY to old systems.
|
* In such case please don't rise up an issues related ONLY to old systems.
|
||||||
*/
|
*/
|
||||||
# warning "libmdbx was only tested with GLIBC >= 2.12."
|
#warning "libmdbx was only tested with GLIBC >= 2.12."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __SANITIZE_THREAD__
|
#ifdef __SANITIZE_THREAD__
|
||||||
# warning "libmdbx don't compatible with ThreadSanitizer, you will get a lot of false-positive issues."
|
#warning \
|
||||||
|
"libmdbx don't compatible with ThreadSanitizer, you will get a lot of false-positive issues."
|
||||||
#endif /* __SANITIZE_THREAD__ */
|
#endif /* __SANITIZE_THREAD__ */
|
||||||
|
|
||||||
#if __has_warning("-Wnested-anon-types")
|
#if __has_warning("-Wnested-anon-types")
|
||||||
# if defined(__clang__)
|
#if defined(__clang__)
|
||||||
# pragma clang diagnostic ignored "-Wnested-anon-types"
|
#pragma clang diagnostic ignored "-Wnested-anon-types"
|
||||||
# elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
# pragma GCC diagnostic ignored "-Wnested-anon-types"
|
#pragma GCC diagnostic ignored "-Wnested-anon-types"
|
||||||
# else
|
#else
|
||||||
# pragma warning disable "nested-anon-types"
|
#pragma warning disable "nested-anon-types"
|
||||||
# endif
|
#endif
|
||||||
#endif /* -Wnested-anon-types */
|
#endif /* -Wnested-anon-types */
|
||||||
|
|
||||||
#if __has_warning("-Wconstant-logical-operand")
|
#if __has_warning("-Wconstant-logical-operand")
|
||||||
# if defined(__clang__)
|
#if defined(__clang__)
|
||||||
# pragma clang diagnostic ignored "-Wconstant-logical-operand"
|
#pragma clang diagnostic ignored "-Wconstant-logical-operand"
|
||||||
# elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
# pragma GCC diagnostic ignored "-Wconstant-logical-operand"
|
#pragma GCC diagnostic ignored "-Wconstant-logical-operand"
|
||||||
# else
|
#else
|
||||||
# pragma warning disable "constant-logical-operand"
|
#pragma warning disable "constant-logical-operand"
|
||||||
# endif
|
#endif
|
||||||
#endif /* -Wconstant-logical-operand */
|
#endif /* -Wconstant-logical-operand */
|
||||||
|
|
||||||
#if defined(__LCC__) && (__LCC__ <= 121)
|
#if defined(__LCC__) && (__LCC__ <= 121)
|
||||||
/* bug #2798 */
|
/* bug #2798 */
|
||||||
# pragma diag_suppress alignment_reduction_ignored
|
#pragma diag_suppress alignment_reduction_ignored
|
||||||
#elif defined(__ICC)
|
#elif defined(__ICC)
|
||||||
# pragma warning(disable: 3453 1366)
|
#pragma warning(disable : 3453 1366)
|
||||||
#elif __has_warning("-Walignment-reduction-ignored")
|
#elif __has_warning("-Walignment-reduction-ignored")
|
||||||
# if defined(__clang__)
|
#if defined(__clang__)
|
||||||
# pragma clang diagnostic ignored "-Walignment-reduction-ignored"
|
#pragma clang diagnostic ignored "-Walignment-reduction-ignored"
|
||||||
# elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
# pragma GCC diagnostic ignored "-Walignment-reduction-ignored"
|
#pragma GCC diagnostic ignored "-Walignment-reduction-ignored"
|
||||||
# else
|
#else
|
||||||
# pragma warning disable "alignment-reduction-ignored"
|
#pragma warning disable "alignment-reduction-ignored"
|
||||||
# endif
|
#endif
|
||||||
#endif /* -Walignment-reduction-ignored */
|
#endif /* -Walignment-reduction-ignored */
|
||||||
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
/* clang-format on */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -183,6 +180,11 @@ extern LIBMDBX_API const char *const mdbx_sourcery_anchor;
|
|||||||
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
|
/* Undefine the NDEBUG if debugging is enforced by MDBX_DEBUG */
|
||||||
|
#if MDBX_DEBUG
|
||||||
|
#undef NDEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Atomics */
|
/* Atomics */
|
||||||
|
|
||||||
@ -789,10 +791,6 @@ typedef struct MDBX_lockinfo {
|
|||||||
|
|
||||||
#define MDBX_LOCK_MAGIC ((MDBX_MAGIC << 8) + MDBX_LOCK_VERSION)
|
#define MDBX_LOCK_MAGIC ((MDBX_MAGIC << 8) + MDBX_LOCK_VERSION)
|
||||||
|
|
||||||
#ifndef MDBX_ASSUME_MALLOC_OVERHEAD
|
|
||||||
#define MDBX_ASSUME_MALLOC_OVERHEAD (sizeof(void *) * 2u)
|
|
||||||
#endif /* MDBX_ASSUME_MALLOC_OVERHEAD */
|
|
||||||
|
|
||||||
/* The maximum size of a database page.
|
/* The maximum size of a database page.
|
||||||
*
|
*
|
||||||
* It is 64K, but value-PAGEHDRSZ must fit in MDBX_page.mp_upper.
|
* It is 64K, but value-PAGEHDRSZ must fit in MDBX_page.mp_upper.
|
||||||
@ -1270,7 +1268,7 @@ MDBX_INTERNAL_FUNC void mdbx_debug_log_va(int level, const char *function,
|
|||||||
|
|
||||||
#define mdbx_audit_enabled() (0)
|
#define mdbx_audit_enabled() (0)
|
||||||
|
|
||||||
#if !defined(NDEBUG) || defined(MDBX_FORCE_ASSERTIONS)
|
#if !defined(NDEBUG) || MDBX_FORCE_ASSERTIONS
|
||||||
#define mdbx_assert_enabled() (1)
|
#define mdbx_assert_enabled() (1)
|
||||||
#else
|
#else
|
||||||
#define mdbx_assert_enabled() (0)
|
#define mdbx_assert_enabled() (0)
|
||||||
|
106
src/options.h
106
src/options.h
@ -17,30 +17,6 @@
|
|||||||
* The libmdbx 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 */
|
/** Using fcntl(F_FULLFSYNC) with 5-10 times slowdown */
|
||||||
#define MDBX_OSX_WANNA_DURABILITY 0
|
#define MDBX_OSX_WANNA_DURABILITY 0
|
||||||
/** Using fsync() with chance of data lost on power failure */
|
/** Using fsync() with chance of data lost on power failure */
|
||||||
@ -159,8 +135,9 @@
|
|||||||
#endif /* MDBX_FAKE_SPILL_WRITEMAP */
|
#endif /* MDBX_FAKE_SPILL_WRITEMAP */
|
||||||
|
|
||||||
/** Controls sort order of internal page number lists.
|
/** Controls sort order of internal page number lists.
|
||||||
* The database format depend on this option and libmdbx builded with different
|
* This mostly experimental/advanced option with not for regular MDBX users.
|
||||||
* option value are incompatible. */
|
* \warning The database format depend on this option and libmdbx builded with
|
||||||
|
* different option value are incompatible. */
|
||||||
#ifndef MDBX_PNL_ASCENDING
|
#ifndef MDBX_PNL_ASCENDING
|
||||||
#define MDBX_PNL_ASCENDING 0
|
#define MDBX_PNL_ASCENDING 0
|
||||||
#endif
|
#endif
|
||||||
@ -168,6 +145,59 @@
|
|||||||
#error MDBX_PNL_ASCENDING must be defined as 0 or 1
|
#error MDBX_PNL_ASCENDING must be defined as 0 or 1
|
||||||
#endif /* MDBX_PNL_ASCENDING */
|
#endif /* MDBX_PNL_ASCENDING */
|
||||||
|
|
||||||
|
/** Avoid dependence from MSVC CRT and use ntdll.dll instead. */
|
||||||
|
#ifndef MDBX_WITHOUT_MSVC_CRT
|
||||||
|
#define MDBX_WITHOUT_MSVC_CRT 1
|
||||||
|
#endif
|
||||||
|
#if !(MDBX_WITHOUT_MSVC_CRT == 0 || MDBX_WITHOUT_MSVC_CRT == 1)
|
||||||
|
#error MDBX_WITHOUT_MSVC_CRT must be defined as 0 or 1
|
||||||
|
#endif /* MDBX_WITHOUT_MSVC_CRT */
|
||||||
|
|
||||||
|
/** Size of buffer used during copying a environment/database file. */
|
||||||
|
#ifndef MDBX_ENVCOPY_WRITEBUF
|
||||||
|
#define MDBX_ENVCOPY_WRITEBUF 1048576u
|
||||||
|
#endif
|
||||||
|
#if MDBX_ENVCOPY_WRITEBUF < 65536u || MDBX_ENVCOPY_WRITEBUF > 1073741824u || \
|
||||||
|
MDBX_ENVCOPY_WRITEBUF % 65536u
|
||||||
|
#error MDBX_ENVCOPY_WRITEBUF must be defined in range 65536..1073741824 and be multiple of 65536
|
||||||
|
#endif /* MDBX_ENVCOPY_WRITEBUF */
|
||||||
|
|
||||||
|
/** Forces assertion checking */
|
||||||
|
#ifndef MDBX_FORCE_ASSERTIONS
|
||||||
|
#define MDBX_FORCE_ASSERTIONS 1
|
||||||
|
#endif
|
||||||
|
#if !(MDBX_FORCE_ASSERTIONS == 0 || MDBX_FORCE_ASSERTIONS == 1)
|
||||||
|
#error MDBX_FORCE_ASSERTIONS must be defined as 0 or 1
|
||||||
|
#endif /* MDBX_FORCE_ASSERTIONS */
|
||||||
|
|
||||||
|
/** Presumed malloc size overhead for each allocation
|
||||||
|
* to adjust allocations to be more aligned. */
|
||||||
|
#ifndef MDBX_ASSUME_MALLOC_OVERHEAD
|
||||||
|
#define MDBX_ASSUME_MALLOC_OVERHEAD (sizeof(void *) * 2u)
|
||||||
|
#elif MDBX_ASSUME_MALLOC_OVERHEAD < 0 || MDBX_ASSUME_MALLOC_OVERHEAD > 64 || \
|
||||||
|
MDBX_ASSUME_MALLOC_OVERHEAD % 4
|
||||||
|
#error MDBX_ASSUME_MALLOC_OVERHEAD must be defined in range 0..64 and be multiple of 4
|
||||||
|
#endif /* MDBX_ASSUME_MALLOC_OVERHEAD */
|
||||||
|
|
||||||
|
/** In case the MDBX_DEBUG is undefined set it corresponding to NDEBUG */
|
||||||
|
#ifndef MDBX_DEBUG
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#define MDBX_DEBUG 0
|
||||||
|
#else
|
||||||
|
#define MDBX_DEBUG 1
|
||||||
|
#endif
|
||||||
|
#endif /* MDBX_DEBUG */
|
||||||
|
|
||||||
|
/** If defined then enables integration with Valgrind,
|
||||||
|
* a memory analyzing tool. */
|
||||||
|
#ifndef MDBX_USE_VALGRIND
|
||||||
|
#endif /* MDBX_USE_VALGRIND */
|
||||||
|
|
||||||
|
/** If defined then enables use C11 atomics,
|
||||||
|
* otherwise detects ones availability automatically. */
|
||||||
|
#ifndef MDBX_HAVE_C11ATOMICS
|
||||||
|
#endif /* MDBX_HAVE_C11ATOMICS */
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Win32 File Locking API for \ref MDBX_LOCKING */
|
/** Win32 File Locking API for \ref MDBX_LOCKING */
|
||||||
@ -364,3 +394,27 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user