mdbx: support for building by GCC 4.8

Change-Id: I4ad5c5be60233ae68936e0cbca1a0f01ec786bad
This commit is contained in:
Leonid Yuriev 2020-09-13 19:50:53 +03:00
parent 1bc49f680d
commit 17d9ed31f9
6 changed files with 28 additions and 8 deletions

View File

@ -440,7 +440,7 @@ if(MDBX_CXX_STANDARD GREATER_EQUAL 11 AND MDBX_CXX_STANDARD LESS 83)
option(MDBX_ENABLE_TESTS "Build MDBX tests" ${BUILD_TESTING}) option(MDBX_ENABLE_TESTS "Build MDBX tests" ${BUILD_TESTING})
endif() endif()
if(NOT MDBX_AVOID_CRT if(NOT MDBX_AVOID_CRT
AND NOT (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) AND NOT (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4) AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4)
AND NOT (MSVC AND MSVC_VERSION LESS 1900)) AND NOT (MSVC AND MSVC_VERSION LESS 1900))
option(MDBX_BUILD_CXX "Build C++ portion" ON) option(MDBX_BUILD_CXX "Build C++ portion" ON)

View File

@ -773,7 +773,7 @@ if(CMAKE_CXX_COMPILER_LOADED)
# determine library for for std::filesystem # determine library for for std::filesystem
set(LIBCXX_FILESYSTEM "") set(LIBCXX_FILESYSTEM "")
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
set(LIBCXX_FILESYSTEM "stdc++fs") set(LIBCXX_FILESYSTEM "stdc++fs")
endif() endif()
elseif(CMAKE_COMPILER_IS_CLANG) elseif(CMAKE_COMPILER_IS_CLANG)

6
mdbx.h
View File

@ -396,8 +396,8 @@ typedef mode_t mdbx_mode_t;
#define cxx07_constexpr_var const #define cxx07_constexpr_var const
#elif !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || \ #elif !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || \
(defined(__LCC__) && __LCC__ < 124) || \ (defined(__LCC__) && __LCC__ < 124) || \
(defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) && \ (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && \
!defined(__LCC__)) || \ !defined(__clang__) && !defined(__LCC__)) || \
(defined(_MSC_VER) && _MSC_VER < 1910) || \ (defined(_MSC_VER) && _MSC_VER < 1910) || \
(defined(__clang__) && __clang_major__ < 4) (defined(__clang__) && __clang_major__ < 4)
#define cxx07_constexpr inline #define cxx07_constexpr inline
@ -1272,7 +1272,7 @@ enum MDBX_txn_flags_t {
* will be ready for use with \ref mdbx_txn_renew(). This flag allows to * will be ready for use with \ref mdbx_txn_renew(). This flag allows to
* preallocate memory and assign a reader slot, thus avoiding these operations * preallocate memory and assign a reader slot, thus avoiding these operations
* at the next start of the transaction. */ * at the next start of the transaction. */
#if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER < 1910 #if defined(__cplusplus) && !defined(__cpp_constexpr) && !defined(DOXYGEN)
MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT), MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT),
#else #else
MDBX_TXN_RDONLY_PREPARE = MDBX_RDONLY | MDBX_NOMEMINIT, MDBX_TXN_RDONLY_PREPARE = MDBX_RDONLY | MDBX_NOMEMINIT,

View File

