diff --git a/GNUmakefile b/GNUmakefile index fd902c5a..20d0aadd 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -767,9 +767,9 @@ $(DIST_DIR)/mdbx.c: $(DIST_DIR)/@tmp-internals.inc $(lastword $(MAKEFILE_LIST)) ) | $(SED) -e '/#include "/d;/#pragma once/d' -e 's|@INCLUDE|#include|' \ -e '/ clang-format o/d;/ \*INDENT-O/d' -e '3i /* clang-format off */' | cat -s >$@ -$(DIST_DIR)/mdbx.c++: $(DIST_DIR)/@tmp-essentials.inc src/mdbx.c++ $(lastword $(MAKEFILE_LIST)) +$(DIST_DIR)/mdbx.c++: $(DIST_DIR)/@tmp-internals.inc src/mdbx.c++ $(lastword $(MAKEFILE_LIST)) @echo ' MAKE $@' - $(QUIET)cat $(DIST_DIR)/@tmp-essentials.inc src/mdbx.c++ | $(SED) \ + $(QUIET)cat $(DIST_DIR)/@tmp-internals.inc src/mdbx.c++ | $(SED) \ -e '/#define xMDBX_ALLOY/d' \ -e '/#include "/d;/#pragma once/d' \ -e 's|@INCLUDE|#include|;s|"mdbx.h"|"mdbx.h++"|' \ diff --git a/src/internals.h b/src/internals.h index 16d6b70b..f2c32d0e 100644 --- a/src/internals.h +++ b/src/internals.h @@ -9,6 +9,13 @@ #include "essentials.h" +#ifdef _MSC_VER +#pragma warning(push, 1) +#if _MSC_VER > 1913 +#pragma warning(disable : 5054) /* deprecated between enumerations of different types */ +#endif +#endif /* MSVC */ + typedef struct dp dp_t; typedef struct dpl dpl_t; typedef struct kvx kvx_t; @@ -561,6 +568,8 @@ MDBX_MAYBE_UNUSED static void static_checks(void) { /******************************************************************************/ +#ifndef __cplusplus + #include "node.h" #include "dbi.h" @@ -588,3 +597,9 @@ MDBX_MAYBE_UNUSED static void static_checks(void) { #include "walk.h" #include "sort.h" + +#endif /* __cplusplus */ + +#ifdef _MSC_VER +#pragma warning(pop) +#endif /* MSVC */ diff --git a/src/mdbx.c++ b/src/mdbx.c++ index 6ae73d8a..d09cbc21 100644 --- a/src/mdbx.c++ +++ b/src/mdbx.c++ @@ -27,6 +27,8 @@ #include // for isxdigit(), etc #include +#include "internals.h" + namespace { #if 0 /* Unused for now */ @@ -1492,7 +1494,7 @@ void txn_managed::commit(commit_latency *latency) { } void txn_managed::commit_embark_read() { - auto env = this->env(); + auto env = handle_->env; commit(); error::success_or_throw(::mdbx_txn_begin(env, nullptr, MDBX_TXN_RDONLY, &handle_)); } diff --git a/src/proto.h b/src/proto.h index 8850c578..6237b46a 100644 --- a/src/proto.h +++ b/src/proto.h @@ -31,7 +31,7 @@ MDBX_INTERNAL int __must_check_result dxb_sync_locked(MDBX_env *env, unsigned fl #if defined(ENABLE_MEMCHECK) || defined(__SANITIZE_ADDRESS__) MDBX_INTERNAL void dxb_sanitize_tail(MDBX_env *env, MDBX_txn *txn); #else -static inline void dxb_sanitize_tail(MDBX_env *env, MDBX_txn *txn) { +MDBX_MAYBE_UNUSED static inline void dxb_sanitize_tail(MDBX_env *env, MDBX_txn *txn) { (void)env; (void)txn; } diff --git a/src/rkl.h b/src/rkl.h index a9c98ab0..48a0183e 100644 --- a/src/rkl.h +++ b/src/rkl.h @@ -33,7 +33,7 @@ typedef struct MDBX_rkl { MDBX_MAYBE_UNUSED MDBX_INTERNAL void rkl_init(rkl_t *rkl); MDBX_MAYBE_UNUSED MDBX_INTERNAL void rkl_clear(rkl_t *rkl); -static inline void rkl_clear_and_shrink(rkl_t *rkl) { rkl_clear(rkl); /* TODO */ } +MDBX_MAYBE_UNUSED static inline void rkl_clear_and_shrink(rkl_t *rkl) { rkl_clear(rkl); /* TODO */ } MDBX_MAYBE_UNUSED MDBX_INTERNAL void rkl_destroy(rkl_t *rkl); MDBX_MAYBE_UNUSED MDBX_INTERNAL void rkl_destructive_move(rkl_t *src, rkl_t *dst); MDBX_MAYBE_UNUSED MDBX_INTERNAL __must_check_result int rkl_copy(const rkl_t *src, rkl_t *dst); diff --git a/src/txl.h b/src/txl.h index 77ca2a3b..b7a240f6 100644 --- a/src/txl.h +++ b/src/txl.h @@ -25,6 +25,6 @@ MDBX_MAYBE_UNUSED MDBX_INTERNAL void txl_sort(txl_t txl); MDBX_MAYBE_UNUSED MDBX_INTERNAL bool txl_contain(const txl_t txl, txnid_t id); -static inline size_t txl_alloclen(const_txl_t txl) { return txl[-1]; } +MDBX_MAYBE_UNUSED static inline size_t txl_alloclen(const_txl_t txl) { return txl[-1]; } -static inline size_t txl_size(const_txl_t txl) { return txl[0]; } +MDBX_MAYBE_UNUSED static inline size_t txl_size(const_txl_t txl) { return txl[0]; } diff --git a/src/unaligned.h b/src/unaligned.h index b119004f..04b6efce 100644 --- a/src/unaligned.h +++ b/src/unaligned.h @@ -13,12 +13,14 @@ MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline size_t field_alignme } /* read-thunk for UB-sanitizer */ -MDBX_NOTHROW_PURE_FUNCTION static inline uint8_t peek_u8(const uint8_t *__restrict ptr) { return *ptr; } +MDBX_NOTHROW_PURE_FUNCTION MDBX_MAYBE_UNUSED static inline uint8_t peek_u8(const uint8_t *__restrict ptr) { + return *ptr; +} /* write-thunk for UB-sanitizer */ -static inline void poke_u8(uint8_t *__restrict ptr, const uint8_t v) { *ptr = v; } +MDBX_MAYBE_UNUSED static inline void poke_u8(uint8_t *__restrict ptr, const uint8_t v) { *ptr = v; } -static inline void *bcopy_2(void *__restrict dst, const void *__restrict src) { +MDBX_MAYBE_UNUSED static inline void *bcopy_2(void *__restrict dst, const void *__restrict src) { uint8_t *__restrict d = (uint8_t *)dst; const uint8_t *__restrict s = (uint8_t *)src; d[0] = s[0]; @@ -26,7 +28,7 @@ static inline void *bcopy_2(void *__restrict dst, const void *__restrict src) { return d; } -static inline void *bcopy_4(void *const __restrict dst, const void *const __restrict src) { +MDBX_MAYBE_UNUSED static inline void *bcopy_4(void *const __restrict dst, const void *const __restrict src) { uint8_t *__restrict d = (uint8_t *)dst; const uint8_t *__restrict s = (uint8_t *)src; d[0] = s[0]; @@ -36,7 +38,7 @@ static inline void *bcopy_4(void *const __restrict dst, const void *const __rest return d; } -static inline void *bcopy_8(void *const __restrict dst, const void *const __restrict src) { +MDBX_MAYBE_UNUSED static inline void *bcopy_8(void *const __restrict dst, const void *const __restrict src) { uint8_t *__restrict d = (uint8_t *)dst; const uint8_t *__restrict s = (uint8_t *)src; d[0] = s[0]; @@ -50,8 +52,8 @@ static inline void *bcopy_8(void *const __restrict dst, const void *const __rest return d; } -MDBX_NOTHROW_PURE_FUNCTION static inline uint16_t unaligned_peek_u16(const size_t expected_alignment, - const void *const ptr) { +MDBX_NOTHROW_PURE_FUNCTION MDBX_MAYBE_UNUSED static inline uint16_t unaligned_peek_u16(const size_t expected_alignment, + const void *const ptr) { assert((uintptr_t)ptr % expected_alignment == 0); if (MDBX_UNALIGNED_OK >= 2 || (expected_alignment % sizeof(uint16_t)) == 0) return *(const uint16_t *)ptr; @@ -66,7 +68,8 @@ MDBX_NOTHROW_PURE_FUNCTION static inline uint16_t unaligned_peek_u16(const size_ } } -static inline void unaligned_poke_u16(const size_t expected_alignment, void *const __restrict ptr, const uint16_t v) { +MDBX_MAYBE_UNUSED static inline void unaligned_poke_u16(const size_t expected_alignment, void *const __restrict ptr, + const uint16_t v) { assert((uintptr_t)ptr % expected_alignment == 0); if (MDBX_UNALIGNED_OK >= 2 || (expected_alignment % sizeof(v)) == 0) *(uint16_t *)ptr = v; @@ -79,8 +82,8 @@ static inline void unaligned_poke_u16(const size_t expected_alignment, void *con } } -MDBX_NOTHROW_PURE_FUNCTION static inline uint32_t unaligned_peek_u32(const size_t expected_alignment, - const void *const __restrict ptr) { +MDBX_NOTHROW_PURE_FUNCTION MDBX_MAYBE_UNUSED static inline uint32_t +unaligned_peek_u32(const size_t expected_alignment, const void *const __restrict ptr) { assert((uintptr_t)ptr % expected_alignment == 0); if (MDBX_UNALIGNED_OK >= 4 || (expected_alignment % sizeof(uint32_t)) == 0) return *(const uint32_t *)ptr; @@ -99,7 +102,8 @@ MDBX_NOTHROW_PURE_FUNCTION static inline uint32_t unaligned_peek_u32(const size_ } } -static inline void unaligned_poke_u32(const size_t expected_alignment, void *const __restrict ptr, const uint32_t v) { +MDBX_MAYBE_UNUSED static inline void unaligned_poke_u32(const size_t expected_alignment, void *const __restrict ptr, + const uint32_t v) { assert((uintptr_t)ptr % expected_alignment == 0); if (MDBX_UNALIGNED_OK >= 4 || (expected_alignment % sizeof(v)) == 0) *(uint32_t *)ptr = v; @@ -115,8 +119,8 @@ static inline void unaligned_poke_u32(const size_t expected_alignment, void *con } } -MDBX_NOTHROW_PURE_FUNCTION static inline uint64_t unaligned_peek_u64(const size_t expected_alignment, - const void *const __restrict ptr) { +MDBX_NOTHROW_PURE_FUNCTION MDBX_MAYBE_UNUSED static inline uint64_t +unaligned_peek_u64(const size_t expected_alignment, const void *const __restrict ptr) { assert((uintptr_t)ptr % expected_alignment == 0); if (MDBX_UNALIGNED_OK >= 8 || (expected_alignment % sizeof(uint64_t)) == 0) return *(const uint64_t *)ptr; @@ -135,8 +139,8 @@ MDBX_NOTHROW_PURE_FUNCTION static inline uint64_t unaligned_peek_u64(const size_ } } -static inline uint64_t unaligned_peek_u64_volatile(const size_t expected_alignment, - const volatile void *const __restrict ptr) { +MDBX_MAYBE_UNUSED static inline uint64_t unaligned_peek_u64_volatile(const size_t expected_alignment, + const volatile void *const __restrict ptr) { assert((uintptr_t)ptr % expected_alignment == 0); assert(expected_alignment % sizeof(uint32_t) == 0); if (MDBX_UNALIGNED_OK >= 8 || (expected_alignment % sizeof(uint64_t)) == 0) @@ -152,7 +156,8 @@ static inline uint64_t unaligned_peek_u64_volatile(const size_t expected_alignme } } -static inline void unaligned_poke_u64(const size_t expected_alignment, void *const __restrict ptr, const uint64_t v) { +MDBX_MAYBE_UNUSED static inline void unaligned_poke_u64(const size_t expected_alignment, void *const __restrict ptr, + const uint64_t v) { assert((uintptr_t)ptr % expected_alignment == 0); if (MDBX_UNALIGNED_OK >= 8 || (expected_alignment % sizeof(v)) == 0) *(uint64_t *)ptr = v; @@ -183,7 +188,7 @@ static inline void unaligned_poke_u64(const size_t expected_alignment, void *con #define UNALIGNED_POKE_64(ptr, struct, field, value) \ unaligned_poke_u64(1, ptr_disp(ptr, offsetof(struct, field)), value) -MDBX_NOTHROW_PURE_FUNCTION static inline pgno_t peek_pgno(const void *const __restrict ptr) { +MDBX_NOTHROW_PURE_FUNCTION MDBX_MAYBE_UNUSED static inline pgno_t peek_pgno(const void *const __restrict ptr) { if (sizeof(pgno_t) == sizeof(uint32_t)) return (pgno_t)unaligned_peek_u32(1, ptr); else if (sizeof(pgno_t) == sizeof(uint64_t)) @@ -195,7 +200,7 @@ MDBX_NOTHROW_PURE_FUNCTION static inline pgno_t peek_pgno(const void *const __re } } -static inline void poke_pgno(void *const __restrict ptr, const pgno_t pgno) { +MDBX_MAYBE_UNUSED static inline void poke_pgno(void *const __restrict ptr, const pgno_t pgno) { if (sizeof(pgno) == sizeof(uint32_t)) unaligned_poke_u32(1, ptr, pgno); else if (sizeof(pgno) == sizeof(uint64_t))