mdbx-build: sourcery pinning (but cmake requires manually config-files removal for now).

This commit is contained in:
Leonid Yuriev 2019-09-05 11:57:52 +03:00
parent 0667f4f211
commit 449307a69f
20 changed files with 261 additions and 168 deletions

3
.gitignore vendored
View File

@ -29,4 +29,5 @@ test/tmp.db-lck
tmp.db tmp.db
tmp.db-lck tmp.db-lck
valgrind.* valgrind.*
version.c src/elements/version.c
src/elements/config.h

View File

@ -50,11 +50,13 @@ endif()
if(DEFINED PROJECT_NAME) if(DEFINED PROJECT_NAME)
set(SUBPROJECT ON) set(SUBPROJECT ON)
set(NOT_SUBPROJECT OFF)
if(NOT DEFINED BUILD_TESTING) if(NOT DEFINED BUILD_TESTING)
set(BUILD_TESTING OFF) set(BUILD_TESTING OFF)
endif() endif()
else() else()
set(SUBPROJECT OFF) set(SUBPROJECT OFF)
set(NOT_SUBPROJECT ON)
project(libmdbx C CXX) project(libmdbx C CXX)
if(NOT DEFINED BUILD_TESTING) if(NOT DEFINED BUILD_TESTING)
set(BUILD_TESTING ON) set(BUILD_TESTING ON)
@ -131,7 +133,6 @@ string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE)
include(cmake/utils.cmake) include(cmake/utils.cmake)
include(cmake/compiler.cmake) include(cmake/compiler.cmake)
include(cmake/profile.cmake) include(cmake/profile.cmake)
option(PROVIDE_VERSIONINFO "Provide library's version information." ON)
find_program(ECHO echo) find_program(ECHO echo)
find_program(CAT cat) find_program(CAT cat)
@ -159,13 +160,16 @@ find_package(Threads REQUIRED)
if(SUBPROJECT) if(SUBPROJECT)
if(NOT DEFINED BUILD_SHARED_LIBS) if(NOT DEFINED BUILD_SHARED_LIBS)
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)" OFF)
endif()
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independed (PIC)" ON)
endif() endif()
else() else()
option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independed (PIC)." ON) option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)" ON)
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." ON) option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independed (PIC)" ON)
if (CC_HAS_ARCH_NATIVE) if (CC_HAS_ARCH_NATIVE)
option(BUILD_FOR_NATIVE_CPU "Generate code for the compiling machine CPU." OFF) option(BUILD_FOR_NATIVE_CPU "Generate code for the compiling machine CPU" OFF)
endif() endif()
if(CMAKE_CONFIGURATION_TYPES OR NOT CMAKE_BUILD_TYPE_UPPERCASE STREQUAL "DEBUG") if(CMAKE_CONFIGURATION_TYPES OR NOT CMAKE_BUILD_TYPE_UPPERCASE STREQUAL "DEBUG")
@ -176,7 +180,7 @@ else()
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION_AVAILABLE if(CMAKE_INTERPROCEDURAL_OPTIMIZATION_AVAILABLE
OR GCC_LTO_AVAILABLE OR MSVC_LTO_AVAILABLE OR CLANG_LTO_AVAILABLE) OR GCC_LTO_AVAILABLE OR MSVC_LTO_AVAILABLE OR CLANG_LTO_AVAILABLE)
option(INTERPROCEDURAL_OPTIMIZATION "Enable interprocedural/LTO optimization." ${INTERPROCEDURAL_OPTIMIZATION_DEFAULT}) option(INTERPROCEDURAL_OPTIMIZATION "Enable interprocedural/LTO optimization" ${INTERPROCEDURAL_OPTIMIZATION_DEFAULT})
endif() endif()
if(INTERPROCEDURAL_OPTIMIZATION) if(INTERPROCEDURAL_OPTIMIZATION)
@ -276,16 +280,17 @@ option(MDBX_ENABLE_TESTS "Build MDBX tests." ${BUILD_TESTING})
# #
set(MDBX_BUILD_OPTIONS ENABLE_ASAN ENABLE_VALGRIND ENABLE_GPROF ENABLE_GCOV) set(MDBX_BUILD_OPTIONS ENABLE_ASAN ENABLE_VALGRIND ENABLE_GPROF ENABLE_GCOV)
add_mdbx_option(MDBX_BUILD_SHARED_LIBRARY "Build libmdbx as shared library (DLL)" ${BUILD_SHARED_LIBS})
add_mdbx_option(MDBX_ALLOY_BUILD "Build MDBX library as single object file" ON) add_mdbx_option(MDBX_ALLOY_BUILD "Build MDBX library as single object file" ON)
add_mdbx_option(MDBX_TXN_CHECKOWNER "Checking transaction matches the calling thread inside libmdbx's API" ON) add_mdbx_option(MDBX_TXN_CHECKOWNER "Checking transaction matches the calling thread inside libmdbx's API" ON)
add_mdbx_option(MDBX_TXN_CHECKPID "Paranoid checking PID inside libmdbx's API" OFF) add_mdbx_option(MDBX_TXN_CHECKPID "Paranoid checking PID inside libmdbx's API" AUTO)
mark_as_advanced(MDBX_TXN_CHECKPID) mark_as_advanced(MDBX_TXN_CHECKPID)
if(APPLE) if(APPLE)
add_mdbx_option(MDBX_OSX_SPEED_INSTEADOF_DURABILITY "Disable use fcntl(F_FULLFSYNC) in favor of speed" OFF) add_mdbx_option(MDBX_OSX_SPEED_INSTEADOF_DURABILITY "Disable use fcntl(F_FULLFSYNC) in favor of speed" OFF)
mark_as_advanced(MDBX_OSX_SPEED_INSTEADOF_DURABILITY) mark_as_advanced(MDBX_OSX_SPEED_INSTEADOF_DURABILITY)
endif() endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
add_mdbx_option(MDBX_AVOID_CRT "Avoid dependence from MSVC CRT" ${BUILD_SHARED_LIBS}) add_mdbx_option(MDBX_AVOID_CRT "Avoid dependence from MSVC CRT" ${NOT_SUBPROJECT})
if(NOT BUILD_SHARED_LIBS) if(NOT BUILD_SHARED_LIBS)
add_mdbx_option(MDBX_CONFIG_MANUAL_TLS_CALLBACK add_mdbx_option(MDBX_CONFIG_MANUAL_TLS_CALLBACK
"Provide mdbx_dll_callback() for manual initialization" OFF) "Provide mdbx_dll_callback() for manual initialization" OFF)
@ -301,27 +306,17 @@ endif()
################################################################################ ################################################################################
################################################################################ ################################################################################
################################################################################
if(PROVIDE_VERSIONINFO)
set(HAVE_MDBX_VERSIONINFO TRUE)
else()
set(HAVE_MDBX_VERSIONINFO FALSE)
endif()
add_subdirectory(src) add_subdirectory(src)
if(MDBX_ENABLE_TESTS) if(MDBX_ENABLE_TESTS)
add_subdirectory(test) add_subdirectory(test)
endif() endif()
if(HAVE_MDBX_VERSIONINFO) set(PACKAGE "libmdbx")
set(PACKAGE "libmdbx") set(CPACK_PACKAGE_VERSION_MAJOR ${MDBX_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MAJOR ${MDBX_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${MDBX_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_MINOR ${MDBX_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${MDBX_VERSION_RELEASE})
set(CPACK_PACKAGE_VERSION_PATCH ${MDBX_VERSION_RELEASE}) set(CPACK_PACKAGE_VERSION_COMMIT ${MDBX_VERSION_REVISION})
set(CPACK_PACKAGE_VERSION_COMMIT ${MDBX_VERSION_REVISION}) set(PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${CPACK_PACKAGE_VERSION_COMMIT}")
set(PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${CPACK_PACKAGE_VERSION_COMMIT}") message(STATUS "libmdbx package version is ${PACKAGE_VERSION}")
message(STATUS "libmdbx package version is ${PACKAGE_VERSION}")
endif()
cmake_policy(POP) cmake_policy(POP)

View File

@ -121,9 +121,8 @@ check-fault: all
; ./mdbx_chk -vvnw $(TESTDB) && ([ ! -e $(TESTDB)-copy ] || ./mdbx_chk -vvn $(TESTDB)-copy) ; ./mdbx_chk -vvnw $(TESTDB) && ([ ! -e $(TESTDB)-copy ] || ./mdbx_chk -vvn $(TESTDB)-copy)
MDBX_VERSION_GIT = ${shell set -o pipefail; git describe --tags | sed -n 's|^v*\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)\(.*\)|\1|p' || echo 'Please fetch tags and/or install latest git version'} MDBX_VERSION_GIT = ${shell set -o pipefail; git describe --tags | sed -n 's|^v*\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)\(.*\)|\1|p' || echo 'Please fetch tags and/or install latest git version'}
version.c: src/elements/version.c.in $(lastword $(MAKEFILE_LIST)) .git/HEAD .git/index .git/refs/tags src/elements/version.c: src/elements/version.c.in $(lastword $(MAKEFILE_LIST)) .git/HEAD .git/index .git/refs/tags
sed \ sed \
-e "s|@MDBX_BUILD_TIMESTAMP@|$(shell date +%Y-%m-%dT%H:%M:%S%z)|" \
-e "s|@MDBX_GIT_TIMESTAMP@|$(shell git show --no-patch --format=%cI HEAD || echo 'Please install latest get version')|" \ -e "s|@MDBX_GIT_TIMESTAMP@|$(shell git show --no-patch --format=%cI HEAD || echo 'Please install latest get version')|" \
-e "s|@MDBX_GIT_TREE@|$(shell git show --no-patch --format=%T HEAD || echo 'Please install latest get version')|" \ -e "s|@MDBX_GIT_TREE@|$(shell git show --no-patch --format=%T HEAD || echo 'Please install latest get version')|" \
-e "s|@MDBX_GIT_COMMIT@|$(shell git show --no-patch --format=%H HEAD || echo 'Please install latest get version')|" \ -e "s|@MDBX_GIT_COMMIT@|$(shell git show --no-patch --format=%H HEAD || echo 'Please install latest get version')|" \
@ -132,16 +131,18 @@ version.c: src/elements/version.c.in $(lastword $(MAKEFILE_LIST)) .git/HEAD .git
-e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_VERSION_GIT)' | cut -d . -f 2)|" \ -e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_VERSION_GIT)' | cut -d . -f 2)|" \
-e "s|\$${MDBX_VERSION_RELEASE}|$(shell echo '$(MDBX_VERSION_GIT)' | cut -d . -f 3)|" \ -e "s|\$${MDBX_VERSION_RELEASE}|$(shell echo '$(MDBX_VERSION_GIT)' | cut -d . -f 3)|" \
-e "s|\$${MDBX_VERSION_REVISION}|$(shell git rev-list --count --no-merges HEAD || echo 'Please fetch tags and/or install latest git version')|" \ -e "s|\$${MDBX_VERSION_REVISION}|$(shell git rev-list --count --no-merges HEAD || echo 'Please fetch tags and/or install latest git version')|" \
-e "s|@MDBX_OPTIONS_STRING@|$(MDBX_OPTIONS)|" \ src/elements/version.c.in > $@ || rm -f $@
-e "s|\$${MDBX_COMPILE_FLAGS}|$(CFLAGS) $(LDFLAGS)|" \
-e "s|@MDBX_BUILD_COMPILER@|$(shell set -o pipefail; $(CC) --version | head -1 || echo 'Please use GCC or CLANG compatible compiler')|" \
-e "s|\$${MDBX_BUILD_TARGET}|$(shell set -o pipefail; LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || echo 'Please use GCC or CLANG compatible compiler')|" \
src/elements/version.c.in > $@
version.o: version.c $(lastword $(MAKEFILE_LIST)) src/elements/config.h: src/elements/version.c $(lastword $(MAKEFILE_LIST))
$(CC) $(CFLAGS) $(MDBX_OPTIONS) -I./src -c version.c -o $@ (echo '#define MDBX_BUILD_TIMESTAMP "$(shell date +%Y-%m-%dT%H:%M:%S%z)"' \
&& echo '#define MDBX_BUILD_OPTIONS_STRING "$(MDBX_OPTIONS)"' \
&& echo '#define MDBX_BUILD_FLAGS "$(CFLAGS) $(LDFLAGS)"' \
&& echo '#define MDBX_BUILD_COMPILER "$(shell set -o pipefail; $(CC) --version | head -1 || echo 'Please use GCC or CLANG compatible compiler')"' \
&& echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || echo 'Please use GCC or CLANG compatible compiler')"' \
&& echo '#define MDBX_BUILD_SOURCERY $(shell set -o pipefail; ((openssl dgst -r -sha256 src/elements/version.c.in || sha256sum src/elements/version.c || shasum -a 256 src/elements/version.c) 2>/dev/null | cut -d ' ' -f 1 && echo -n `git describe --tags --long --dirty=-dirty`) | tr -c -s '[a-zA-Z0-9]' _ || echo 'Please install openssl or sha256sum or shasum')' \
) > $@ || rm -f $@
libmdbx.o: src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST)) libmdbx.o: src/elements/config.h src/elements/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
$(CC) $(CFLAGS) $(MDBX_OPTIONS) -c src/alloy.c -o $@ $(CC) $(CFLAGS) $(MDBX_OPTIONS) -c src/alloy.c -o $@
define test-rule define test-rule
@ -151,10 +152,10 @@ $(patsubst %.cc,%.o,$(1)): $(1) $(TEST_INC) mdbx.h $(lastword $(MAKEFILE_LIST))
endef endef
$(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file)))) $(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file))))
libmdbx.a: libmdbx.o version.o libmdbx.a: libmdbx.o
$(AR) rs $@ $? $(AR) rs $@ $?
libmdbx.$(SO_SUFFIX): libmdbx.o version.o libmdbx.$(SO_SUFFIX): libmdbx.o
$(CC) $(CFLAGS) $^ -pthread -shared $(LDFLAGS) -o $@ $(CC) $(CFLAGS) $^ -pthread -shared $(LDFLAGS) -o $@
mdbx_%: src/tools/mdbx_%.c libmdbx.a mdbx_%: src/tools/mdbx_%.c libmdbx.a