@ -1399,7 +1399,7 @@ ceil_powerof2(size_t value, size_t granularity) {
MDBX_LIFORECLAIM | MDBX_EXCLUSIVE) MDBX_LIFORECLAIM | MDBX_EXCLUSIVE)
#define ENV_USABLE_FLAGS (ENV_CHANGEABLE_FLAGS | ENV_CHANGELESS_FLAGS) #define ENV_USABLE_FLAGS (ENV_CHANGEABLE_FLAGS | ENV_CHANGELESS_FLAGS)
#if !(defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1900) #if !defined(__cplusplus) || defined(__cpp_constexpr)
static __maybe_unused void static_checks(void) { static __maybe_unused void static_checks(void) {
STATIC_ASSERT_MSG(INT16_MAX - CORE_DBS == MDBX_MAX_DBI, STATIC_ASSERT_MSG(INT16_MAX - CORE_DBS == MDBX_MAX_DBI,
"Oops, MDBX_MAX_DBI or CORE_DBS?"); "Oops, MDBX_MAX_DBI or CORE_DBS?");

View File

@ -475,14 +475,24 @@ const std::string actor_config::serialize(const char *prefix) const {
result.append(params.pathname_log); result.append(params.pathname_log);
result.push_back('|'); result.push_back('|');
#if __cplusplus > 201400
static_assert(std::is_trivially_copyable<actor_params_pod>::value, static_assert(std::is_trivially_copyable<actor_params_pod>::value,
"actor_params_pod should by POD"); "actor_params_pod should by POD");
#else
static_assert(std::is_standard_layout<actor_params_pod>::value,
"actor_params_pod should by POD");
#endif
result.append(data2hex(static_cast<const actor_params_pod *>(&params), result.append(data2hex(static_cast<const actor_params_pod *>(&params),
sizeof(actor_params_pod), checksum)); sizeof(actor_params_pod), checksum));
result.push_back('|'); result.push_back('|');
#if __cplusplus > 201400
static_assert(std::is_trivially_copyable<actor_config_pod>::value, static_assert(std::is_trivially_copyable<actor_config_pod>::value,
"actor_config_pod should by POD"); "actor_config_pod should by POD");
#else
static_assert(std::is_standard_layout<actor_config_pod>::value,
"actor_config_pod should by POD");
#endif
result.append(data2hex(static_cast<const actor_config_pod *>(this), result.append(data2hex(static_cast<const actor_config_pod *>(this),
sizeof(actor_config_pod), checksum)); sizeof(actor_config_pod), checksum));
result.push_back('|'); result.push_back('|');
@ -527,8 +537,13 @@ bool actor_config::deserialize(const char *str, actor_config &config) {
TRACE("<< actor_config::deserialize: slash-3\n"); TRACE("<< actor_config::deserialize: slash-3\n");
return false; return false;
} }
#if __cplusplus > 201400
static_assert(std::is_trivially_copyable<actor_params_pod>::value, static_assert(std::is_trivially_copyable<actor_params_pod>::value,
"actor_params_pod should by POD"); "actor_params_pod should by POD");
#else
static_assert(std::is_standard_layout<actor_params_pod>::value,
"actor_params_pod should by POD");
#endif
if (!hex2data(str, slash, static_cast<actor_params_pod *>(&config.params), if (!hex2data(str, slash, static_cast<actor_params_pod *>(&config.params),
sizeof(actor_params_pod), checksum)) { sizeof(actor_params_pod), checksum)) {
TRACE("<< actor_config::deserialize: actor_params_pod(%.*s)\n", TRACE("<< actor_config::deserialize: actor_params_pod(%.*s)\n",
@ -542,8 +557,13 @@ bool actor_config::deserialize(const char *str, actor_config &config) {
TRACE("<< actor_config::deserialize: slash-4\n"); TRACE("<< actor_config::deserialize: slash-4\n");
return false; return false;
} }
#if __cplusplus > 201400
static_assert(std::is_trivially_copyable<actor_config_pod>::value, static_assert(std::is_trivially_copyable<actor_config_pod>::value,
"actor_config_pod should by POD"); "actor_config_pod should by POD");
#else
static_assert(std::is_standard_layout<actor_config_pod>::value,
"actor_config_pod should by POD");
#endif
if (!hex2data(str, slash, static_cast<actor_config_pod *>(&config), if (!hex2data(str, slash, static_cast<actor_config_pod *>(&config),
sizeof(actor_config_pod), checksum)) { sizeof(actor_config_pod), checksum)) {
TRACE("<< actor_config::deserialize: actor_config_pod(%.*s)\n", TRACE("<< actor_config::deserialize: actor_config_pod(%.*s)\n",

View File

@ -198,7 +198,7 @@ void __hot maker::pair(serial_t serial, const buffer &key, buffer &value,
void maker::setup(const config::actor_params_pod &actor, unsigned actor_id, void maker::setup(const config::actor_params_pod &actor, unsigned actor_id,
unsigned thread_number) { unsigned thread_number) {
#if !defined(_MSC_VER) || _MSC_VER > 1900 #if defined(__cpp_constexpr)
static_assert(unsigned(MDBX_INTEGERKEY | MDBX_REVERSEKEY | MDBX_DUPSORT | static_assert(unsigned(MDBX_INTEGERKEY | MDBX_REVERSEKEY | MDBX_DUPSORT |
MDBX_INTEGERDUP | MDBX_REVERSEDUP) < UINT16_MAX, MDBX_INTEGERDUP | MDBX_REVERSEDUP) < UINT16_MAX,
"WTF?"); "WTF?");
@ -317,7 +317,7 @@ void __hot maker::mk_begin(const serial_t serial, const essentials &params,
void __hot maker::mk_continue(const serial_t serial, const essentials &params, void __hot maker::mk_continue(const serial_t serial, const essentials &params,
result &out) { result &out) {
#if !defined(_MSC_VER) || _MSC_VER > 1900 #if defined(__cpp_constexpr)
static_assert( static_assert(
(essentials::prng_fill_flag & (essentials::prng_fill_flag &
unsigned(MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_INTEGERKEY | unsigned(MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_INTEGERKEY |