mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +08:00
mdbx: more fix MSVC '/Wall' warnings.
Change-Id: I359a3056d6bb5db762fe6b6b8a89e8ed066f8a87
This commit is contained in:
parent
006f531757
commit
a78edd314e
10
src/mdbx.c
10
src/mdbx.c
@ -3024,7 +3024,7 @@ again_on_freelist_change:
|
|||||||
if (total_room >= rpl_len) {
|
if (total_room >= rpl_len) {
|
||||||
if (total_room == rpl_len || --more < 0)
|
if (total_room == rpl_len || --more < 0)
|
||||||
break;
|
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 */
|
/* Keep current record (overflow page), add a new one */
|
||||||
head_id--;
|
head_id--;
|
||||||
refill_reclaimed_pos++;
|
refill_reclaimed_pos++;
|
||||||
@ -3072,7 +3072,7 @@ again_on_freelist_change:
|
|||||||
/* (Re)write {key = head_id, IDL length = head_room} */
|
/* (Re)write {key = head_id, IDL length = head_room} */
|
||||||
total_room -= head_room;
|
total_room -= head_room;
|
||||||
head_room = rpl_len - total_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 */
|
/* Overflow multi-page for part of me_reclaimed_pglist */
|
||||||
head_room /= (head_id < INT16_MAX) ? (pgno_t)head_id
|
head_room /= (head_id < INT16_MAX) ? (pgno_t)head_id
|
||||||
: INT16_MAX; /* amortize page sizes */
|
: INT16_MAX; /* amortize page sizes */
|
||||||
@ -4647,12 +4647,14 @@ static int __cold mdbx_setup_dxb(MDBX_env *env, int lck_rc) {
|
|||||||
", have %" PRIu64 "/%" PRIaPGNO "), "
|
", have %" PRIu64 "/%" PRIaPGNO "), "
|
||||||
"assume collision in non-exclusive mode",
|
"assume collision in non-exclusive mode",
|
||||||
expected_bytes, bytes2pgno(env, expected_bytes),
|
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 {
|
} else {
|
||||||
mdbx_notice("filesize mismatch (expect %" PRIuPTR "/%" PRIaPGNO
|
mdbx_notice("filesize mismatch (expect %" PRIuPTR "/%" PRIaPGNO
|
||||||
", have %" PRIu64 "/%" PRIaPGNO ")",
|
", have %" PRIu64 "/%" PRIaPGNO ")",
|
||||||
expected_bytes, bytes2pgno(env, expected_bytes),
|
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) {
|
if (filesize_before_mmap < used_bytes) {
|
||||||
mdbx_error("last-page beyond end-of-file (last %" PRIaPGNO
|
mdbx_error("last-page beyond end-of-file (last %" PRIaPGNO
|
||||||
", have %" PRIaPGNO ")",
|
", have %" PRIaPGNO ")",
|
||||||
|
@ -83,13 +83,13 @@ typedef struct {
|
|||||||
typedef CRITICAL_SECTION mdbx_fastmutex_t;
|
typedef CRITICAL_SECTION mdbx_fastmutex_t;
|
||||||
#else
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
|
||||||
typedef pthread_t mdbx_thread_t;
|
typedef pthread_t mdbx_thread_t;
|
||||||
typedef pthread_key_t mdbx_thread_key_t;
|
typedef pthread_key_t mdbx_thread_key_t;
|
||||||
#define INVALID_HANDLE_VALUE (-1)
|
#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);
|
return __sync_fetch_and_add(p, v);
|
||||||
#else
|
#else
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
return _InterlockedExchangeAdd64(p, v);
|
return _InterlockedExchangeAdd64((volatile int64_t *)p, v);
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSAtomicAdd64(v, (volatile int64_t *)p);
|
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);
|
return __sync_bool_compare_and_swap(p, c, v);
|
||||||
#else
|
#else
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
return c == _InterlockedCompareExchange64(p, v, c);
|
return c == _InterlockedCompareExchange64((volatile int64_t *)p, v, c);
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return c == OSAtomicCompareAndSwap64Barrier(c, v, (volatile uint64_t *)p);
|
return c == OSAtomicCompareAndSwap64Barrier(c, v, (volatile uint64_t *)p);
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
|
|
||||||
#include "../mdbx.h"
|
#include "../mdbx.h"
|
||||||
#include "../src/defs.h"
|
#include "../src/defs.h"
|
||||||
|
#include "../src/osal.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
@ -62,7 +62,7 @@ inline time from_seconds(uint64_t seconds) {
|
|||||||
|
|
||||||
inline time from_utc(time_t utc) {
|
inline time from_utc(time_t utc) {
|
||||||
assert(utc >= 0);
|
assert(utc >= 0);
|
||||||
return from_seconds(utc);
|
return from_seconds((uint64_t)utc);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline time infinite() {
|
inline time infinite() {
|
||||||
|
@ -66,7 +66,7 @@ const char *keygencase2str(const keygen_case keycase) {
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void mdbx_debug_logger(int type, const char *function, int line,
|
static void mdbx_logger(int type, const char *function, int line,
|
||||||
const char *msg, va_list args) {
|
const char *msg, va_list args) {
|
||||||
logging::loglevel level = logging::info;
|
logging::loglevel level = logging::info;
|
||||||
if (type & MDBX_DBG_EXTRA)
|
if (type & MDBX_DBG_EXTRA)
|
||||||
@ -120,7 +120,7 @@ void testcase::db_prepare() {
|
|||||||
mdbx_dbg_opts |= MDBX_DBG_TRACE;
|
mdbx_dbg_opts |= MDBX_DBG_TRACE;
|
||||||
if (config.params.loglevel <= logging::verbose)
|
if (config.params.loglevel <= logging::verbose)
|
||||||
mdbx_dbg_opts |= MDBX_DBG_PRINT;
|
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);
|
log_info("set mdbx debug-opts: 0x%02x", rc);
|
||||||
|
|
||||||
MDBX_env *env = nullptr;
|
MDBX_env *env = nullptr;
|
||||||
|
@ -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) {
|
static __inline unsigned add_with_carry(uint64_t *sum, uint64_t addend) {
|
||||||
*sum += 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) {
|
static __inline uint64_t mul_64x64_128(uint64_t a, uint64_t b, uint64_t *h) {
|
||||||
|
Loading…
Reference in New Issue
Block a user