5
mdbx.h
View File

@ -197,6 +197,7 @@ typedef struct mdbx_version_info {
const char *commit; const char *commit;
const char *describe; const char *describe;
} git; } git;
const char *sourcery;
} mdbx_version_info; } mdbx_version_info;
typedef struct mdbx_build_info { typedef struct mdbx_build_info {
@ -211,7 +212,7 @@ extern LIBMDBX_API const mdbx_version_info mdbx_version;
extern LIBMDBX_API const mdbx_build_info mdbx_build; extern LIBMDBX_API const mdbx_build_info mdbx_build;
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
#ifndef MDBX_BUILD_DLL #if !MDBX_BUILD_SHARED_LIBRARY
/* Dll initialization callback for ability to dynamically load MDBX DLL by /* Dll initialization callback for ability to dynamically load MDBX DLL by
* LoadLibrary() on Windows versions before Windows Vista. This function MUST be * LoadLibrary() on Windows versions before Windows Vista. This function MUST be
@ -227,7 +228,7 @@ extern LIBMDBX_API const mdbx_build_info mdbx_build;
void LIBMDBX_API NTAPI mdbx_dll_callback(PVOID module, DWORD reason, void LIBMDBX_API NTAPI mdbx_dll_callback(PVOID module, DWORD reason,
PVOID reserved); PVOID reserved);
#endif /* MDBX_CONFIG_MANUAL_TLS_CALLBACK */ #endif /* MDBX_CONFIG_MANUAL_TLS_CALLBACK */
#endif /* MDBX_BUILD_DLL */ #endif /* !MDBX_BUILD_SHARED_LIBRARY */
#endif /* Windows */ #endif /* Windows */
/* The name of the lock file in the DB environment */ /* The name of the lock file in the DB environment */

View File

@ -13,12 +13,8 @@
## ##
# Get version # Get version
if(HAVE_MDBX_VERSIONINFO) fetch_version(MDBX "${CMAKE_CURRENT_SOURCE_DIR}/../VERSION")
fetch_version(MDBX "${CMAKE_CURRENT_SOURCE_DIR}/../VERSION") message(STATUS "libmdbx version is ${MDBX_VERSION}")
message(STATUS "libmdbx version is ${MDBX_VERSION}")
else()
set(MDBX_VERSION "unversioned")
endif()
if(MDBX_ALLOY_MODE) if(MDBX_ALLOY_MODE)
set(LIBMDBX_SOURCES alloy.c) set(LIBMDBX_SOURCES alloy.c)
@ -33,10 +29,10 @@ else()
elements/core.c elements/osal.c elements/lck-${LIBMDBX_OSAL}.c) elements/core.c elements/osal.c elements/lck-${LIBMDBX_OSAL}.c)
endif() endif()
list(APPEND LIBMDBX_SOURCES ../mdbx.h list(APPEND LIBMDBX_SOURCES ../mdbx.h
"${CMAKE_CURRENT_BINARY_DIR}/version.c" "${CMAKE_CURRENT_SOURCE_DIR}/elements/version.c"
"${CMAKE_CURRENT_BINARY_DIR}/mdbx-config.h") "${CMAKE_CURRENT_SOURCE_DIR}/elements/config.h")
if(BUILD_SHARED_LIBS) if(MDBX_BUILD_SHARED_LIBRARY)
add_library(mdbx SHARED ${LIBMDBX_SOURCES}) add_library(mdbx SHARED ${LIBMDBX_SOURCES})
target_compile_definitions(mdbx PRIVATE LIBMDBX_EXPORTS INTERFACE LIBMDBX_IMPORTS) target_compile_definitions(mdbx PRIVATE LIBMDBX_EXPORTS INTERFACE LIBMDBX_IMPORTS)
if(CC_HAS_VISIBILITY AND (LTO_ENABLED OR INTERPROCEDURAL_OPTIMIZATION)) if(CC_HAS_VISIBILITY AND (LTO_ENABLED OR INTERPROCEDURAL_OPTIMIZATION))
@ -52,43 +48,42 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(MSVC) if(MSVC)
if(NOT MSVC_LIB_EXE) if(NOT MSVC_LIB_EXE)
# Find lib.exe # Find lib.exe
get_filename_component (CL_NAME ${CMAKE_C_COMPILER} NAME) get_filename_component(CL_NAME ${CMAKE_C_COMPILER} NAME)
string (REPLACE cl.exe lib.exe MSVC_LIB_EXE ${CL_NAME}) string(REPLACE cl.exe lib.exe MSVC_LIB_EXE ${CL_NAME})
find_program(MSVC_LIB_EXE ${MSVC_LIB_EXE}) find_program(MSVC_LIB_EXE ${MSVC_LIB_EXE})
endif() endif()
if(MSVC_LIB_EXE) if(MSVC_LIB_EXE)
message (STATUS "Found MSVC's lib tool: ${MSVC_LIB_EXE}") message(STATUS "Found MSVC's lib tool: ${MSVC_LIB_EXE}")
set(MDBX_NTDLL_EXTRA_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.lib) set(MDBX_NTDLL_EXTRA_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.lib)
add_custom_command(OUTPUT ${MDBX_NTDLL_EXTRA_IMPLIB} add_custom_command(OUTPUT ${MDBX_NTDLL_EXTRA_IMPLIB}
COMMENT "Create extra-import-library for ntdll.dll" COMMENT "Create extra-import-library for ntdll.dll"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def"
COMMAND ${MSVC_LIB_EXE} /def:"${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" /out:"${MDBX_NTDLL_EXTRA_IMPLIB}" ${INITIAL_CMAKE_STATIC_LINKER_FLAGS}) COMMAND ${MSVC_LIB_EXE} /def:"${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" /out:"${MDBX_NTDLL_EXTRA_IMPLIB}" ${INITIAL_CMAKE_STATIC_LINKER_FLAGS})
else() else()
message (SEND_ERROR "MSVC's lib tool not found") message(SEND_ERROR "MSVC's lib tool not found")
endif() endif()
elseif(MINGW OR MINGW64) elseif(MINGW OR MINGW64)
if(NOT DLLTOOL) if(NOT DLLTOOL)
# Find dlltool # Find dlltool
get_filename_component (GCC_NAME ${CMAKE_C_COMPILER} NAME) get_filename_component(GCC_NAME ${CMAKE_C_COMPILER} NAME)
string (REPLACE gcc dlltool DLLTOOL_NAME ${GCC_NAME}) string(REPLACE gcc dlltool DLLTOOL_NAME ${GCC_NAME})
find_program (DLLTOOL NAMES ${DLLTOOL_NAME}) find_program(DLLTOOL NAMES ${DLLTOOL_NAME})
endif() endif()
if(DLLTOOL) if(DLLTOOL)
message (STATUS "Found dlltool: ${DLLTOOL}") message(STATUS "Found dlltool: ${DLLTOOL}")
set(MDBX_NTDLL_EXTRA_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.a") set(MDBX_NTDLL_EXTRA_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.a")
add_custom_command(OUTPUT ${MDBX_NTDLL_EXTRA_IMPLIB} add_custom_command(OUTPUT ${MDBX_NTDLL_EXTRA_IMPLIB}
COMMENT "Create extra-import-library for ntdll.dll" COMMENT "Create extra-import-library for ntdll.dll"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def"
COMMAND ${DLLTOOL} -d "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" -l "${MDBX_NTDLL_EXTRA_IMPLIB}") COMMAND ${DLLTOOL} -d "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" -l "${MDBX_NTDLL_EXTRA_IMPLIB}")
else() else()
message (SEND_ERROR "dlltool not found") message(SEND_ERROR "dlltool not found")
endif() endif()
endif() endif()
endif() endif()
target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ${CMAKE_THREAD_LIBS_INIT})
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_compile_definitions(mdbx ${MDBX_LIBDEP_MODE} MDBX_BUILD_DLL)
target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ntdll.lib) target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ntdll.lib)
if(MDBX_NTDLL_EXTRA_IMPLIB) if(MDBX_NTDLL_EXTRA_IMPLIB)
# LY: Sometimes Cmake requires a nightmarish magic for simple things. # LY: Sometimes Cmake requires a nightmarish magic for simple things.
@ -110,8 +105,6 @@ set_target_properties(mdbx PROPERTIES
C_STANDARD 11 C_STANDARD 11
C_STANDARD_REQUIRED OFF C_STANDARD_REQUIRED OFF
PUBLIC_HEADER "../mdbx.h") PUBLIC_HEADER "../mdbx.h")
target_include_directories(mdbx PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
if(CC_HAS_FASTMATH) if(CC_HAS_FASTMATH)
target_compile_options(mdbx PRIVATE "-ffast-math") target_compile_options(mdbx PRIVATE "-ffast-math")
@ -179,19 +172,19 @@ endif()
list(REMOVE_DUPLICATES mdbx_compile_options) list(REMOVE_DUPLICATES mdbx_compile_options)
# make string of space separated flags # make string of space separated flags
string(REPLACE ";" " " MDBX_COMPILE_FLAGS "${mdbx_compile_options}") string(REPLACE ";" " " MDBX_BUILD_FLAGS "${mdbx_compile_options}")
unset(mdbx_compile_options) unset(mdbx_compile_options)
string(STRIP "${MDBX_COMPILE_FLAGS}${MDBX_DEFINITIONS}" MDBX_COMPILE_FLAGS) string(STRIP "${MDBX_BUILD_FLAGS}${MDBX_DEFINITIONS}" MDBX_BUILD_FLAGS)
if(CMAKE_CONFIGURATION_TYPES) if(CMAKE_CONFIGURATION_TYPES)
# add dynamic part via per-configuration define # add dynamic part via per-configuration define
message(STATUS "MDBX Compile Flags: ${MDBX_COMPILE_FLAGS} <AND CONFIGURATION DEPENDENT>") message(STATUS "MDBX Compile Flags: ${MDBX_BUILD_FLAGS} <AND CONFIGURATION DEPENDENT>")
set(MDBX_COMPILE_FLAGS "${MDBX_COMPILE_FLAGS}") set(MDBX_BUILD_FLAGS "${MDBX_BUILD_FLAGS}")
add_definitions( add_definitions(
-DMDBX_COMPILE_FLAGS="$<$<CONFIG:Debug>:${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_DEFINES_DEBUG}>$<$<CONFIG:Release>:${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_DEFINES_RELEASE}>$<$<CONFIG:RelWithDebInfo>:${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CMAKE_C_DEFINES_RELWITHDEBINFO}>$<$<CONFIG:MinSizeRel>:${CMAKE_C_FLAGS_MINSIZEREL} ${CMAKE_C_DEFINES_MINSIZEREL}>" -DMDBX_COMPILE_FLAGS="$<$<CONFIG:Debug>:${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_DEFINES_DEBUG}>$<$<CONFIG:Release>:${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_DEFINES_RELEASE}>$<$<CONFIG:RelWithDebInfo>:${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CMAKE_C_DEFINES_RELWITHDEBINFO}>$<$<CONFIG:MinSizeRel>:${CMAKE_C_FLAGS_MINSIZEREL} ${CMAKE_C_DEFINES_MINSIZEREL}>"
) )
else() else()
message(STATUS "MDBX Compile Flags: ${MDBX_COMPILE_FLAGS}") message(STATUS "MDBX Compile Flags: ${MDBX_BUILD_FLAGS}")
set(MDBX_COMPILE_FLAGS "${MDBX_COMPILE_FLAGS}") set(MDBX_BUILD_FLAGS "${MDBX_BUILD_FLAGS}")
endif() endif()
# get compiler info # get compiler info
@ -201,11 +194,8 @@ execute_process(COMMAND sh -c "${CMAKE_C_COMPILER} --version | head -1"
ERROR_QUIET ERROR_QUIET
RESULT_VARIABLE rc) RESULT_VARIABLE rc)
if(rc OR NOT MDBX_BUILD_COMPILER) if(rc OR NOT MDBX_BUILD_COMPILER)
set(MDBX_BUILD_COMPILER "") string(STRIP "${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}" MDBX_BUILD_COMPILER)
else()
set(MDBX_BUILD_COMPILER " | ${MDBX_BUILD_COMPILER}" )
endif() endif()
string(STRIP "${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}${MDBX_BUILD_COMPILER}" MDBX_BUILD_COMPILER)
# make a build-target triplet # make a build-target triplet
if(CMAKE_C_COMPILER_TARGET) if(CMAKE_C_COMPILER_TARGET)
@ -229,15 +219,15 @@ endif()
# options # options
string(TIMESTAMP MDBX_BUILD_TIMESTAMP UTC) string(TIMESTAMP MDBX_BUILD_TIMESTAMP UTC)
set(MDBX_OPTIONS_STRING -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}") set(MDBX_BUILD_OPTIONS_STRING -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
foreach(item IN LISTS MDBX_BUILD_OPTIONS) foreach(item IN LISTS MDBX_BUILD_OPTIONS)
if(DEFINED ${item} AND NOT "${${item}}" STREQUAL "AUTO") if(DEFINED ${item} AND NOT "${${item}}" STREQUAL "AUTO")
string(APPEND MDBX_OPTIONS_STRING " -D${item}=${${item}}") string(APPEND MDBX_BUILD_OPTIONS_STRING " -D${item}=${${item}}")
message(STATUS "${item}: ${${item}}") message(STATUS "${item}: ${${item}}")
else() else()
unset(${item} CACHE) unset(${item} CACHE)
set(${item}_AUTO ON) set(${item}_AUTO ON)
string(APPEND MDBX_OPTIONS_STRING " -D${item}=AUTO") string(APPEND MDBX_BUILD_OPTIONS_STRING " -D${item}=AUTO")
message(STATUS "${item}: AUTO") message(STATUS "${item}: AUTO")
endif() endif()
endforeach() endforeach()
@ -257,12 +247,15 @@ foreach(item IN LISTS options)
message(STATUS "${item}: ${value}") message(STATUS "${item}: ${value}")
endforeach(item) endforeach(item)
# generate version file # generate version and config files
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/elements/version.c.in" configure_file("${CMAKE_CURRENT_SOURCE_DIR}/elements/version.c.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.c" ESCAPE_QUOTES) "${CMAKE_CURRENT_SOURCE_DIR}/elements/version.c" ESCAPE_QUOTES)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/elements/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/mdbx-config.h" ESCAPE_QUOTES)
target_compile_definitions(mdbx PRIVATE MDBX_CONFIG_H="${CMAKE_CURRENT_BINARY_DIR}/mdbx-config.h") file(SHA256 "${CMAKE_CURRENT_SOURCE_DIR}/elements/version.c" MDBX_SOURCERY_DIGEST)
string(MAKE_C_IDENTIFIER "${MDBX_GIT_DESCRIBE}" MDBX_SOURCERY_SUFFIX)
set(MDBX_BUILD_SOURCERY "${MDBX_SOURCERY_DIGEST}_${MDBX_SOURCERY_SUFFIX}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/elements/config.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/elements/config.h" ESCAPE_QUOTES)
add_subdirectory(tools) add_subdirectory(tools)

