mdbx: cleanup tabs (minor).

This commit is contained in:
Leo Yuriev 2017-05-24 13:37:06 +03:00
parent 8af6291d50
commit dd7855c30d
2 changed files with 235 additions and 237 deletions

View File

@ -16,18 +16,17 @@
/* clang-format off */ /* clang-format off */
#ifndef _FILE_OFFSET_BITS #ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64 # define _FILE_OFFSET_BITS 64
#endif #endif
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
# define _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable : 4464) /* C4464: relative include path contains '..' */ #pragma warning(disable : 4464) /* C4464: relative include path contains '..' */
#pragma warning(disable : 4710) /* C4710: 'xyz': function not inlined */ #pragma warning(disable : 4710) /* C4710: 'xyz': function not inlined */
#pragma warning(disable : 4711) /* C4711: function 'xyz' selected for automatic inline expansion */ #pragma warning(disable : 4711) /* C4711: function 'xyz' selected for automatic inline expansion */
//#pragma warning(disable : 4061) /* C4061: enumerator 'abc' in switch of enum 'xyz' is not explicitly handled by a case label */
#pragma warning(disable : 4201) /* C4201: nonstandard extension used : nameless struct / union */ #pragma warning(disable : 4201) /* C4201: nonstandard extension used : nameless struct / union */
#pragma warning(disable : 4706) /* C4706: assignment within conditional expression */ #pragma warning(disable : 4706) /* C4706: assignment within conditional expression */
#pragma warning(disable : 4127) /* C4127: conditional expression is constant */ #pragma warning(disable : 4127) /* C4127: conditional expression is constant */
@ -37,102 +36,102 @@
#include "./defs.h" #include "./defs.h"
#if defined(USE_VALGRIND) #if defined(USE_VALGRIND)
# include <valgrind/memcheck.h> # include <valgrind/memcheck.h>
# ifndef VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE # ifndef VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE
/* LY: available since Valgrind 3.10 */ /* LY: available since Valgrind 3.10 */
# define VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE(a,s) # define VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE(a,s)
# define VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(a,s) # define VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(a,s)
# endif # endif
#else #else
# define VALGRIND_CREATE_MEMPOOL(h,r,z) # define VALGRIND_CREATE_MEMPOOL(h,r,z)
# define VALGRIND_DESTROY_MEMPOOL(h) # define VALGRIND_DESTROY_MEMPOOL(h)
# define VALGRIND_MEMPOOL_TRIM(h,a,s) # define VALGRIND_MEMPOOL_TRIM(h,a,s)
# define VALGRIND_MEMPOOL_ALLOC(h,a,s) # define VALGRIND_MEMPOOL_ALLOC(h,a,s)
# define VALGRIND_MEMPOOL_FREE(h,a) # define VALGRIND_MEMPOOL_FREE(h,a)
# define VALGRIND_MEMPOOL_CHANGE(h,a,b,s) # define VALGRIND_MEMPOOL_CHANGE(h,a,b,s)
# define VALGRIND_MAKE_MEM_NOACCESS(a,s) # define VALGRIND_MAKE_MEM_NOACCESS(a,s)
# define VALGRIND_MAKE_MEM_DEFINED(a,s) # define VALGRIND_MAKE_MEM_DEFINED(a,s)
# define VALGRIND_MAKE_MEM_UNDEFINED(a,s) # define VALGRIND_MAKE_MEM_UNDEFINED(a,s)
# define VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE(a,s) # define VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE(a,s)
# define VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(a,s) # define VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(a,s)
# define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,s) (0) # define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,s) (0)
# define VALGRIND_CHECK_MEM_IS_DEFINED(a,s) (0) # define VALGRIND_CHECK_MEM_IS_DEFINED(a,s) (0)
#endif /* USE_VALGRIND */ #endif /* USE_VALGRIND */
#ifdef __SANITIZE_ADDRESS__ #ifdef __SANITIZE_ADDRESS__
# include <sanitizer/asan_interface.h> # include <sanitizer/asan_interface.h>
#else #else
# define ASAN_POISON_MEMORY_REGION(addr, size) \ # define ASAN_POISON_MEMORY_REGION(addr, size) \
((void)(addr), (void)(size)) ((void)(addr), (void)(size))
# define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ # define ASAN_UNPOISON_MEMORY_REGION(addr, size) \
((void)(addr), (void)(size)) ((void)(addr), (void)(size))
#endif /* __SANITIZE_ADDRESS__ */ #endif /* __SANITIZE_ADDRESS__ */
#include "./osal.h" #include "./osal.h"
#ifndef MDBX_DEBUG #ifndef MDBX_DEBUG
# define MDBX_DEBUG 0 # define MDBX_DEBUG 0
#endif #endif
#if MDBX_DEBUG #if MDBX_DEBUG
# undef NDEBUG # undef NDEBUG
#endif #endif
#if defined(__GNUC__) && !__GNUC_PREREQ(4,2) #if defined(__GNUC__) && !__GNUC_PREREQ(4,2)
/* Actualy libmdbx was not tested with compilers older than GCC from RHEL6. /* Actualy libmdbx was not tested with compilers older than GCC from RHEL6.
* But you could remove this #error and try to continue at your own risk. * 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. * In such case please don't rise up an issues related ONLY to old compilers.
*/ */
# warning "libmdbx required at least GCC 4.2 compatible C/C++ compiler." # warning "libmdbx required at least GCC 4.2 compatible C/C++ compiler."
#endif #endif
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2,12) #if defined(__GLIBC__) && !__GLIBC_PREREQ(2,12)
/* Actualy libmdbx was not tested with something older than glibc 2.12 (from RHEL6). /* Actualy libmdbx was not tested with something older than glibc 2.12 (from RHEL6).
* But you could remove this #error and try to continue at your own risk. * 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 systems. * In such case please don't rise up an issues related ONLY to old systems.
*/ */
# warning "libmdbx required at least GLIBC 2.12." # warning "libmdbx required at least GLIBC 2.12."
#endif #endif
#if defined(__i386) || defined(__x86_64) || defined(_M_IX86) #if defined(__i386) || defined(__x86_64) || defined(_M_IX86)
# define UNALIGNED_OK 1 /* TODO */ # define UNALIGNED_OK 1 /* TODO */
#endif #endif
#ifndef UNALIGNED_OK #ifndef UNALIGNED_OK
# define UNALIGNED_OK 0 # define UNALIGNED_OK 0
#endif /* UNALIGNED_OK */ #endif /* UNALIGNED_OK */
#if (-6 & 5) || CHAR_BIT != 8 || UINT_MAX < 0xffffffff || ULONG_MAX % 0xFFFF #if (-6 & 5) || CHAR_BIT != 8 || UINT_MAX < 0xffffffff || ULONG_MAX % 0xFFFF
# error "Sanity checking failed: Two's complement, reasonably sized integer types" # error "Sanity checking failed: Two's complement, reasonably sized integer types"
#endif #endif
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
#ifndef ARRAY_LENGTH #ifndef ARRAY_LENGTH
# ifdef __cplusplus # ifdef __cplusplus
template <typename T, size_t N> template <typename T, size_t N>
char (&__ArraySizeHelper(T (&array)[N]))[N]; char (&__ArraySizeHelper(T (&array)[N]))[N];
# define ARRAY_LENGTH(array) (sizeof(::__ArraySizeHelper(array))) # define ARRAY_LENGTH(array) (sizeof(::__ArraySizeHelper(array)))
# else # else
# define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0])) # define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
# endif # endif
#endif /* ARRAY_LENGTH */ #endif /* ARRAY_LENGTH */
#ifndef ARRAY_END #ifndef ARRAY_END
# define ARRAY_END(array) (&array[ARRAY_LENGTH(array)]) # define ARRAY_END(array) (&array[ARRAY_LENGTH(array)])
#endif /* ARRAY_END */ #endif /* ARRAY_END */
#ifndef STRINGIFY #ifndef STRINGIFY
# define STRINGIFY_HELPER(x) #x # define STRINGIFY_HELPER(x) #x
# define STRINGIFY(x) STRINGIFY_HELPER(x) # define STRINGIFY(x) STRINGIFY_HELPER(x)
#endif /* STRINGIFY */ #endif /* STRINGIFY */
#ifndef offsetof #ifndef offsetof
# define offsetof(type, member) __builtin_offsetof(type, member) # define offsetof(type, member) __builtin_offsetof(type, member)
#endif /* offsetof */ #endif /* offsetof */
#ifndef container_of #ifndef container_of
# define container_of(ptr, type, member) \ # define container_of(ptr, type, member) \
((type *)((char *)(ptr) - offsetof(type, member))) ((type *)((char *)(ptr) - offsetof(type, member)))
#endif /* container_of */ #endif /* container_of */
/* *INDENT-ON* */ /* *INDENT-ON* */

