mirror of
https://github.com/isar/libmdbx.git
synced 2025-10-25 01:08:56 +08:00
mdbx: refine/rearrange build options.
Change-Id: Ic27bf2b1f22e7ed9e6a1db9a1ed2496b1bb1239b
This commit is contained in:
190
src/internals.h
190
src/internals.h
@@ -21,33 +21,20 @@
|
||||
#define MDBX_DEPRECATED
|
||||
#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
|
||||
/* Amalgamated build */
|
||||
# define MDBX_INTERNAL_FUNC static
|
||||
# define MDBX_INTERNAL_VAR static
|
||||
#define MDBX_INTERNAL_FUNC static
|
||||
#define MDBX_INTERNAL_VAR static
|
||||
#else
|
||||
/* Non-amalgamated build */
|
||||
# define MDBX_INTERNAL_FUNC
|
||||
# define MDBX_INTERNAL_VAR extern
|
||||
#define MDBX_INTERNAL_FUNC
|
||||
#define MDBX_INTERNAL_VAR extern
|
||||
#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
|
||||
#define MDBX_DISABLE_GNU_SOURCE 0
|
||||
#endif
|
||||
@@ -55,13 +42,13 @@
|
||||
#undef _GNU_SOURCE
|
||||
#elif (defined(__linux__) || defined(__gnu_linux__)) && !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#endif /* MDBX_DISABLE_GNU_SOURCE */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Should be defined before any includes */
|
||||
#ifndef _FILE_OFFSET_BITS
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
@@ -69,107 +56,117 @@
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if _MSC_FULL_VER < 190024234
|
||||
/* Actually libmdbx was not tested with compilers older than 19.00.24234 (Visual Studio 2015 Update 3).
|
||||
* But you could remove this #error and try to continue 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."
|
||||
# endif
|
||||
# ifndef _CRT_SECURE_NO_WARNINGS
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
# endif
|
||||
#if _MSC_FULL_VER < 190024234
|
||||
/* Actually libmdbx was not tested with compilers older than 19.00.24234 (Visual
|
||||
* Studio 2015 Update 3). But you could remove this #error and try to continue
|
||||
* 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."
|
||||
#endif
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#if _MSC_VER > 1800
|
||||
# pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||
#pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||
#endif
|
||||
#if _MSC_VER > 1913
|
||||
# pragma warning(disable : 5045) /* Compiler will insert Spectre mitigation... */
|
||||
#pragma warning(disable : 5045) /* Compiler will insert Spectre mitigation... \
|
||||
*/
|
||||
#endif
|
||||
#pragma warning(disable : 4710) /* 'xyz': function not inlined */
|
||||
#pragma warning(disable : 4711) /* function 'xyz' selected for automatic inline expansion */
|
||||
#pragma warning(disable : 4201) /* nonstandard extension used : nameless struct / union */
|
||||
#pragma warning(disable : 4711) /* function 'xyz' selected for automatic \
|
||||
inline expansion */
|
||||
#pragma warning( \
|
||||
disable : 4201) /* nonstandard extension used : nameless struct / union */
|
||||
#pragma warning(disable : 4702) /* unreachable code */
|
||||
#pragma warning(disable : 4706) /* assignment within conditional expression */
|
||||
#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 : 4820) /* bytes padding added after data member for alignment */
|
||||
#pragma warning(disable : 4548) /* expression before comma has no effect; expected expression with side - effect */
|
||||
#pragma warning(disable : 4366) /* the result of the unary '&' operator may be 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) */
|
||||
#pragma warning( \
|
||||
disable : 4820) /* bytes padding added after data member for alignment */
|
||||
#pragma warning(disable : 4548) /* expression before comma has no effect; \
|
||||
expected expression with side - effect */
|
||||
#pragma warning(disable : 4366) /* the result of the unary '&' operator may be \
|
||||
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) */
|
||||
|
||||
#include "../mdbx.h"
|
||||
#include "defs.h"
|
||||
|
||||
#if defined(__GNUC__) && !__GNUC_PREREQ(4,2)
|
||||
/* Actually libmdbx was not tested with compilers older than GCC 4.2.
|
||||
* 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.
|
||||
*/
|
||||
# warning "libmdbx required GCC >= 4.2"
|
||||
#if defined(__GNUC__) && !__GNUC_PREREQ(4, 2)
|
||||
/* Actually libmdbx was not tested with compilers older than GCC 4.2.
|
||||
* 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.
|
||||
*/
|
||||
#warning "libmdbx required GCC >= 4.2"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && !__CLANG_PREREQ(3,8)
|
||||
/* Actually libmdbx was not tested with CLANG older than 3.8.
|
||||
* 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.
|
||||
*/
|
||||
# warning "libmdbx required CLANG >= 3.8"
|
||||
#if defined(__clang__) && !__CLANG_PREREQ(3, 8)
|
||||
/* Actually libmdbx was not tested with CLANG older than 3.8.
|
||||
* 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.
|
||||
*/
|
||||
#warning "libmdbx required CLANG >= 3.8"
|
||||
#endif
|
||||
|
||||
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2,12)
|
||||
/* Actually libmdbx was not tested with something older than glibc 2.12.
|
||||
* 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.
|
||||
*/
|
||||
# warning "libmdbx was only tested with GLIBC >= 2.12."
|
||||
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 12)
|
||||
/* Actually libmdbx was not tested with something older than glibc 2.12.
|
||||
* 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.
|
||||
*/
|
||||
#warning "libmdbx was only tested with GLIBC >= 2.12."
|
||||
#endif
|
||||
|
||||
#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__ */
|
||||
|
||||
#if __has_warning("-Wnested-anon-types")
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Wnested-anon-types"
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC diagnostic ignored "-Wnested-anon-types"
|
||||
# else
|
||||
# pragma warning disable "nested-anon-types"
|
||||
# endif
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wnested-anon-types"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wnested-anon-types"
|
||||
#else
|
||||
#pragma warning disable "nested-anon-types"
|
||||
#endif
|
||||
#endif /* -Wnested-anon-types */
|
||||
|
||||
#if __has_warning("-Wconstant-logical-operand")
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Wconstant-logical-operand"
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC diagnostic ignored "-Wconstant-logical-operand"
|
||||
# else
|
||||
# pragma warning disable "constant-logical-operand"
|
||||
# endif
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wconstant-logical-operand"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wconstant-logical-operand"
|
||||
#else
|
||||
#pragma warning disable "constant-logical-operand"
|
||||
#endif
|
||||
#endif /* -Wconstant-logical-operand */
|
||||
|
||||
#if defined(__LCC__) && (__LCC__ <= 121)
|
||||
/* bug #2798 */
|
||||
# pragma diag_suppress alignment_reduction_ignored
|
||||
/* bug #2798 */
|
||||
#pragma diag_suppress alignment_reduction_ignored
|
||||
#elif defined(__ICC)
|
||||
# pragma warning(disable: 3453 1366)
|
||||
#pragma warning(disable : 3453 1366)
|
||||
#elif __has_warning("-Walignment-reduction-ignored")
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Walignment-reduction-ignored"
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC diagnostic ignored "-Walignment-reduction-ignored"
|
||||
# else
|
||||
# pragma warning disable "alignment-reduction-ignored"
|
||||
# endif
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Walignment-reduction-ignored"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Walignment-reduction-ignored"
|
||||
#else
|
||||
#pragma warning disable "alignment-reduction-ignored"
|
||||
#endif
|
||||
#endif /* -Walignment-reduction-ignored */
|
||||
|
||||
/* *INDENT-ON* */
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -183,6 +180,11 @@ extern LIBMDBX_API const char *const mdbx_sourcery_anchor;
|
||||
|
||||
#include "options.h"
|
||||
|
||||
/* Undefine the NDEBUG if debugging is enforced by MDBX_DEBUG */
|
||||
#if MDBX_DEBUG
|
||||
#undef NDEBUG
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Atomics */
|
||||
|
||||
@@ -789,10 +791,6 @@ typedef struct MDBX_lockinfo {
|
||||
|
||||
#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.
|
||||
*
|
||||
* 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)
|
||||
|
||||
#if !defined(NDEBUG) || defined(MDBX_FORCE_ASSERTIONS)
|
||||
#if !defined(NDEBUG) || MDBX_FORCE_ASSERTIONS
|
||||
#define mdbx_assert_enabled() (1)
|
||||
#else
|
||||
#define mdbx_assert_enabled() (0)
|
||||
|
||||
Reference in New Issue
Block a user