View File

@ -15,12 +15,9 @@
#define MDBX_ALLOY 1 #define MDBX_ALLOY 1
#include "elements/internals.h" /* must be included fisrt */ #include "elements/internals.h" /* must be included fisrt */
#include "../mdbx.h"
#include "elements/defs.h"
#include "elements/osal.h"
#include "elements/core.c" #include "elements/core.c"
#include "elements/osal.c" #include "elements/osal.c"
#include "elements/version.c"
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
#include "elements/lck-windows.c" #include "elements/lck-windows.c"

View File

@ -1,4 +1,7 @@
#cmakedefine HAVE_VALGRIND_MEMCHECK_H /* *INDENT-OFF* */
/* clang-format off */
#cmakedefine HAVE_VALGRIND_MEMCHECK_H
#cmakedefine HAS_RELAXED_CONSTEXPR #cmakedefine HAS_RELAXED_CONSTEXPR
#cmakedefine LTO_ENABLED #cmakedefine LTO_ENABLED
@ -7,16 +10,14 @@
#cmakedefine ENABLE_GCOV #cmakedefine ENABLE_GCOV
#cmakedefine ENABLE_ASAN #cmakedefine ENABLE_ASAN
#cmakedefine01 HAVE_MDBX_VERSIONINFO
/* Common */ /* Common */
#cmakedefine01 MDBX_TXN_CHECKPID #cmakedefine01 MDBX_TXN_CHECKPID
#cmakedefine01 MDBX_TXN_CHECKOWNER #cmakedefine01 MDBX_TXN_CHECKOWNER
#cmakedefine01 MDBX_BUILD_SHARED_LIBRARY
/* Windows */ /* Windows */
#cmakedefine MDBX_BUILD_DLL
#cmakedefine01 MDBX_CONFIG_MANUAL_TLS_CALLBACK #cmakedefine01 MDBX_CONFIG_MANUAL_TLS_CALLBACK
#cmakedefine MDBX_AVOID_CRT #cmakedefine01 MDBX_AVOID_CRT
/* MacOS */ /* MacOS */
#cmakedefine01 MDBX_OSX_SPEED_INSTEADOF_DURABILITY #cmakedefine01 MDBX_OSX_SPEED_INSTEADOF_DURABILITY
@ -26,6 +27,10 @@
#cmakedefine01 MDBX_USE_OFDLOCKS #cmakedefine01 MDBX_USE_OFDLOCKS
/* Simulate "AUTO" values of tristate options */ /* Simulate "AUTO" values of tristate options */
#cmakedefine MDBX_TXN_CHECKPID_AUTO
#ifdef MDBX_TXN_CHECKPID_AUTO
#undef MDBX_TXN_CHECKPID
#endif
#cmakedefine MDBX_USE_ROBUST_AUTO #cmakedefine MDBX_USE_ROBUST_AUTO
#ifdef MDBX_USE_ROBUST_AUTO #ifdef MDBX_USE_ROBUST_AUTO
#undef MDBX_USE_ROBUST #undef MDBX_USE_ROBUST
@ -34,3 +39,15 @@
#ifdef MDBX_USE_OFDLOCKS_AUTO #ifdef MDBX_USE_OFDLOCKS_AUTO
#undef MDBX_USE_OFDLOCKS #undef MDBX_USE_OFDLOCKS
#endif #endif
/* Build Info */
#cmakedefine MDBX_BUILD_TIMESTAMP "@MDBX_BUILD_TIMESTAMP@"
#cmakedefine MDBX_BUILD_TARGET "@MDBX_BUILD_TARGET@"
#cmakedefine MDBX_BUILD_CONFIG "@MDBX_BUILD_CONFIG@"
#cmakedefine MDBX_BUILD_OPTIONS_STRING "@MDBX_BUILD_OPTIONS_STRING@"
#cmakedefine MDBX_BUILD_COMPILER "@MDBX_BUILD_COMPILER@"
#cmakedefine MDBX_BUILD_FLAGS "@MDBX_BUILD_FLAGS@"
#cmakedefine MDBX_BUILD_SOURCERY @MDBX_BUILD_SOURCERY@
/* *INDENT-ON* */
/* clang-format on */

