diff --git a/src/mdbx.c b/src/mdbx.c index b03b7de8..4cb59f50 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -3024,7 +3024,7 @@ again_on_freelist_change: if (total_room >= rpl_len) { if (total_room == rpl_len || --more < 0) break; - } else if (head_room >= env->me_maxfree_1pg && head_id > 1) { + } else if (head_room >= (ssize_t)env->me_maxfree_1pg && head_id > 1) { /* Keep current record (overflow page), add a new one */ head_id--; refill_reclaimed_pos++; @@ -3072,7 +3072,7 @@ again_on_freelist_change: /* (Re)write {key = head_id, IDL length = head_room} */ total_room -= head_room; head_room = rpl_len - total_room; - if (head_room > env->me_maxfree_1pg && head_id > 1) { + if (head_room > (ssize_t)env->me_maxfree_1pg && head_id > 1) { /* Overflow multi-page for part of me_reclaimed_pglist */ head_room /= (head_id < INT16_MAX) ? (pgno_t)head_id : INT16_MAX; /* amortize page sizes */ @@ -4647,12 +4647,14 @@ static int __cold mdbx_setup_dxb(MDBX_env *env, int lck_rc) { ", have %" PRIu64 "/%" PRIaPGNO "), " "assume collision in non-exclusive mode", expected_bytes, bytes2pgno(env, expected_bytes), - filesize_before_mmap, bytes2pgno(env, filesize_before_mmap)); + filesize_before_mmap, + bytes2pgno(env, (size_t)filesize_before_mmap)); } else { mdbx_notice("filesize mismatch (expect %" PRIuPTR "/%" PRIaPGNO ", have %" PRIu64 "/%" PRIaPGNO ")", expected_bytes, bytes2pgno(env, expected_bytes), - filesize_before_mmap, bytes2pgno(env, filesize_before_mmap)); + filesize_before_mmap, + bytes2pgno(env, (size_t)filesize_before_mmap)); if (filesize_before_mmap < used_bytes) { mdbx_error("last-page beyond end-of-file (last %" PRIaPGNO ", have %" PRIaPGNO ")", diff --git a/src/osal.h b/src/osal.h index 35d2bdbb..cb3dbd68 100644 --- a/src/osal.h +++ b/src/osal.h @@ -83,13 +83,13 @@ typedef struct { typedef CRITICAL_SECTION mdbx_fastmutex_t; #else #include +#include #include #include #include #include #include #include -#include typedef pthread_t mdbx_thread_t; typedef pthread_key_t mdbx_thread_key_t; #define INVALID_HANDLE_VALUE (-1) @@ -561,7 +561,7 @@ static __inline uint64_t mdbx_atomic_add64(volatile uint64_t *p, uint64_t v) { return __sync_fetch_and_add(p, v); #else #ifdef _MSC_VER - return _InterlockedExchangeAdd64(p, v); + return _InterlockedExchangeAdd64((volatile int64_t *)p, v); #endif #ifdef __APPLE__ return OSAtomicAdd64(v, (volatile int64_t *)p); @@ -598,7 +598,7 @@ static __inline bool mdbx_atomic_compare_and_swap64(volatile uint64_t *p, return __sync_bool_compare_and_swap(p, c, v); #else #ifdef _MSC_VER - return c == _InterlockedCompareExchange64(p, v, c); + return c == _InterlockedCompareExchange64((volatile int64_t *)p, v, c); #endif #ifdef __APPLE__ return c == OSAtomicCompareAndSwap64Barrier(c, v, (volatile uint64_t *)p); diff --git a/test/base.h b/test/base.h index 8557787d..e882c191 100644 --- a/test/base.h +++ b/test/base.h @@ -86,6 +86,7 @@ #include "../mdbx.h" #include "../src/defs.h" +#include "../src/osal.h" #ifdef _MSC_VER #pragma warning(pop) diff --git a/test/chrono.h b/test/chrono.h index b417f1e1..4be7e46e 100644 --- a/test/chrono.h +++ b/test/chrono.h @@ -62,7 +62,7 @@ inline time from_seconds(uint64_t seconds) { inline time from_utc(time_t utc) { assert(utc >= 0); - return from_seconds(utc); + return from_seconds((uint64_t)utc); } inline time infinite() { diff --git a/test/test.cc b/test/test.cc index 9a265e33..73e96986 100644 --- a/test/test.cc +++ b/test/test.cc @@ -66,8 +66,8 @@ const char *keygencase2str(const keygen_case keycase) { //----------------------------------------------------------------------------- -static void mdbx_debug_logger(int type, const char *function, int line, - const char *msg, va_list args) { +static void mdbx_logger(int type, const char *function, int line, + const char *msg, va_list args) { logging::loglevel level = logging::info; if (type & MDBX_DBG_EXTRA) level = logging::extra; @@ -120,7 +120,7 @@ void testcase::db_prepare() { mdbx_dbg_opts |= MDBX_DBG_TRACE; if (config.params.loglevel <= logging::verbose) mdbx_dbg_opts |= MDBX_DBG_PRINT; - int rc = mdbx_setup_debug(mdbx_dbg_opts, mdbx_debug_logger); + int rc = mdbx_setup_debug(mdbx_dbg_opts, mdbx_logger); log_info("set mdbx debug-opts: 0x%02x", rc); MDBX_env *env = nullptr; diff --git a/test/utils.h b/test/utils.h index 624a204c..726f676a 100644 --- a/test/utils.h +++ b/test/utils.h @@ -229,7 +229,7 @@ static __inline uint64_t mul_32x32_64(uint32_t a, uint32_t b) { static __inline unsigned add_with_carry(uint64_t *sum, uint64_t addend) { *sum += addend; - return *sum < addend; + return (*sum < addend) ? 1u : 0u; } static __inline uint64_t mul_64x64_128(uint64_t a, uint64_t b, uint64_t *h) {