View File

@ -17,293 +17,292 @@
/* clang-format off */ /* clang-format off */
#ifndef __GNUC_PREREQ #ifndef __GNUC_PREREQ
# if defined(__GNUC__) && defined(__GNUC_MINOR__) # if defined(__GNUC__) && defined(__GNUC_MINOR__)
# define __GNUC_PREREQ(maj, min) \ # define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else # else
# define __GNUC_PREREQ(maj, min) (0) # define __GNUC_PREREQ(maj, min) (0)
# endif # endif
#endif /* __GNUC_PREREQ */ #endif /* __GNUC_PREREQ */
#ifndef __CLANG_PREREQ #ifndef __CLANG_PREREQ
# ifdef __clang__ # ifdef __clang__
# define __CLANG_PREREQ(maj,min) \ # define __CLANG_PREREQ(maj,min) \
((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min)) ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
# else # else
# define __CLANG_PREREQ(maj,min) (0) # define __CLANG_PREREQ(maj,min) (0)
# endif # endif
#endif /* __CLANG_PREREQ */ #endif /* __CLANG_PREREQ */
#ifndef __GLIBC_PREREQ #ifndef __GLIBC_PREREQ
# if defined(__GLIBC__) && defined(__GLIBC_MINOR__) # if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
# define __GLIBC_PREREQ(maj, min) \ # define __GLIBC_PREREQ(maj, min) \
((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
# else # else
# define __GLIBC_PREREQ(maj, min) (0) # define __GLIBC_PREREQ(maj, min) (0)
# endif # endif
#endif /* __GLIBC_PREREQ */ #endif /* __GLIBC_PREREQ */
#ifndef __has_attribute #ifndef __has_attribute
# define __has_attribute(x) (0) # define __has_attribute(x) (0)
#endif #endif
#ifndef __has_feature #ifndef __has_feature
# define __has_feature(x) (0) # define __has_feature(x) (0)
#endif #endif
#ifndef __has_extension #ifndef __has_extension
# define __has_extension(x) (0) # define __has_extension(x) (0)
#endif #endif
#ifndef __has_builtin #ifndef __has_builtin
# define __has_builtin(x) (0) # define __has_builtin(x) (0)
#endif #endif
#if __has_feature(thread_sanitizer) #if __has_feature(thread_sanitizer)
# define __SANITIZE_THREAD__ 1 # define __SANITIZE_THREAD__ 1
#endif #endif
#if __has_feature(address_sanitizer) #if __has_feature(address_sanitizer)
# define __SANITIZE_ADDRESS__ 1 # define __SANITIZE_ADDRESS__ 1
#endif #endif
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
#ifndef __extern_C #ifndef __extern_C
# ifdef __cplusplus # ifdef __cplusplus
# define __extern_C extern "C" # define __extern_C extern "C"
# else # else
# define __extern_C # define __extern_C
# endif # endif
#endif /* __extern_C */ #endif /* __extern_C */
#ifndef __cplusplus #ifndef __cplusplus
# ifndef bool # ifndef bool
# define bool _Bool # define bool _Bool
# endif # endif
# ifndef true # ifndef true
# define true (1) # define true (1)
# endif # endif
# ifndef false # ifndef false
# define false (0) # define false (0)
# endif # endif
#endif #endif
#if !defined(nullptr) && !defined(__cplusplus) || (__cplusplus < 201103L && !defined(_MSC_VER)) #if !defined(nullptr) && !defined(__cplusplus) || (__cplusplus < 201103L && !defined(_MSC_VER))
# define nullptr NULL # define nullptr NULL
#endif #endif
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
#if !defined(__thread) && (defined(_MSC_VER) || defined(__DMC__)) #if !defined(__thread) && (defined(_MSC_VER) || defined(__DMC__))
# define __thread __declspec(thread) # define __thread __declspec(thread)
#endif /* __thread */ #endif /* __thread */
#ifndef __alwaysinline #ifndef __alwaysinline
# if defined(__GNUC__) || __has_attribute(always_inline) # if defined(__GNUC__) || __has_attribute(always_inline)
# define __alwaysinline __inline __attribute__((always_inline)) # define __alwaysinline __inline __attribute__((always_inline))
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define __alwaysinline __forceinline # define __alwaysinline __forceinline
# else # else
# define __alwaysinline # define __alwaysinline
# endif # endif
#endif /* __alwaysinline */ #endif /* __alwaysinline */
#ifndef __noinline #ifndef __noinline
# if defined(__GNUC__) || __has_attribute(noinline) # if defined(__GNUC__) || __has_attribute(noinline)
# define __noinline __attribute__((noinline)) # define __noinline __attribute__((noinline))
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define __noinline __declspec(noinline) # define __noinline __declspec(noinline)
# elif defined(__SUNPRO_C) || defined(__sun) || defined(sun) # elif defined(__SUNPRO_C) || defined(__sun) || defined(sun)
# define __noinline inline # define __noinline inline
# elif !defined(__INTEL_COMPILER) # elif !defined(__INTEL_COMPILER)
# define __noinline /* FIXME ? */ # define __noinline /* FIXME ? */
# endif # endif
#endif /* __noinline */ #endif /* __noinline */
#ifndef __must_check_result #ifndef __must_check_result
# if defined(__GNUC__) || __has_attribute(warn_unused_result) # if defined(__GNUC__) || __has_attribute(warn_unused_result)
# define __must_check_result __attribute__((warn_unused_result)) # define __must_check_result __attribute__((warn_unused_result))
# else # else
# define __must_check_result # define __must_check_result
# endif # endif
#endif /* __must_check_result */ #endif /* __must_check_result */
#ifndef __deprecated #ifndef __deprecated
# if defined(__GNUC__) || __has_attribute(deprecated) # if defined(__GNUC__) || __has_attribute(deprecated)
# define __deprecated __attribute__((deprecated)) # define __deprecated __attribute__((deprecated))
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define __deprecated __declspec(deprecated) # define __deprecated __declspec(deprecated)
# else # else
# define __deprecated # define __deprecated
# endif # endif
#endif /* __deprecated */ #endif /* __deprecated */
#ifndef __packed #ifndef __packed
# if defined(__GNUC__) || __has_attribute(packed) # if defined(__GNUC__) || __has_attribute(packed)
# define __packed __attribute__((packed)) # define __packed __attribute__((packed))
# else # else
# define __packed # define __packed
# endif # endif
#endif /* __packed */ #endif /* __packed */
#ifndef __aligned #ifndef __aligned
# if defined(__GNUC__) || __has_attribute(aligned) # if defined(__GNUC__) || __has_attribute(aligned)
# define __aligned(N) __attribute__((aligned(N))) # define __aligned(N) __attribute__((aligned(N)))
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define __aligned(N) __declspec(align(N)) # define __aligned(N) __declspec(align(N))
# else # else
# define __aligned(N) # define __aligned(N)
# endif # endif
#endif /* __aligned */ #endif /* __aligned */
#ifndef __noreturn #ifndef __noreturn
# if defined(__GNUC__) || __has_attribute(noreturn) # if defined(__GNUC__) || __has_attribute(noreturn)
# define __noreturn __attribute__((noreturn)) # define __noreturn __attribute__((noreturn))
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define __noreturn __declspec(noreturn) # define __noreturn __declspec(noreturn)
# else # else
# define __noreturn # define __noreturn
# endif # endif
#endif /* __noreturn */ #endif /* __noreturn */
#ifndef __nothrow #ifndef __nothrow
# if defined(__GNUC__) || __has_attribute(nothrow) # if defined(__GNUC__) || __has_attribute(nothrow)
# define __nothrow __attribute__((nothrow)) # define __nothrow __attribute__((nothrow))
# elif defined(_MSC_VER) && defined(__cplusplus) # elif defined(_MSC_VER) && defined(__cplusplus)
# define __nothrow __declspec(nothrow) # define __nothrow __declspec(nothrow)
# else # else
# define __nothrow # define __nothrow
# endif # endif
#endif /* __nothrow */ #endif /* __nothrow */
#ifndef __pure_function #ifndef __pure_function
/* Many functions have no effects except the return value and their /* Many functions have no effects except the return value and their
* return value depends only on the parameters and/or global variables. * return value depends only on the parameters and/or global variables.
* Such a function can be subject to common subexpression elimination * Such a function can be subject to common subexpression elimination
* and loop optimization just as an arithmetic operator would be. * and loop optimization just as an arithmetic operator would be.
* These functions should be declared with the attribute pure. */ * These functions should be declared with the attribute pure. */
# if defined(__GNUC__) || __has_attribute(pure) # if defined(__GNUC__) || __has_attribute(pure)
# define __pure_function __attribute__((pure)) # define __pure_function __attribute__((pure))
# else # else
# define __pure_function # define __pure_function
# endif # endif
#endif /* __pure_function */ #endif /* __pure_function */
#ifndef __const_function #ifndef __const_function
/* Many functions do not examine any values except their arguments, /* Many functions do not examine any values except their arguments,
* and have no effects except the return value. Basically this is just * and have no effects except the return value. Basically this is just
* slightly more strict class than the PURE attribute, since function * slightly more strict class than the PURE attribute, since function
* is not allowed to read global memory. * is not allowed to read global memory.
* *
* Note that a function that has pointer arguments and examines the * Note that a function that has pointer arguments and examines the
* data pointed to must not be declared const. Likewise, a function * data pointed to must not be declared const. Likewise, a function
* that calls a non-const function usually must not be const. * that calls a non-const function usually must not be const.
* It does not make sense for a const function to return void. */ * It does not make sense for a const function to return void. */
# if defined(__GNUC__) || __has_attribute(const) # if defined(__GNUC__) || __has_attribute(const)
# define __const_function __attribute__((const)) # define __const_function __attribute__((const))
# else # else
# define __const_function # define __const_function
# endif # endif
#endif /* __const_function */ #endif /* __const_function */
#ifndef __dll_hidden #ifndef __dll_hidden
# if defined(__GNUC__) || __has_attribute(visibility) # if defined(__GNUC__) || __has_attribute(visibility)
# define __hidden __attribute__((visibility("hidden"))) # define __hidden __attribute__((visibility("hidden")))
# else # else
# define __hidden # define __hidden
# endif # endif
#endif /* __dll_hidden */ #endif /* __dll_hidden */
#ifndef __optimize #ifndef __optimize
# if defined(__OPTIMIZE__) # if defined(__OPTIMIZE__)
# if defined(__clang__) && !__has_attribute(optimize) # if defined(__clang__) && !__has_attribute(optimize)
# define __optimize(ops) # define __optimize(ops)
# elif defined(__GNUC__) || __has_attribute(optimize) # elif defined(__GNUC__) || __has_attribute(optimize)
# define __optimize(ops) __attribute__((optimize(ops))) # define __optimize(ops) __attribute__((optimize(ops)))
# else # else
# define __optimize(ops) # define __optimize(ops)
# endif # endif
# else # else
# define __optimize(ops) # define __optimize(ops)
# endif # endif
#endif /* __optimize */ #endif /* __optimize */
#ifndef __hot #ifndef __hot
# if defined(__OPTIMIZE__) # if defined(__OPTIMIZE__)
# if defined(__clang__) && !__has_attribute(hot) # if defined(__clang__) && !__has_attribute(hot)
/* just put frequently used functions in separate section */ /* just put frequently used functions in separate section */
# define __hot __attribute__((section("text.hot"))) __optimize("O3") # define __hot __attribute__((section("text.hot"))) __optimize("O3")
# elif defined(__GNUC__) || __has_attribute(hot) # elif defined(__GNUC__) || __has_attribute(hot)
# define __hot __attribute__((hot)) __optimize("O3") # define __hot __attribute__((hot)) __optimize("O3")
# else # else
# define __hot __optimize("O3") # define __hot __optimize("O3")
# endif # endif
# else # else
# define __hot # define __hot
# endif # endif
#endif /* __hot */ #endif /* __hot */
#ifndef __cold #ifndef __cold
# if defined(__OPTIMIZE__) # if defined(__OPTIMIZE__)
# if defined(__clang__) && !__has_attribute(cold) # if defined(__clang__) && !__has_attribute(cold)
/* just put infrequently used functions in separate section */ /* just put infrequently used functions in separate section */
# define __cold __attribute__((section("text.unlikely"))) __optimize("Os") # define __cold __attribute__((section("text.unlikely"))) __optimize("Os")
# elif defined(__GNUC__) || __has_attribute(cold) # elif defined(__GNUC__) || __has_attribute(cold)
# define __cold __attribute__((cold)) __optimize("Os") # define __cold __attribute__((cold)) __optimize("Os")
# else # else
# define __cold __optimize("Os") # define __cold __optimize("Os")
# endif # endif
# else # else
# define __cold # define __cold
# endif # endif
#endif /* __cold */ #endif /* __cold */
#ifndef __flatten #ifndef __flatten
# if defined(__OPTIMIZE__) && (defined(__GNUC__) || __has_attribute(flatten)) # if defined(__OPTIMIZE__) && (defined(__GNUC__) || __has_attribute(flatten))
# define __flatten __attribute__((flatten)) # define __flatten __attribute__((flatten))
# else # else
# define __flatten # define __flatten
# endif # endif
#endif /* __flatten */ #endif /* __flatten */
#ifndef likely #ifndef likely
# if defined(__GNUC__) || defined(__clang__) # if defined(__GNUC__) || defined(__clang__)
# define likely(cond) __builtin_expect(!!(cond), 1) # define likely(cond) __builtin_expect(!!(cond), 1)
# else # else
# define likely(x) (x) # define likely(x) (x)
# endif # endif
#endif /* likely */ #endif /* likely */
#ifndef unlikely #ifndef unlikely
# if defined(__GNUC__) || defined(__clang__) # if defined(__GNUC__) || defined(__clang__)
# define unlikely(cond) __builtin_expect(!!(cond), 0) # define unlikely(cond) __builtin_expect(!!(cond), 0)
# else # else
# define unlikely(x) (x) # define unlikely(x) (x)
# endif # endif
#endif /* unlikely */ #endif /* unlikely */
#if !defined(__noop) && !defined(_MSC_VER) #if !defined(__noop) && !defined(_MSC_VER)
static __inline int __do_noop(void* crutch, ...) { static __inline int __do_noop(void* crutch, ...) {
(void) crutch; return 0; (void) crutch; return 0;
} }
# define __noop(...) __do_noop(0, __VA_ARGS__) # define __noop(...) __do_noop(0, __VA_ARGS__)
#endif /* __noop */ #endif /* __noop */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Wrapper around __func__, which is a C99 feature */ /* Wrapper around __func__, which is a C99 feature */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define mdbx_func_ __func__ # define mdbx_func_ __func__
#elif (defined(__GNUC__) && __GNUC__ >= 2) || defined(__clang__) || defined(_MSC_VER) #elif (defined(__GNUC__) && __GNUC__ >= 2) || defined(__clang__) || defined(_MSC_VER)
# define mdbx_func_ __FUNCTION__ # define mdbx_func_ __FUNCTION__
#else #else
# define mdbx_func_ "<mdbx_unknown>" # define mdbx_func_ "<mdbx_unknown>"
#endif #endif
/* *INDENT-ON* */ /* *INDENT-ON* */
/* clang-format on */ /* clang-format on */
#define MDBX_TETRAD(a, b, c, d) \ #define MDBX_TETRAD(a, b, c, d) \
((uint32_t)(a) << 24 | (uint32_t)(b) << 16 | (uint32_t)(c) << 8 | \ ((uint32_t)(a) << 24 | (uint32_t)(b) << 16 | (uint32_t)(c) << 8 | (d))
(uint32_t)(d))