mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx: refine options and build-info.
Change-Id: Ib1a778dd27a0ea8b3a05484b2208e2222736b2d3
This commit is contained in:
parent
40ee895aae
commit
1ab33333bc
@ -78,7 +78,6 @@ MAN_SRCDIR := man1/
|
||||
|
||||
config.h: mdbx.c $(lastword $(MAKEFILE_LIST))
|
||||
(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')"' \
|
||||
@ -176,7 +175,6 @@ src/elements/version.c: src/elements/version.c.in $(lastword $(MAKEFILE_LIST)) .
|
||||
|
||||
src/elements/config.h: src/elements/version.c $(lastword $(MAKEFILE_LIST))
|
||||
(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')"' \
|
||||
|
@ -194,18 +194,6 @@ endif()
|
||||
|
||||
# options
|
||||
string(TIMESTAMP MDBX_BUILD_TIMESTAMP UTC)
|
||||
set(MDBX_BUILD_OPTIONS_STRING -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
|
||||
foreach(item IN LISTS MDBX_BUILD_OPTIONS)
|
||||
if(DEFINED ${item} AND NOT "${${item}}" STREQUAL "AUTO")
|
||||
string(APPEND MDBX_BUILD_OPTIONS_STRING " -D${item}=${${item}}")
|
||||
message(STATUS "${item}: ${${item}}")
|
||||
else()
|
||||
unset(${item} CACHE)
|
||||
set(${item}_AUTO ON)
|
||||
string(APPEND MDBX_BUILD_OPTIONS_STRING " -D${item}=AUTO")
|
||||
message(STATUS "${item}: AUTO")
|
||||
endif()
|
||||
endforeach()
|
||||
set(options VERSION C_COMPILER CXX_COMPILER DEFINITIONS)
|
||||
foreach(item IN LISTS options)
|
||||
if(DEFINED ${item})
|
||||
|
@ -47,7 +47,6 @@
|
||||
#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@
|
||||
|
@ -67,7 +67,7 @@ static __inline MDBX_node *NODEPTR(MDBX_page *p, unsigned i) {
|
||||
/* Get the page number pointed to by a branch node */
|
||||
static __inline pgno_t NODEPGNO(const MDBX_node *node) {
|
||||
pgno_t pgno;
|
||||
if (UNALIGNED_OK) {
|
||||
if (MDBX_UNALIGNED_OK) {
|
||||
pgno = node->mn_ksize_and_pgno;
|
||||
if (sizeof(pgno_t) > 4)
|
||||
pgno &= MAX_PAGENO;
|
||||
@ -83,7 +83,7 @@ static __inline pgno_t NODEPGNO(const MDBX_node *node) {
|
||||
static __inline void SETPGNO(MDBX_node *node, pgno_t pgno) {
|
||||
assert(pgno <= MAX_PAGENO);
|
||||
|
||||
if (UNALIGNED_OK) {
|
||||
if (MDBX_UNALIGNED_OK) {
|
||||
if (sizeof(pgno_t) > 4)
|
||||
pgno |= ((uint64_t)node->mn_ksize) << 48;
|
||||
node->mn_ksize_and_pgno = pgno;
|
||||
@ -98,7 +98,7 @@ static __inline void SETPGNO(MDBX_node *node, pgno_t pgno) {
|
||||
/* Get the size of the data in a leaf node */
|
||||
static __inline size_t NODEDSZ(const MDBX_node *node) {
|
||||
size_t size;
|
||||
if (UNALIGNED_OK) {
|
||||
if (MDBX_UNALIGNED_OK) {
|
||||
size = node->mn_dsize;
|
||||
} else {
|
||||
size = node->mn_lo | ((size_t)node->mn_hi << 16);
|
||||
@ -109,7 +109,7 @@ static __inline size_t NODEDSZ(const MDBX_node *node) {
|
||||
/* Set the size of the data for a leaf node */
|
||||
static __inline void SETDSZ(MDBX_node *node, size_t size) {
|
||||
assert(size < INT_MAX);
|
||||
if (UNALIGNED_OK) {
|
||||
if (MDBX_UNALIGNED_OK) {
|
||||
node->mn_dsize = (uint32_t)size;
|
||||
} else {
|
||||
node->mn_lo = (uint16_t)size;
|
||||
@ -7642,7 +7642,7 @@ static int __hot mdbx_cmp_int_a2(const MDBX_val *a, const MDBX_val *b) {
|
||||
mdbx_assert(NULL, a->iov_len == b->iov_len);
|
||||
mdbx_assert(NULL, 0 == (uintptr_t)a->iov_base % sizeof(uint16_t) &&
|
||||
0 == (uintptr_t)b->iov_base % sizeof(uint16_t));
|
||||
#if UNALIGNED_OK
|
||||
#if MDBX_UNALIGNED_OK
|
||||
switch (a->iov_len) {
|
||||
case 4:
|
||||
return mdbx_cmp2int(*(uint32_t *)a->iov_base, *(uint32_t *)b->iov_base);
|
||||
@ -7677,7 +7677,7 @@ static int __hot mdbx_cmp_int_a2(const MDBX_val *a, const MDBX_val *b) {
|
||||
} while (pa != end);
|
||||
return diff;
|
||||
}
|
||||
#endif /* UNALIGNED_OK */
|
||||
#endif /* MDBX_UNALIGNED_OK */
|
||||
}
|
||||
|
||||
/* Compare two items pointing at unsigneds of unknown alignment.
|
||||
@ -7685,7 +7685,7 @@ static int __hot mdbx_cmp_int_a2(const MDBX_val *a, const MDBX_val *b) {
|
||||
* This is also set as MDBX_INTEGERDUP|MDBX_DUPFIXED's MDBX_dbx.md_dcmp. */
|
||||
static int __hot mdbx_cmp_int_ua(const MDBX_val *a, const MDBX_val *b) {
|
||||
mdbx_assert(NULL, a->iov_len == b->iov_len);
|
||||
#if UNALIGNED_OK
|
||||
#if MDBX_UNALIGNED_OK
|
||||
switch (a->iov_len) {
|
||||
case 4:
|
||||
return mdbx_cmp2int(*(uint32_t *)a->iov_base, *(uint32_t *)b->iov_base);
|
||||
@ -7716,7 +7716,7 @@ static int __hot mdbx_cmp_int_ua(const MDBX_val *a, const MDBX_val *b) {
|
||||
#else /* __BYTE_ORDER__ */
|
||||
return memcmp(a->iov_base, b->iov_base, a->iov_len);
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
#endif /* UNALIGNED_OK */
|
||||
#endif /* MDBX_UNALIGNED_OK */
|
||||
}
|
||||
|
||||
/* Compare two items lexically */
|
||||
@ -15177,39 +15177,185 @@ __dll_export
|
||||
#endif
|
||||
const mdbx_build_info mdbx_build = {
|
||||
#ifdef MDBX_BUILD_TIMESTAMP
|
||||
MDBX_BUILD_TIMESTAMP
|
||||
MDBX_BUILD_TIMESTAMP
|
||||
#else
|
||||
__DATE__ " " __TIME__
|
||||
#endif
|
||||
,
|
||||
__DATE__ " " __TIME__
|
||||
#endif /* MDBX_BUILD_TIMESTAMP */
|
||||
|
||||
,
|
||||
#ifdef MDBX_BUILD_TARGET
|
||||
MDBX_BUILD_TARGET
|
||||
MDBX_BUILD_TARGET
|
||||
#else
|
||||
"UNKNOWN_BUILD_TARGET"
|
||||
#endif
|
||||
#if defined(__ANDROID__)
|
||||
"Android"
|
||||
#elif defined(__linux__) || defined(__gnu_linux__)
|
||||
"Linux"
|
||||
#elif defined(EMSCRIPTEN) || defined(__EMSCRIPTEN__)
|
||||
"webassembly"
|
||||
#elif defined(__CYGWIN__)
|
||||
"CYGWIN"
|
||||
#elif defined(_WIN64) || defined(_WIN32) || defined(__TOS_WIN__) \
|
||||
|| defined(__WINDOWS__)
|
||||
"Windows"
|
||||
#elif defined(__APPLE__)
|
||||
#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) \
|
||||
|| (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR)
|
||||
"iOS"
|
||||
#else
|
||||
"MacOS"
|
||||
#endif
|
||||
#elif defined(__FreeBSD__)
|
||||
"FreeBSD"
|
||||
#elif defined(__DragonFly__)
|
||||
"DragonFlyBSD"
|
||||
#elif defined(__NetBSD__) || defined(__NETBSD__)
|
||||
"NetBSD"
|
||||
#elif defined(__OpenBSD__)
|
||||
"OpenBSD"
|
||||
#elif defined(__bsdi__)
|
||||
"UnixBSDI"
|
||||
#elif defined(__MACH__)
|
||||
"MACH"
|
||||
#elif (defined(_HPUX_SOURCE) || defined(__hpux) || defined(__HP_aCC))
|
||||
"HPUX"
|
||||
#elif defined(_AIX)
|
||||
"AIX"
|
||||
#elif defined(__sun) && defined(__SVR4)
|
||||
"Solaris"
|
||||
#elif defined(__BSD__) || defined(BSD)
|
||||
"UnixBSD"
|
||||
#elif defined(__unix__) || defined(UNIX) || defined(__unix) \
|
||||
|| defined(__UNIX) || defined(__UNIX__)
|
||||
"UNIX"
|
||||
#elif defined(_POSIX_VERSION)
|
||||
"POSIX" STRINGIFY(_POSIX_VERSION)
|
||||
#else
|
||||
"UnknownOS"
|
||||
#endif /* Target OS */
|
||||
|
||||
"-"
|
||||
|
||||
#if defined(__amd64__)
|
||||
"AMD64"
|
||||
#elif defined(__ia32__)
|
||||
"IA32"
|
||||
#elif defined(__e2k__) || defined(__elbrus__)
|
||||
"Elbrus"
|
||||
#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
|
||||
"Alpha"
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
"ARM64"
|
||||
#elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) \
|
||||
|| defined(__TARGET_ARCH_THUMB) || defined(_ARM) || defined(_M_ARM) \
|
||||
|| defined(_M_ARMT) || defined(__arm)
|
||||
"ARM"
|
||||
#elif defined(__mips64) || defined(__mips64__) || (defined(__mips) && (__mips >= 64))
|
||||
"MIPS64"
|
||||
#elif if defined(__mips__) || defined(__mips) || defined(_R4000) || defined(__MIPS__)
|
||||
"MIPS"
|
||||
#elif defined(__hppa64__) || defined(__HPPA64__) || defined(__hppa64)
|
||||
"PARISC64"
|
||||
#elif defined(__hppa__) || defined(__HPPA__) || defined(__hppa)
|
||||
"PARISC"
|
||||
#elif defined(__ia64__) || defined(__ia64) || defined(_IA64) \
|
||||
|| defined(__IA64__) || defined(_M_IA64) || defined(__itanium__)
|
||||
"Itanium"
|
||||
#elif defined(__powerpc64__) || defined(__ppc64__) || defined(__ppc64) \
|
||||
|| defined(__powerpc64) || defined(_ARCH_PPC64)
|
||||
"PowerPC64"
|
||||
#elif defined(__powerpc__) || defined(__ppc__) || defined(__powerpc) \
|
||||
|| defined(__ppc) || defined(_ARCH_PPC) || defined(__PPC__) || defined(__POWERPC__)
|
||||
"PowerPC"
|
||||
#elif defined(__sparc64__) || defined(__sparc64)
|
||||
"SPARC64"
|
||||
#elif defined(__sparc__) || defined(__sparc)
|
||||
"SPARC"
|
||||
#elif defined(__s390__) || defined(__s390) || defined(__zarch__) || defined(__zarch)
|
||||
"S390"
|
||||
#else
|
||||
"UnknownARCH"
|
||||
#endif
|
||||
#endif /* MDBX_BUILD_TARGET */
|
||||
|
||||
#ifdef MDBX_BUILD_CONFIG
|
||||
"-" MDBX_BUILD_CONFIG
|
||||
#endif
|
||||
,
|
||||
#ifdef MDBX_BUILD_OPTIONS_STRING
|
||||
MDBX_BUILD_OPTIONS_STRING
|
||||
"-" MDBX_BUILD_CONFIG
|
||||
#endif /* MDBX_BUILD_CONFIG */
|
||||
,
|
||||
"MDBX_DEBUG=" STRINGIFY(MDBX_DEBUG)
|
||||
#ifdef MDBX_CONFIG_H
|
||||
" MDBX_CONFIG_H=" STRINGIFY(MDBX_CONFIG_H)
|
||||
#endif /* MDBX_CONFIG_H */
|
||||
" MDBX_WORDBITS=" STRINGIFY(MDBX_WORDBITS)
|
||||
" BYTE_ORDER="
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
"LITTLE_ENDIAN"
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
"BIG_ENDIAN"
|
||||
#else
|
||||
"@TODO: MDBX_BUILD_OPTIONS_STRING"
|
||||
#error "FIXME: Unsupported byte order"
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
" MDBX_TXN_CHECKPID=" STRINGIFY(MDBX_TXN_CHECKPID)
|
||||
" MDBX_TXN_CHECKOWNER=" STRINGIFY(MDBX_TXN_CHECKOWNER)
|
||||
" MDBX_64BIT_ATOMIC=" STRINGIFY(MDBX_64BIT_ATOMIC)
|
||||
#ifdef __APPLE__
|
||||
" MDBX_OSX_SPEED_INSTEADOF_DURABILITY=" STRINGIFY(MDBX_OSX_SPEED_INSTEADOF_DURABILITY)
|
||||
#endif /* MacOS */
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
" MDBX_AVOID_CRT=" STRINGIFY(MDBX_AVOID_CRT)
|
||||
" MDBX_CONFIG_MANUAL_TLS_CALLBACK=" STRINGIFY(MDBX_CONFIG_MANUAL_TLS_CALLBACK)
|
||||
" MDBX_BUILD_SHARED_LIBRARY=" STRINGIFY(MDBX_BUILD_SHARED_LIBRARY)
|
||||
" WINVER=" STRINGIFY(WINVER)
|
||||
#else /* Windows */
|
||||
" MDBX_USE_ROBUST=" MDBX_USE_ROBUST_CONFIG
|
||||
" MDBX_USE_OFDLOCKS=" MDBX_USE_OFDLOCKS_CONFIG
|
||||
#endif /* !Windows */
|
||||
#ifdef MDBX_OSAL_LOCK
|
||||
" MDBX_OSAL_LOCK=" STRINGIFY(MDBX_OSAL_LOCK)
|
||||
#endif
|
||||
,
|
||||
" MDBX_CACHELINE_SIZE=" STRINGIFY(MDBX_CACHELINE_SIZE)
|
||||
" MDBX_CPU_WRITEBACK_IS_COHERENT=" STRINGIFY(MDBX_CPU_WRITEBACK_IS_COHERENT)
|
||||
" MDBX_UNALIGNED_OK=" STRINGIFY(MDBX_UNALIGNED_OK)
|
||||
" MDBX_PNL_ASCENDING=" STRINGIFY(MDBX_PNL_ASCENDING)
|
||||
,
|
||||
#ifdef MDBX_BUILD_COMPILER
|
||||
MDBX_BUILD_COMPILER
|
||||
MDBX_BUILD_COMPILER
|
||||
#else
|
||||
"@TODO: MDBX_BUILD_COMPILER"
|
||||
#endif
|
||||
,
|
||||
#ifdef __INTEL_COMPILER
|
||||
"Intel C/C++ " STRINGIFY(__INTEL_COMPILER)
|
||||
#elsif defined(__apple_build_version__)
|
||||
"Apple clang " STRINGIFY(__apple_build_version__)
|
||||
#elif defined(__ibmxl__)
|
||||
"IBM clang C " STRINGIFY(__ibmxl_version__) "." STRINGIFY(__ibmxl_release__)
|
||||
"." STRINGIFY(__ibmxl_modification__) "." STRINGIFY(__ibmxl_ptf_fix_level__)
|
||||
#elif defined(__clang__)
|
||||
"clang " STRINGIFY(__clang_version__)
|
||||
#elif defined(__MINGW64__)
|
||||
"MINGW-64 " STRINGIFY(__MINGW64_MAJOR_VERSION) "." STRINGIFY(__MINGW64_MINOR_VERSION)
|
||||
#elif defined(__MINGW32__)
|
||||
"MINGW-32 " STRINGIFY(__MINGW32_MAJOR_VERSION) "." STRINGIFY(__MINGW32_MINOR_VERSION)
|
||||
#elif defined(__IBMC__)
|
||||
"IBM C " STRINGIFY(__IBMC__)
|
||||
#elif defined(__GNUC__)
|
||||
"GNU C/C++ "
|
||||
#ifdef __VERSION__
|
||||
__VERSION__
|
||||
#else
|
||||
STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
"MSVC " STRINGIFY(_MSC_FULL_VER) "-" STRINGIFY(_MSC_BUILD)
|
||||
#else
|
||||
"Unknown compiler"
|
||||
#endif
|
||||
#endif /* MDBX_BUILD_COMPILER */
|
||||
,
|
||||
#ifdef MDBX_BUILD_FLAGS
|
||||
MDBX_BUILD_FLAGS
|
||||
#endif
|
||||
MDBX_BUILD_FLAGS
|
||||
#endif /* MDBX_BUILD_FLAGS */
|
||||
#ifdef MDBX_BUILD_FLAGS_CONFIG
|
||||
MDBX_BUILD_FLAGS_CONFIG
|
||||
#endif
|
||||
};
|
||||
MDBX_BUILD_FLAGS_CONFIG
|
||||
#endif /* MDBX_BUILD_FLAGS_CONFIG */
|
||||
};
|
||||
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
LIBMDBX_API __attribute__((__weak__)) const char *__asan_default_options() {
|
||||
|
@ -164,7 +164,6 @@
|
||||
/* 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__) || \
|
||||
@ -176,25 +175,25 @@
|
||||
#else
|
||||
#define MDBX_USE_ROBUST 0
|
||||
#endif
|
||||
#define MDBX_USE_ROBUST_CONFIG "AUTO=" STRINGIFY(MDBX_USE_ROBUST)
|
||||
#else
|
||||
#define MDBX_USE_ROBUST_CONFIG MDBX_USE_ROBUST
|
||||
#define MDBX_USE_ROBUST_CONFIG STRINGIFY(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) && \
|
||||
!defined(MDBX_SAFE4QEMU)
|
||||
#define MDBX_USE_OFDLOCKS 1
|
||||
#else
|
||||
#define MDBX_USE_OFDLOCKS 0
|
||||
#endif
|
||||
#define MDBX_USE_OFDLOCKS_CONFIG "AUTO=" STRINGIFY(MDBX_USE_OFDLOCKS)
|
||||
#else
|
||||
#define MDBX_USE_OFDLOCKS_CONFIG MDBX_USE_OFDLOCKS
|
||||
#define MDBX_USE_OFDLOCKS_CONFIG STRINGIFY(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()
|
||||
@ -209,7 +208,6 @@
|
||||
#endif /* MDBX_TXN_CHECKPID */
|
||||
|
||||
#ifndef MDBX_TXN_CHECKOWNER
|
||||
#define MDBX_TXN_CHECKOWNER_CONFIG AUTO
|
||||
#define MDBX_TXN_CHECKOWNER 1
|
||||
#endif /* MDBX_TXN_CHECKOWNER */
|
||||
|
||||
|
@ -234,15 +234,15 @@ typedef pthread_mutex_t mdbx_fastmutex_t;
|
||||
#endif /* __amd64__ */
|
||||
#endif /* all x86 */
|
||||
|
||||
#if !defined(UNALIGNED_OK)
|
||||
#if !defined(MDBX_UNALIGNED_OK)
|
||||
#if (defined(__ia32__) || defined(__e2k__) || \
|
||||
defined(__ARM_FEATURE_UNALIGNED)) && \
|
||||
!defined(__ALIGNED__)
|
||||
#define UNALIGNED_OK 1
|
||||
#define MDBX_UNALIGNED_OK 1
|
||||
#else
|
||||
#define UNALIGNED_OK 0
|
||||
#define MDBX_UNALIGNED_OK 0
|
||||
#endif
|
||||
#endif /* UNALIGNED_OK */
|
||||
#endif /* MDBX_UNALIGNED_OK */
|
||||
|
||||
#if (-6 & 5) || CHAR_BIT != 8 || UINT_MAX < 0xffffffff || ULONG_MAX % 0xFFFF
|
||||
#error \
|
||||
|
@ -151,7 +151,7 @@ template <typename T> static __inline T load(const void *ptr) {
|
||||
#if defined(_MSC_VER) && \
|
||||
(defined(_M_ARM64) || defined(_M_X64) || defined(_M_IA64))
|
||||
return *(const T __unaligned *)ptr;
|
||||
#elif UNALIGNED_OK
|
||||
#elif MDBX_UNALIGNED_OK
|
||||
return *(const T *)ptr;
|
||||
#else
|
||||
T local;
|
||||
@ -161,14 +161,14 @@ template <typename T> static __inline T load(const void *ptr) {
|
||||
memcpy(&local, (const T *)ptr, sizeof(T));
|
||||
#endif /* __GNUC__ || __clang__ */
|
||||
return local;
|
||||
#endif /* UNALIGNED_OK */
|
||||
#endif /* MDBX_UNALIGNED_OK */
|
||||
}
|
||||
|
||||
template <typename T> static __inline void store(void *ptr, const T &value) {
|
||||
#if defined(_MSC_VER) && \
|
||||
(defined(_M_ARM64) || defined(_M_X64) || defined(_M_IA64))
|
||||
*((T __unaligned *)ptr) = value;
|
||||
#elif UNALIGNED_OK
|
||||
#elif MDBX_UNALIGNED_OK
|
||||
*(volatile T *)ptr = value;
|
||||
#else
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
@ -176,7 +176,7 @@ template <typename T> static __inline void store(void *ptr, const T &value) {
|
||||
#else
|
||||
memcpy(ptr, &value, sizeof(T));
|
||||
#endif /* __GNUC__ || __clang__ */
|
||||
#endif /* UNALIGNED_OK */
|
||||
#endif /* MDBX_UNALIGNED_OK */
|
||||
}
|
||||
|
||||
} /* namespace unaligned */
|
||||
|
Loading…
x
Reference in New Issue
Block a user