View File

@ -14686,6 +14686,53 @@ int mdbx_set_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
__dll_export
#ifdef __attribute_used__
__attribute_used__
#elif defined(__GNUC__) || __has_attribute(__used__)
__attribute__((__used__))
#endif
#ifdef __attribute_externally_visible__
__attribute_externally_visible__
#elif (defined(__GNUC__) && !defined(__clang__)) || \
__has_attribute(__externally_visible__)
__attribute__((__externally_visible__))
#endif
const mdbx_build_info mdbx_build = {
#ifdef MDBX_BUILD_TIMESTAMP
MDBX_BUILD_TIMESTAMP
#else
__DATE__ " " __TIME__
#endif
,
#ifdef MDBX_BUILD_TARGET
MDBX_BUILD_TARGET
#else
"UNKNOWN_BUILD_TARGET"
#endif
#ifdef MDBX_BUILD_CONFIG
"-" MDBX_BUILD_CONFIG
#endif
,
#ifdef MDBX_BUILD_OPTIONS_STRING
MDBX_BUILD_OPTIONS_STRING
#else
"@TODO: MDBX_BUILD_OPTIONS_STRING"
#endif
,
#ifdef MDBX_BUILD_COMPILER
MDBX_BUILD_COMPILER
#else
"@TODO: MDBX_BUILD_COMPILER"
#endif
,
#ifdef MDBX_BUILD_FLAGS
MDBX_BUILD_FLAGS
#else
"@TODO: MDBX_BUILD_FLAGS"
#endif
};
#ifdef __SANITIZE_ADDRESS__ #ifdef __SANITIZE_ADDRESS__
LIBMDBX_API __attribute__((__weak__)) const char *__asan_default_options() { LIBMDBX_API __attribute__((__weak__)) const char *__asan_default_options() {
return "symbolize=1:allow_addr2line=1:" return "symbolize=1:allow_addr2line=1:"

View File

@ -417,6 +417,9 @@ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
# define STRINGIFY(x) STRINGIFY_HELPER(x) # define STRINGIFY(x) STRINGIFY_HELPER(x)
#endif /* STRINGIFY */ #endif /* STRINGIFY */
#define CONCAT(a,b) a##b
#define XCONCAT(a,b) CONCAT(a,b)
#ifndef offsetof #ifndef offsetof
# define offsetof(type, member) __builtin_offsetof(type, member) # define offsetof(type, member) __builtin_offsetof(type, member)
#endif /* offsetof */ #endif /* offsetof */

View File

@ -15,9 +15,7 @@
/* *INDENT-OFF* */ /* *INDENT-OFF* */
/* clang-format off */ /* clang-format off */
#ifdef MDBX_CONFIG_H #include "config.h"
#include MDBX_CONFIG_H
#endif
/* In case the MDBX_DEBUG is undefined set it corresponding to NDEBUG */ /* In case the MDBX_DEBUG is undefined set it corresponding to NDEBUG */
#ifndef MDBX_DEBUG #ifndef MDBX_DEBUG
@ -153,6 +151,57 @@
#define MDBX_WORDBITS 32 #define MDBX_WORDBITS 32
#endif /* MDBX_WORDBITS */ #endif /* MDBX_WORDBITS */
/* Some platforms define the EOWNERDEAD error code even though they
* don't support Robust Mutexes. Compile with -DMDBX_USE_ROBUST=0. */
#ifndef MDBX_USE_ROBUST
#define MDBX_USE_ROBUST_CONFIG AUTO
/* Howard Chu: Android currently lacks Robust Mutex support */
#if defined(EOWNERDEAD) && !defined(__ANDROID__) && !defined(__APPLE__) && \
(!defined(__GLIBC__) || \
__GLIBC_PREREQ( \
2, \
10) /* LY: glibc before 2.10 has a troubles with Robust Mutex too. */ \
|| _POSIX_C_SOURCE >= 200809L)
#define MDBX_USE_ROBUST 1
#else
#define MDBX_USE_ROBUST 0
#endif
#else
#define MDBX_USE_ROBUST_CONFIG MDBX_USE_ROBUST
#endif /* MDBX_USE_ROBUST */
#ifndef MDBX_USE_OFDLOCKS
#define MDBX_USE_OFDLOCKS_CONFIG AUTO
#if defined(F_OFD_SETLK) && defined(F_OFD_SETLKW) && defined(F_OFD_GETLK)
#define MDBX_USE_OFDLOCKS 1
#else
#define MDBX_USE_OFDLOCKS 0
#endif
#else
#define MDBX_USE_OFDLOCKS_CONFIG MDBX_USE_OFDLOCKS
#endif /* MDBX_USE_OFDLOCKS */
/* Controls checking PID against reuse DB environment after the fork() */
#ifndef MDBX_TXN_CHECKPID
#define MDBX_TXN_CHECKPID_CONFIG AUTO
#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
#else
#define MDBX_TXN_CHECKPID_CONFIG MDBX_TXN_CHECKPID
#endif /* MDBX_TXN_CHECKPID */
#define mdbx_sourcery_anchor XCONCAT(mdbx_sourcery_, MDBX_BUILD_SOURCERY)
#if defined(MDBX_TOOLS)
extern LIBMDBX_API const char *const mdbx_sourcery_anchor;
#endif
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Basic constants and types */ /* Basic constants and types */
@ -202,11 +251,7 @@ typedef uint32_t pgno_t;
/* A transaction ID. */ /* A transaction ID. */
typedef uint64_t txnid_t; typedef uint64_t txnid_t;
#define PRIaTXN PRIi64 #define PRIaTXN PRIi64
#if MDBX_DEBUG
#define MIN_TXNID UINT64_C(0x100000000) #define MIN_TXNID UINT64_C(0x100000000)
#else
#define MIN_TXNID UINT64_C(1)
#endif /* MIN_TXNID */
/* Used for offsets within a single page. /* Used for offsets within a single page.
* Since memory pages are typically 4 or 8KB in size, 12-13 bits, * Since memory pages are typically 4 or 8KB in size, 12-13 bits,
@ -1274,16 +1319,3 @@ static __inline void mdbx_jitter4testing(bool tiny) {
(void)tiny; (void)tiny;
#endif #endif
} }
/* 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
#endif /* MDBX_TXN_CHECKPID */

View File

@ -14,30 +14,6 @@
#include "./internals.h" #include "./internals.h"
/* Some platforms define the EOWNERDEAD error code even though they
* don't support Robust Mutexes. Compile with -DMDBX_USE_ROBUST=0. */
#ifndef MDBX_USE_ROBUST
/* Howard Chu: Android currently lacks Robust Mutex support */
#if defined(EOWNERDEAD) && !defined(__ANDROID__) && !defined(__APPLE__) && \
(!defined(__GLIBC__) || \
__GLIBC_PREREQ( \
2, \
10) /* LY: glibc before 2.10 has a troubles with Robust Mutex too. */ \
|| _POSIX_C_SOURCE >= 200809L)
#define MDBX_USE_ROBUST 1
#else
#define MDBX_USE_ROBUST 0
#endif
#endif /* MDBX_USE_ROBUST */
#ifndef MDBX_USE_OFDLOCKS
#if defined(F_OFD_SETLK) && defined(F_OFD_SETLKW) && defined(F_OFD_GETLK)
#define MDBX_USE_OFDLOCKS 1
#else
#define MDBX_USE_OFDLOCKS 0
#endif
#endif /* MDBX_USE_OFDLOCKS */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* global constructor/destructor */ /* global constructor/destructor */

View File

@ -26,7 +26,7 @@
static void mdbx_winnt_import(void); static void mdbx_winnt_import(void);
#ifdef MDBX_BUILD_DLL #ifdef MDBX_BUILD_SHARED_LIBRARY
#if MDBX_AVOID_CRT && defined(NDEBUG) #if MDBX_AVOID_CRT && defined(NDEBUG)
/* DEBUG/CHECKED builds still require MSVC's CRT for runtime checks. /* DEBUG/CHECKED builds still require MSVC's CRT for runtime checks.
* *
@ -44,7 +44,7 @@ static
#endif /* !MDBX_CONFIG_MANUAL_TLS_CALLBACK */ #endif /* !MDBX_CONFIG_MANUAL_TLS_CALLBACK */
void NTAPI void NTAPI
mdbx_dll_callback(PVOID module, DWORD reason, PVOID reserved) mdbx_dll_callback(PVOID module, DWORD reason, PVOID reserved)
#endif /* MDBX_BUILD_DLL */ #endif /* MDBX_BUILD_SHARED_LIBRARY */
{ {
(void)reserved; (void)reserved;
switch (reason) { switch (reason) {
@ -62,12 +62,12 @@ static
mdbx_rthc_thread_dtor(module); mdbx_rthc_thread_dtor(module);
break; break;
} }
#ifdef MDBX_BUILD_DLL #if MDBX_BUILD_SHARED_LIBRARY
return TRUE; return TRUE;
#endif #endif
} }
#if !defined(MDBX_BUILD_DLL) && !MDBX_CONFIG_MANUAL_TLS_CALLBACK #if !MDBX_BUILD_SHARED_LIBRARY && !MDBX_CONFIG_MANUAL_TLS_CALLBACK
/* *INDENT-OFF* */ /* *INDENT-OFF* */
/* clang-format off */ /* clang-format off */
#if defined(_MSC_VER) #if defined(_MSC_VER)
@ -105,7 +105,7 @@ static
#endif #endif
/* *INDENT-ON* */ /* *INDENT-ON* */
/* clang-format on */ /* clang-format on */
#endif /* !defined(MDBX_BUILD_DLL) && !MDBX_CONFIG_MANUAL_TLS_CALLBACK */ #endif /* !MDBX_BUILD_SHARED_LIBRARY && !MDBX_CONFIG_MANUAL_TLS_CALLBACK */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/

View File

@ -34,7 +34,8 @@
#if !defined(_CRT_SECURE_NO_WARNINGS) #if !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif
#if !defined(_NO_CRT_STDIO_INLINE) && defined(MDBX_BUILD_DLL) #if !defined(_NO_CRT_STDIO_INLINE) && MDBX_BUILD_SHARED_LIBRARY && \
!defined(MDBX_TOOLS)
#define _NO_CRT_STDIO_INLINE #define _NO_CRT_STDIO_INLINE
#endif #endif
#endif /* Windows */ #endif /* Windows */
@ -109,7 +110,7 @@ typedef struct {
} mdbx_condmutex_t; } mdbx_condmutex_t;
typedef CRITICAL_SECTION mdbx_fastmutex_t; typedef CRITICAL_SECTION mdbx_fastmutex_t;
#ifdef MDBX_AVOID_CRT #if MDBX_AVOID_CRT
#ifndef mdbx_malloc #ifndef mdbx_malloc
static inline void *mdbx_malloc(size_t bytes) { static inline void *mdbx_malloc(size_t bytes) {
return LocalAlloc(LMEM_FIXED, bytes); return LocalAlloc(LMEM_FIXED, bytes);

View File

@ -12,14 +12,13 @@
* <http://www.OpenLDAP.org/license.html>. * <http://www.OpenLDAP.org/license.html>.
*/ */
#include "elements/internals.h" #include "internals.h"
#if defined(_MSC_VER) && defined(MDBX_BUILD_TARGET) #if defined(_MSC_VER) && defined(MDBX_BUILD_TARGET)
#pragma message("Configuration-depended MDBX_BUILD_TARGET: " MDBX_BUILD_TARGET) #pragma message("Configuration-depended MDBX_BUILD_TARGET: " MDBX_BUILD_TARGET)
#endif #endif
#if defined(_MSC_VER) && defined(MDBX_COMPILE_FLAGS) #if defined(_MSC_VER) && defined(MDBX_BUILD_FLAGS)
#pragma message( \ #pragma message("Configuration-depended MDBX_BUILD_FLAGS: " MDBX_BUILD_FLAGS)
"Configuration-depended MDBX_COMPILE_FLAGS: " MDBX_COMPILE_FLAGS)
#endif #endif
#if MDBX_VERSION_MAJOR != ${MDBX_VERSION_MAJOR} || \ #if MDBX_VERSION_MAJOR != ${MDBX_VERSION_MAJOR} || \
@ -27,19 +26,39 @@
#error "API version mismatch! Had `git fetch --tags` done?" #error "API version mismatch! Had `git fetch --tags` done?"
#endif #endif
/*LIBMDBX_API*/ const mdbx_version_info mdbx_version = { static const char sourcery[] = STRINGIFY(MDBX_BUILD_SOURCERY);
__dll_export
#ifdef __attribute_used__
__attribute_used__
#elif defined(__GNUC__) || __has_attribute(__used__)
__attribute__((__used__))
#endif
#ifdef __attribute_externally_visible__
__attribute_externally_visible__
#elif (defined(__GNUC__) && !defined(__clang__)) || \
__has_attribute(__externally_visible__)
__attribute__((__externally_visible__))
#endif
const mdbx_version_info mdbx_version = {
${MDBX_VERSION_MAJOR}, ${MDBX_VERSION_MAJOR},
${MDBX_VERSION_MINOR}, ${MDBX_VERSION_MINOR},
${MDBX_VERSION_RELEASE}, ${MDBX_VERSION_RELEASE},
${MDBX_VERSION_REVISION}, ${MDBX_VERSION_REVISION},
{"@MDBX_GIT_TIMESTAMP@", "@MDBX_GIT_TREE@", "@MDBX_GIT_COMMIT@", {"@MDBX_GIT_TIMESTAMP@", "@MDBX_GIT_TREE@", "@MDBX_GIT_COMMIT@",
"@MDBX_GIT_DESCRIBE@"}}; "@MDBX_GIT_DESCRIBE@"},
sourcery};
/*LIBMDBX_API*/ const mdbx_build_info mdbx_build = { __dll_export
"@MDBX_BUILD_TIMESTAMP@", #ifdef __attribute_used__
"${MDBX_BUILD_TARGET}" __attribute_used__
#ifdef DMDBX_BUILD_CONFIG #elif defined(__GNUC__) || __has_attribute(__used__)
"-" DMDBX_BUILD_CONFIG __attribute__((__used__))
#endif #endif
, #ifdef __attribute_externally_visible__
"@MDBX_OPTIONS_STRING@", "@MDBX_BUILD_COMPILER@", "${MDBX_COMPILE_FLAGS}"}; __attribute_externally_visible__
#elif (defined(__GNUC__) && !defined(__clang__)) || \
__has_attribute(__externally_visible__)
__attribute__((__externally_visible__))
#endif
const char *const mdbx_sourcery_anchor = sourcery;

View File

@ -13,7 +13,7 @@ foreach (TOOL ${MDBX_TOOLS})
add_executable(${TOOL} ${TOOL}.c) add_executable(${TOOL} ${TOOL}.c)
endif() endif()
target_link_libraries(${TOOL} mdbx) target_link_libraries(${TOOL} mdbx ${CMAKE_THREAD_LIBS_INIT})
set_target_properties(${TOOL} PROPERTIES set_target_properties(${TOOL} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>) INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)

View File

@ -938,14 +938,16 @@ int main(int argc, char *argv[]) {
case 'V': case 'V':
printf("mdbx_chk version %d.%d.%d.%d\n" printf("mdbx_chk version %d.%d.%d.%d\n"
" - source: %s %s, commit %s, tree %s\n" " - source: %s %s, commit %s, tree %s\n"
" - anchor: %s\n"
" - build: %s for %s by %s\n" " - build: %s for %s by %s\n"
" - flags: %s\n" " - flags: %s\n"
" - options: %s\n", " - options: %s\n",
mdbx_version.major, mdbx_version.minor, mdbx_version.release, mdbx_version.major, mdbx_version.minor, mdbx_version.release,
mdbx_version.revision, mdbx_version.git.describe, mdbx_version.revision, mdbx_version.git.describe,
mdbx_version.git.datetime, mdbx_version.git.commit, mdbx_version.git.datetime, mdbx_version.git.commit,
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target, mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options); mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
mdbx_build.options);
return EXIT_SUCCESS; return EXIT_SUCCESS;
case 'v': case 'v':
verbose++; verbose++;

View File

@ -58,14 +58,16 @@ int main(int argc, char *argv[]) {
else if (argv[1][1] == 'V' && argv[1][2] == '\0') { else if (argv[1][1] == 'V' && argv[1][2] == '\0') {
printf("mdbx_copy version %d.%d.%d.%d\n" printf("mdbx_copy version %d.%d.%d.%d\n"
" - source: %s %s, commit %s, tree %s\n" " - source: %s %s, commit %s, tree %s\n"
" - anchor: %s\n"
" - build: %s for %s by %s\n" " - build: %s for %s by %s\n"
" - flags: %s\n" " - flags: %s\n"
" - options: %s\n", " - options: %s\n",
mdbx_version.major, mdbx_version.minor, mdbx_version.release, mdbx_version.major, mdbx_version.minor, mdbx_version.release,
mdbx_version.revision, mdbx_version.git.describe, mdbx_version.revision, mdbx_version.git.describe,
mdbx_version.git.datetime, mdbx_version.git.commit, mdbx_version.git.datetime, mdbx_version.git.commit,
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target, mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options); mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
mdbx_build.options);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} else } else
argc = 0; argc = 0;

View File

@ -191,14 +191,16 @@ int main(int argc, char *argv[]) {
case 'V': case 'V':
printf("mdbx_dump version %d.%d.%d.%d\n" printf("mdbx_dump version %d.%d.%d.%d\n"
" - source: %s %s, commit %s, tree %s\n" " - source: %s %s, commit %s, tree %s\n"
" - anchor: %s\n"
" - build: %s for %s by %s\n" " - build: %s for %s by %s\n"
" - flags: %s\n" " - flags: %s\n"
" - options: %s\n", " - options: %s\n",
mdbx_version.major, mdbx_version.minor, mdbx_version.release, mdbx_version.major, mdbx_version.minor, mdbx_version.release,
mdbx_version.revision, mdbx_version.git.describe, mdbx_version.revision, mdbx_version.git.describe,
mdbx_version.git.datetime, mdbx_version.git.commit, mdbx_version.git.datetime, mdbx_version.git.commit,
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target, mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options); mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
mdbx_build.options);
return EXIT_SUCCESS; return EXIT_SUCCESS;
case 'l': case 'l':
list = 1; list = 1;

View File

@ -346,14 +346,16 @@ int main(int argc, char *argv[]) {
case 'V': case 'V':
printf("mdbx_load version %d.%d.%d.%d\n" printf("mdbx_load version %d.%d.%d.%d\n"
" - source: %s %s, commit %s, tree %s\n" " - source: %s %s, commit %s, tree %s\n"
" - anchor: %s\n"
" - build: %s for %s by %s\n" " - build: %s for %s by %s\n"
" - flags: %s\n" " - flags: %s\n"
" - options: %s\n", " - options: %s\n",
mdbx_version.major, mdbx_version.minor, mdbx_version.release, mdbx_version.major, mdbx_version.minor, mdbx_version.release,
mdbx_version.revision, mdbx_version.git.describe, mdbx_version.revision, mdbx_version.git.describe,
mdbx_version.git.datetime, mdbx_version.git.commit, mdbx_version.git.datetime, mdbx_version.git.commit,
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target, mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options); mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
mdbx_build.options);
return EXIT_SUCCESS; return EXIT_SUCCESS;
case 'a': case 'a':
append = 1; append = 1;

View File

@ -88,14 +88,16 @@ int main(int argc, char *argv[]) {
case 'V': case 'V':
printf("mdbx_stat version %d.%d.%d.%d\n" printf("mdbx_stat version %d.%d.%d.%d\n"
" - source: %s %s, commit %s, tree %s\n" " - source: %s %s, commit %s, tree %s\n"
" - anchor: %s\n"
" - build: %s for %s by %s\n" " - build: %s for %s by %s\n"
" - flags: %s\n" " - flags: %s\n"
" - options: %s\n", " - options: %s\n",
mdbx_version.major, mdbx_version.minor, mdbx_version.release, mdbx_version.major, mdbx_version.minor, mdbx_version.release,
mdbx_version.revision, mdbx_version.git.describe, mdbx_version.revision, mdbx_version.git.describe,
mdbx_version.git.datetime, mdbx_version.git.commit, mdbx_version.git.datetime, mdbx_version.git.commit,
mdbx_version.git.tree, mdbx_build.datetime, mdbx_build.target, mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
mdbx_build.compiler, mdbx_build.flags, mdbx_build.options); mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
mdbx_build.options);
return EXIT_SUCCESS; return EXIT_SUCCESS;
case 'a': case 'a':
if (subname) if (subname)