mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 16:44:13 +08:00
mdbx: Merge branch 'devel'.
This commit is contained in:
commit
4eada0f2b6
@ -97,7 +97,7 @@
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;%(PreprocessorDefinitions);MDBX_DEBUG=1</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<StringPooling>true</StringPooling>
|
||||
@ -113,7 +113,7 @@
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<StringPooling>true</StringPooling>
|
||||
<Optimization>Full</Optimization>
|
||||
@ -139,7 +139,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;%(PreprocessorDefinitions);MDBX_DEBUG=1</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<StringPooling>true</StringPooling>
|
||||
@ -157,7 +157,7 @@
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
|
11
mdbx.h
11
mdbx.h
@ -74,7 +74,6 @@ typedef unsigned mode_t;
|
||||
typedef HANDLE mdbx_filehandle_t;
|
||||
typedef DWORD mdbx_pid_t;
|
||||
typedef DWORD mdbx_tid_t;
|
||||
typedef SSIZE_T ssize_t;
|
||||
#define MDBX_ENODATA ERROR_HANDLE_EOF
|
||||
#define MDBX_EINVAL ERROR_INVALID_PARAMETER
|
||||
#define MDBX_EACCESS ERROR_ACCESS_DENIED
|
||||
@ -813,11 +812,11 @@ LIBMDBX_API int mdbx_env_get_fd(MDBX_env *env, mdbx_filehandle_t *fd);
|
||||
* - MDBX_EINVAL - an invalid parameter was specified,
|
||||
* or the environment has an active write transaction. */
|
||||
LIBMDBX_API int mdbx_env_set_mapsize(MDBX_env *env, size_t size);
|
||||
LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, ssize_t size_lower,
|
||||
ssize_t size_now, ssize_t size_upper,
|
||||
ssize_t growth_step,
|
||||
ssize_t shrink_threshold,
|
||||
ssize_t pagesize);
|
||||
LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
|
||||
intptr_t size_now, intptr_t size_upper,
|
||||
intptr_t growth_step,
|
||||
intptr_t shrink_threshold,
|
||||
intptr_t pagesize);
|
||||
|
||||
/* Set the maximum number of threads/reader slots for the environment.
|
||||
*
|
||||
|
92
src/mdbx.c
92
src/mdbx.c
@ -37,14 +37,6 @@
|
||||
|
||||
#include "./bits.h"
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER == 1900
|
||||
/* LY: MSVC 2015 has buggy/inconsistent PRIuPTR/PRIxPTR macros and format-arg
|
||||
checker for size_t typedef. */
|
||||
#pragma warning(disable : 4777) /* format string '%10u' requires an argument \
|
||||
of type 'unsigned int', but variadic \
|
||||
argument 1 has type 'std::size_t' */
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* rthc (tls keys and destructors) */
|
||||
|
||||
@ -1076,7 +1068,7 @@ static void __cold mdbx_kill_page(MDBX_env *env, pgno_t pgno) {
|
||||
VALGRIND_MAKE_MEM_NOACCESS(&mp->mp_pages, env->me_psize - shift);
|
||||
ASAN_POISON_MEMORY_REGION(&mp->mp_pages, env->me_psize - shift);
|
||||
} else {
|
||||
ssize_t len = env->me_psize - shift;
|
||||
intptr_t len = env->me_psize - shift;
|
||||
void *buf = alloca(len);
|
||||
memset(buf, 0x6F /* 'o', 111 */, len);
|
||||
(void)mdbx_pwrite(env->me_fd, buf, len, offs + shift);
|
||||
@ -2903,16 +2895,16 @@ static int mdbx_freelist_save(MDBX_txn *txn) {
|
||||
int rc, more = 1;
|
||||
txnid_t cleanup_reclaimed_id = 0, head_id = 0;
|
||||
pgno_t befree_count = 0;
|
||||
ssize_t head_room = 0, total_room = 0;
|
||||
intptr_t head_room = 0, total_room = 0;
|
||||
unsigned cleanup_reclaimed_pos = 0, refill_reclaimed_pos = 0;
|
||||
const bool lifo = (env->me_flags & MDBX_LIFORECLAIM) != 0;
|
||||
|
||||
mdbx_cursor_init(&mc, txn, FREE_DBI, NULL);
|
||||
|
||||
/* MDBX_RESERVE cancels meminit in ovpage malloc (when no WRITEMAP) */
|
||||
const ssize_t clean_limit = (env->me_flags & (MDBX_NOMEMINIT | MDBX_WRITEMAP))
|
||||
? SSIZE_MAX
|
||||
: env->me_maxfree_1pg;
|
||||
const intptr_t clean_limit =
|
||||
(env->me_flags & (MDBX_NOMEMINIT | MDBX_WRITEMAP)) ? SSIZE_MAX
|
||||
: env->me_maxfree_1pg;
|
||||
|
||||
again_on_freelist_change:
|
||||
while (1) {
|
||||
@ -3012,7 +3004,7 @@ again_on_freelist_change:
|
||||
continue;
|
||||
}
|
||||
|
||||
const ssize_t rpl_len =
|
||||
const intptr_t rpl_len =
|
||||
(env->me_reclaimed_pglist ? env->me_reclaimed_pglist[0] : 0) +
|
||||
txn->mt_loose_count;
|
||||
if (rpl_len && refill_reclaimed_pos == 0)
|
||||
@ -3024,7 +3016,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 >= (intptr_t)env->me_maxfree_1pg && head_id > 1) {
|
||||
/* Keep current record (overflow page), add a new one */
|
||||
head_id--;
|
||||
refill_reclaimed_pos++;
|
||||
@ -3066,13 +3058,16 @@ again_on_freelist_change:
|
||||
/* LY: note that freeDB cleanup is not needed. */
|
||||
++cleanup_reclaimed_pos;
|
||||
}
|
||||
mdbx_tassert(txn, txn->mt_lifo_reclaimed != NULL);
|
||||
head_id = txn->mt_lifo_reclaimed[refill_reclaimed_pos];
|
||||
} else {
|
||||
mdbx_tassert(txn, txn->mt_lifo_reclaimed == NULL);
|
||||
}
|
||||
|
||||
/* (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 > (intptr_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 */
|
||||
@ -3091,7 +3086,7 @@ again_on_freelist_change:
|
||||
|
||||
/* IDL is initially empty, zero out at least the length */
|
||||
pgno_t *pgs = (pgno_t *)data.iov_base;
|
||||
ssize_t i = head_room > clean_limit ? head_room : 0;
|
||||
intptr_t i = head_room > clean_limit ? head_room : 0;
|
||||
do {
|
||||
pgs[i] = 0;
|
||||
} while (--i >= 0);
|
||||
@ -3132,18 +3127,23 @@ again_on_freelist_change:
|
||||
|
||||
size_t rpl_left = env->me_reclaimed_pglist[0];
|
||||
pgno_t *rpl_end = env->me_reclaimed_pglist + rpl_left;
|
||||
if (!lifo) {
|
||||
if (txn->mt_lifo_reclaimed == 0) {
|
||||
mdbx_tassert(txn, lifo == 0);
|
||||
rc = mdbx_cursor_first(&mc, &key, &data);
|
||||
if (unlikely(rc))
|
||||
goto bailout;
|
||||
} else {
|
||||
mdbx_tassert(txn, lifo != 0);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
txnid_t id;
|
||||
if (!lifo) {
|
||||
if (txn->mt_lifo_reclaimed == 0) {
|
||||
mdbx_tassert(txn, lifo == 0);
|
||||
id = *(txnid_t *)key.iov_base;
|
||||
mdbx_tassert(txn, id <= env->me_last_reclaimed);
|
||||
} else {
|
||||
mdbx_tassert(txn, lifo != 0);
|
||||
mdbx_tassert(txn,
|
||||
refill_reclaimed_pos > 0 &&
|
||||
refill_reclaimed_pos <= txn->mt_lifo_reclaimed[0]);
|
||||
@ -3227,7 +3227,7 @@ static int mdbx_page_flush(MDBX_txn *txn, pgno_t keep) {
|
||||
pgno_t pgno = 0;
|
||||
MDBX_page *dp = NULL;
|
||||
struct iovec iov[MDBX_COMMIT_PAGES];
|
||||
ssize_t wpos = 0, wsize = 0;
|
||||
intptr_t wpos = 0, wsize = 0;
|
||||
size_t next_pos = 1; /* impossible pos, so pos != next_pos */
|
||||
int n = 0;
|
||||
|
||||
@ -4110,7 +4110,7 @@ int __cold mdbx_env_get_maxkeysize(MDBX_env *env) {
|
||||
}
|
||||
|
||||
#define mdbx_nodemax(pagesize) \
|
||||
(((((pagesize)-PAGEHDRSZ) / MDBX_MINKEYS) & -(ssize_t)2) - sizeof(indx_t))
|
||||
(((((pagesize)-PAGEHDRSZ) / MDBX_MINKEYS) & -(intptr_t)2) - sizeof(indx_t))
|
||||
|
||||
#define mdbx_maxkey(nodemax) ((nodemax) - (NODESIZE + sizeof(MDBX_db)))
|
||||
|
||||
@ -4120,11 +4120,11 @@ int mdbx_get_maxkeysize(size_t pagesize) {
|
||||
if (pagesize == 0)
|
||||
pagesize = mdbx_syspagesize();
|
||||
|
||||
ssize_t nodemax = mdbx_nodemax(pagesize);
|
||||
intptr_t nodemax = mdbx_nodemax(pagesize);
|
||||
if (nodemax < 0)
|
||||
return -MDBX_EINVAL;
|
||||
|
||||
ssize_t maxkey = mdbx_maxkey(nodemax);
|
||||
intptr_t maxkey = mdbx_maxkey(nodemax);
|
||||
return (maxkey > 0 && maxkey < INT_MAX) ? (int)maxkey : -MDBX_EINVAL;
|
||||
}
|
||||
|
||||
@ -4139,13 +4139,13 @@ static void __cold mdbx_setup_pagesize(MDBX_env *env, const size_t pagesize) {
|
||||
|
||||
STATIC_ASSERT(mdbx_maxfree1pg(MIN_PAGESIZE) > 42);
|
||||
STATIC_ASSERT(mdbx_maxfree1pg(MAX_PAGESIZE) < MDBX_IDL_DB_MAX);
|
||||
const ssize_t maxfree_1pg = (pagesize - PAGEHDRSZ) / sizeof(pgno_t) - 1;
|
||||
const intptr_t maxfree_1pg = (pagesize - PAGEHDRSZ) / sizeof(pgno_t) - 1;
|
||||
mdbx_ensure(env, maxfree_1pg > 42 && maxfree_1pg < MDBX_IDL_DB_MAX);
|
||||
env->me_maxfree_1pg = (unsigned)maxfree_1pg;
|
||||
|
||||
STATIC_ASSERT(mdbx_nodemax(MIN_PAGESIZE) > 42);
|
||||
STATIC_ASSERT(mdbx_nodemax(MAX_PAGESIZE) < UINT16_MAX);
|
||||
const ssize_t nodemax = mdbx_nodemax(pagesize);
|
||||
const intptr_t nodemax = mdbx_nodemax(pagesize);
|
||||
mdbx_ensure(env, nodemax > 42 && nodemax < UINT16_MAX);
|
||||
env->me_nodemax = (unsigned)nodemax;
|
||||
|
||||
@ -4153,7 +4153,7 @@ static void __cold mdbx_setup_pagesize(MDBX_env *env, const size_t pagesize) {
|
||||
STATIC_ASSERT(mdbx_maxkey(MIN_PAGESIZE) < MIN_PAGESIZE);
|
||||
STATIC_ASSERT(mdbx_maxkey(MAX_PAGESIZE) > 42);
|
||||
STATIC_ASSERT(mdbx_maxkey(MAX_PAGESIZE) < MAX_PAGESIZE);
|
||||
const ssize_t maxkey_limit = mdbx_maxkey(env->me_nodemax);
|
||||
const intptr_t maxkey_limit = mdbx_maxkey(env->me_nodemax);
|
||||
mdbx_ensure(env, maxkey_limit > 42 && (size_t)maxkey_limit < pagesize);
|
||||
env->me_maxkey_limit = (unsigned)maxkey_limit;
|
||||
|
||||
@ -4245,11 +4245,11 @@ static int __cold mdbx_env_map(MDBX_env *env, size_t usedsize) {
|
||||
return MDBX_SUCCESS;
|
||||
}
|
||||
|
||||
LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, ssize_t size_lower,
|
||||
ssize_t size_now, ssize_t size_upper,
|
||||
ssize_t growth_step,
|
||||
ssize_t shrink_threshold,
|
||||
ssize_t pagesize) {
|
||||
LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
|
||||
intptr_t size_now, intptr_t size_upper,
|
||||
intptr_t growth_step,
|
||||
intptr_t shrink_threshold,
|
||||
intptr_t pagesize) {
|
||||
if (unlikely(!env))
|
||||
return MDBX_EINVAL;
|
||||
|
||||
@ -4274,7 +4274,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, ssize_t size_lower,
|
||||
|
||||
if (pagesize < 0)
|
||||
pagesize = env->me_psize;
|
||||
if (pagesize != (ssize_t)env->me_psize) {
|
||||
if (pagesize != (intptr_t)env->me_psize) {
|
||||
rc = MDBX_EINVAL;
|
||||
goto bailout;
|
||||
}
|
||||
@ -4426,7 +4426,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, ssize_t size_lower,
|
||||
|
||||
if (env->me_map) {
|
||||
/* apply new params */
|
||||
mdbx_assert(env, pagesize == (ssize_t)env->me_psize);
|
||||
mdbx_assert(env, pagesize == (intptr_t)env->me_psize);
|
||||
|
||||
MDBX_meta *head = mdbx_meta_head(env);
|
||||
MDBX_meta meta = *head;
|
||||
@ -4458,7 +4458,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, ssize_t size_lower,
|
||||
mdbx_meta_set_txnid(env, &meta, mdbx_meta_txnid_stable(env, head) + 1);
|
||||
rc = mdbx_sync_locked(env, env->me_flags, &meta);
|
||||
}
|
||||
} else if (pagesize != (ssize_t)env->me_psize) {
|
||||
} else if (pagesize != (intptr_t)env->me_psize) {
|
||||
mdbx_setup_pagesize(env, pagesize);
|
||||
}
|
||||
|
||||
@ -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 ")",
|
||||
@ -6974,7 +6976,7 @@ int mdbx_cursor_put(MDBX_cursor *mc, MDBX_val *key, MDBX_val *data,
|
||||
* Copy end of page, adjusting alignment so
|
||||
* compiler may copy words instead of bytes. */
|
||||
const size_t off =
|
||||
(PAGEHDRSZ + data->iov_len) & -(ssize_t)sizeof(size_t);
|
||||
(PAGEHDRSZ + data->iov_len) & -(intptr_t)sizeof(size_t);
|
||||
memcpy((size_t *)((char *)np + off), (size_t *)((char *)omp + off),
|
||||
whole - off);
|
||||
memcpy(np, omp, PAGEHDRSZ); /* Copy header of page */
|
||||
@ -7379,7 +7381,7 @@ static int mdbx_node_add(MDBX_cursor *mc, unsigned indx, MDBX_val *key,
|
||||
MDBX_val *data, pgno_t pgno, unsigned flags) {
|
||||
unsigned i;
|
||||
size_t node_size = NODESIZE;
|
||||
ssize_t room;
|
||||
intptr_t room;
|
||||
MDBX_node *node;
|
||||
MDBX_page *mp = mc->mc_pg[mc->mc_top];
|
||||
MDBX_page *ofp = NULL; /* overflow page */
|
||||
@ -7413,7 +7415,7 @@ static int mdbx_node_add(MDBX_cursor *mc, unsigned indx, MDBX_val *key,
|
||||
return MDBX_SUCCESS;
|
||||
}
|
||||
|
||||
room = (ssize_t)SIZELEFT(mp) - (ssize_t)sizeof(indx_t);
|
||||
room = (intptr_t)SIZELEFT(mp) - (intptr_t)sizeof(indx_t);
|
||||
if (key != NULL)
|
||||
node_size += key->iov_len;
|
||||
if (IS_LEAF(mp)) {
|
||||
@ -7430,7 +7432,7 @@ static int mdbx_node_add(MDBX_cursor *mc, unsigned indx, MDBX_val *key,
|
||||
", put data on overflow page",
|
||||
data->iov_len, node_size + data->iov_len);
|
||||
node_size = EVEN(node_size + sizeof(pgno_t));
|
||||
if ((ssize_t)node_size > room)
|
||||
if ((intptr_t)node_size > room)
|
||||
goto full;
|
||||
if ((rc = mdbx_page_new(mc, P_OVERFLOW, ovpages, &ofp)))
|
||||
return rc;
|
||||
@ -7442,7 +7444,7 @@ static int mdbx_node_add(MDBX_cursor *mc, unsigned indx, MDBX_val *key,
|
||||
}
|
||||
}
|
||||
node_size = EVEN(node_size);
|
||||
if (unlikely((ssize_t)node_size > room))
|
||||
if (unlikely((intptr_t)node_size > room))
|
||||
goto full;
|
||||
|
||||
update:
|
||||
@ -10302,12 +10304,12 @@ int __cold mdbx_reader_list(MDBX_env *env, MDBX_msg_func *func, void *ctx) {
|
||||
const txnid_t txnid = lck->mti_readers[i].mr_txnid;
|
||||
if (txnid == ~(txnid_t)0)
|
||||
snprintf(buf, sizeof(buf), "%10" PRIuPTR " %" PRIxPTR " -\n",
|
||||
(size_t)lck->mti_readers[i].mr_pid,
|
||||
(size_t)lck->mti_readers[i].mr_tid);
|
||||
(uintptr_t)lck->mti_readers[i].mr_pid,
|
||||
(uintptr_t)lck->mti_readers[i].mr_tid);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%10" PRIuPTR " %" PRIxPTR " %" PRIaTXN "\n",
|
||||
(size_t)lck->mti_readers[i].mr_pid,
|
||||
(size_t)lck->mti_readers[i].mr_tid, txnid);
|
||||
(uintptr_t)lck->mti_readers[i].mr_pid,
|
||||
(uintptr_t)lck->mti_readers[i].mr_tid, txnid);
|
||||
|
||||
if (first) {
|
||||
first = 0;
|
||||
|
@ -508,7 +508,7 @@ int mdbx_pread(mdbx_filehandle_t fd, void *buf, size_t bytes, uint64_t offset) {
|
||||
#else
|
||||
STATIC_ASSERT_MSG(sizeof(off_t) >= sizeof(size_t),
|
||||
"libmdbx requires 64-bit file I/O on 64-bit systems");
|
||||
ssize_t read = pread(fd, buf, bytes, offset);
|
||||
intptr_t read = pread(fd, buf, bytes, offset);
|
||||
if (read < 0) {
|
||||
int rc = errno;
|
||||
return (rc == MDBX_SUCCESS) ? /* paranoia */ MDBX_EIO : rc;
|
||||
@ -534,7 +534,7 @@ int mdbx_pwrite(mdbx_filehandle_t fd, const void *buf, size_t bytes,
|
||||
return GetLastError();
|
||||
#else
|
||||
int rc;
|
||||
ssize_t written;
|
||||
intptr_t written;
|
||||
do {
|
||||
STATIC_ASSERT_MSG(sizeof(off_t) >= sizeof(size_t),
|
||||
"libmdbx requires 64-bit file I/O on 64-bit systems");
|
||||
@ -562,7 +562,7 @@ int mdbx_pwritev(mdbx_filehandle_t fd, struct iovec *iov, int iovcnt,
|
||||
: MDBX_EIO /* ERROR_WRITE_FAULT */;
|
||||
#else
|
||||
int rc;
|
||||
ssize_t written;
|
||||
intptr_t written;
|
||||
do {
|
||||
STATIC_ASSERT_MSG(sizeof(off_t) >= sizeof(size_t),
|
||||
"libmdbx requires 64-bit file I/O on 64-bit systems");
|
||||
@ -593,7 +593,7 @@ int mdbx_write(mdbx_filehandle_t fd, const void *buf, size_t bytes) {
|
||||
if (unlikely(!WriteFile(fd, ptr, (DWORD)chunk, &written, NULL)))
|
||||
return GetLastError();
|
||||
#else
|
||||
ssize_t written = write(fd, ptr, chunk);
|
||||
intptr_t written = write(fd, ptr, chunk);
|
||||
if (written < 0) {
|
||||
int rc = errno;
|
||||
#ifdef SIGPIPE
|
||||
|
45
src/osal.h
45
src/osal.h
@ -83,13 +83,13 @@ typedef struct {
|
||||
typedef CRITICAL_SECTION mdbx_fastmutex_t;
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
typedef pthread_t mdbx_thread_t;
|
||||
typedef pthread_key_t mdbx_thread_key_t;
|
||||
#define INVALID_HANDLE_VALUE (-1)
|
||||
@ -515,7 +515,8 @@ int mdbx_rpid_check(MDBX_env *env, mdbx_pid_t pid);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Atomics */
|
||||
|
||||
#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) && \
|
||||
#if !defined(__cplusplus) && (__STDC_VERSION__ >= 201112L) && \
|
||||
!defined(__STDC_NO_ATOMICS__) && \
|
||||
(__GNUC_PREREQ(4, 9) || __CLANG_PREREQ(3, 8) || \
|
||||
!(defined(__GNUC__) || defined(__clang__)))
|
||||
#include <stdatomic.h>
|
||||
@ -538,7 +539,7 @@ int mdbx_rpid_check(MDBX_env *env, mdbx_pid_t pid);
|
||||
#endif
|
||||
|
||||
static __inline uint32_t mdbx_atomic_add32(volatile uint32_t *p, uint32_t v) {
|
||||
#if defined(ATOMIC_VAR_INIT)
|
||||
#if !defined(__cplusplus) && defined(ATOMIC_VAR_INIT)
|
||||
assert(atomic_is_lock_free(p));
|
||||
return atomic_fetch_add((_Atomic uint32_t *)p, v);
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
@ -554,14 +555,14 @@ static __inline uint32_t mdbx_atomic_add32(volatile uint32_t *p, uint32_t v) {
|
||||
}
|
||||
|
||||
static __inline uint64_t mdbx_atomic_add64(volatile uint64_t *p, uint64_t v) {
|
||||
#ifdef ATOMIC_VAR_INIT
|
||||
#if !defined(__cplusplus) && defined(ATOMIC_VAR_INIT)
|
||||
assert(atomic_is_lock_free(p));
|
||||
return atomic_fetch_add((_Atomic uint64_t *)p, v);
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
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);
|
||||
@ -569,12 +570,12 @@ static __inline uint64_t mdbx_atomic_add64(volatile uint64_t *p, uint64_t v) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#define mdbx_atomic_sub32(p, v) mdbx_atomic_add32(p, -(v))
|
||||
#define mdbx_atomic_sub64(p, v) mdbx_atomic_add64(p, -(v))
|
||||
#define mdbx_atomic_sub32(p, v) mdbx_atomic_add32(p, 0 - (v))
|
||||
#define mdbx_atomic_sub64(p, v) mdbx_atomic_add64(p, 0 - (v))
|
||||
|
||||
static __inline bool mdbx_atomic_compare_and_swap32(volatile uint32_t *p,
|
||||
uint32_t c, uint32_t v) {
|
||||
#ifdef ATOMIC_VAR_INIT
|
||||
#if !defined(__cplusplus) && defined(ATOMIC_VAR_INIT)
|
||||
assert(atomic_is_lock_free(p));
|
||||
return atomic_compare_exchange_strong((_Atomic uint32_t *)p, &c, v);
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
@ -591,14 +592,14 @@ static __inline bool mdbx_atomic_compare_and_swap32(volatile uint32_t *p,
|
||||
|
||||
static __inline bool mdbx_atomic_compare_and_swap64(volatile uint64_t *p,
|
||||
uint64_t c, uint64_t v) {
|
||||
#ifdef ATOMIC_VAR_INIT
|
||||
#if !defined(__cplusplus) && defined(ATOMIC_VAR_INIT)
|
||||
assert(atomic_is_lock_free(p));
|
||||
return atomic_compare_exchange_strong((_Atomic uint64_t *)p, &c, v);
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
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);
|
||||
@ -608,6 +609,30 @@ static __inline bool mdbx_atomic_compare_and_swap64(volatile uint64_t *p,
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 1920
|
||||
/* LY: MSVC 2015/2017 has buggy/inconsistent PRIuPTR/PRIxPTR macros
|
||||
* for internal format-args checker. */
|
||||
#undef PRIuPTR
|
||||
#undef PRIiPTR
|
||||
#undef PRIdPTR
|
||||
#undef PRIxPTR
|
||||
#define PRIuPTR "Iu"
|
||||
#define PRIiPTR "Ii"
|
||||
#define PRIdPTR "Id"
|
||||
#define PRIxPTR "Ix"
|
||||
#define PRIuSIZE "zu"
|
||||
#define PRIiSIZE "zi"
|
||||
#define PRIdSIZE "zd"
|
||||
#define PRIxSIZE "zx"
|
||||
#endif /* fix PRI*PTR for _MSC_VER */
|
||||
|
||||
#ifndef PRIuSIZE
|
||||
#define PRIuSIZE PRIuPTR
|
||||
#define PRIiSIZE PRIiPTR
|
||||
#define PRIdSIZE PRIdPTR
|
||||
#define PRIxSIZE PRIxPTR
|
||||
#endif /* PRI*SIZE macros for MSVC */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@ -18,14 +18,7 @@
|
||||
#pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||
#endif
|
||||
#pragma warning(disable : 4996) /* The POSIX name is deprecated... */
|
||||
#if _MSC_VER == 1900
|
||||
/* LY: MSVC 2015 has buggy/inconsistent PRIuPTR/PRIxPTR macros and format-arg
|
||||
checker for size_t typedef. */
|
||||
#pragma warning(disable : 4777) /* format string '%10u' requires an argument \
|
||||
of type 'unsigned int', but variadic \
|
||||
argument 1 has type 'std::size_t' */
|
||||
#endif
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
|
||||
#include "../bits.h"
|
||||
|
||||
|
@ -93,7 +93,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -106,7 +106,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -117,7 +117,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
@ -133,7 +133,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
|
@ -18,14 +18,7 @@
|
||||
#pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||
#endif
|
||||
#pragma warning(disable : 4996) /* The POSIX name is deprecated... */
|
||||
#if _MSC_VER == 1900
|
||||
/* LY: MSVC 2015 has buggy/inconsistent PRIuPTR/PRIxPTR macros and format-arg
|
||||
checker for size_t typedef. */
|
||||
#pragma warning(disable : 4777) /* format string '%10u' requires an argument \
|
||||
of type 'unsigned int', but variadic \
|
||||
argument 1 has type 'std::size_t' */
|
||||
#endif
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
|
||||
#include "../bits.h"
|
||||
|
||||
|
@ -93,7 +93,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -106,7 +106,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -117,7 +117,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
@ -133,7 +133,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
|
@ -18,14 +18,7 @@
|
||||
#pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||
#endif
|
||||
#pragma warning(disable : 4996) /* The POSIX name is deprecated... */
|
||||
#if _MSC_VER == 1900
|
||||
/* LY: MSVC 2015 has buggy/inconsistent PRIuPTR/PRIxPTR macros and format-arg
|
||||
checker for size_t typedef. */
|
||||
#pragma warning(disable : 4777) /* format string '%10u' requires an argument \
|
||||
of type 'unsigned int', but variadic \
|
||||
argument 1 has type 'std::size_t' */
|
||||
#endif
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
|
||||
#include "../bits.h"
|
||||
#include <ctype.h>
|
||||
|
@ -93,7 +93,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -106,7 +106,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -117,7 +117,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
@ -133,7 +133,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
|
@ -18,14 +18,7 @@
|
||||
#pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||
#endif
|
||||
#pragma warning(disable : 4996) /* The POSIX name is deprecated... */
|
||||
#if _MSC_VER == 1900
|
||||
/* LY: MSVC 2015 has buggy/inconsistent PRIuPTR/PRIxPTR macros and format-arg
|
||||
checker for size_t typedef. */
|
||||
#pragma warning(disable : 4777) /* format string '%10u' requires an argument \
|
||||
of type 'unsigned int', but variadic \
|
||||
argument 1 has type 'std::size_t' */
|
||||
#endif
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
|
||||
#include "../bits.h"
|
||||
#include <ctype.h>
|
||||
@ -96,8 +89,8 @@ static void readhdr(void) {
|
||||
} else if (!strncmp(dbuf.iov_base, "VERSION=", STRLENOF("VERSION="))) {
|
||||
version = atoi((char *)dbuf.iov_base + STRLENOF("VERSION="));
|
||||
if (version > 3) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": unsupported VERSION %d\n", prog,
|
||||
lineno, version);
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": unsupported VERSION %d\n",
|
||||
prog, lineno, version);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else if (!strncmp(dbuf.iov_base, "HEADER=END", STRLENOF("HEADER=END"))) {
|
||||
@ -108,7 +101,7 @@ static void readhdr(void) {
|
||||
mode |= PRINT;
|
||||
else if (strncmp((char *)dbuf.iov_base + STRLENOF("FORMAT="), "bytevalue",
|
||||
STRLENOF("bytevalue"))) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": unsupported FORMAT %s\n", prog,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": unsupported FORMAT %s\n", prog,
|
||||
lineno, (char *)dbuf.iov_base + STRLENOF("FORMAT="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -122,7 +115,7 @@ static void readhdr(void) {
|
||||
} else if (!strncmp(dbuf.iov_base, "type=", STRLENOF("type="))) {
|
||||
if (strncmp((char *)dbuf.iov_base + STRLENOF("type="), "btree",
|
||||
STRLENOF("btree"))) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": unsupported type %s\n", prog,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": unsupported type %s\n", prog,
|
||||
lineno, (char *)dbuf.iov_base + STRLENOF("type="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -134,7 +127,7 @@ static void readhdr(void) {
|
||||
void *unused;
|
||||
i = sscanf((char *)dbuf.iov_base + STRLENOF("mapaddr="), "%p", &unused);
|
||||
if (i != 1) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": invalid mapaddr %s\n", prog,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": invalid mapaddr %s\n", prog,
|
||||
lineno, (char *)dbuf.iov_base + STRLENOF("mapaddr="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -146,7 +139,7 @@ static void readhdr(void) {
|
||||
i = sscanf((char *)dbuf.iov_base + STRLENOF("mapsize="), "%" PRIu64 "",
|
||||
&envinfo.mi_mapsize);
|
||||
if (i != 1) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": invalid mapsize %s\n", prog,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": invalid mapsize %s\n", prog,
|
||||
lineno, (char *)dbuf.iov_base + STRLENOF("mapsize="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -159,7 +152,7 @@ static void readhdr(void) {
|
||||
i = sscanf((char *)dbuf.iov_base + STRLENOF("maxreaders="), "%u",
|
||||
&envinfo.mi_maxreaders);
|
||||
if (i != 1) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": invalid maxreaders %s\n", prog,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": invalid maxreaders %s\n", prog,
|
||||
lineno, (char *)dbuf.iov_base + STRLENOF("maxreaders="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -176,13 +169,13 @@ static void readhdr(void) {
|
||||
if (!dbflags[i].bit) {
|
||||
ptr = memchr(dbuf.iov_base, '=', dbuf.iov_len);
|
||||
if (!ptr) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": unexpected format\n", prog,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": unexpected format\n", prog,
|
||||
lineno);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
*ptr = '\0';
|
||||
fprintf(stderr,
|
||||
"%s: line %" PRIiPTR ": unrecognized keyword ignored: %s\n",
|
||||
"%s: line %" PRIiSIZE ": unrecognized keyword ignored: %s\n",
|
||||
prog, lineno, (char *)dbuf.iov_base);
|
||||
}
|
||||
}
|
||||
@ -191,7 +184,7 @@ static void readhdr(void) {
|
||||
}
|
||||
|
||||
static void badend(void) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": unexpected end of input\n", prog,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": unexpected end of input\n", prog,
|
||||
lineno);
|
||||
}
|
||||
|
||||
@ -247,7 +240,7 @@ static int readline(MDBX_val *out, MDBX_val *buf) {
|
||||
buf->iov_base = realloc(buf->iov_base, buf->iov_len * 2);
|
||||
if (!buf->iov_base) {
|
||||
Eof = 1;
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": out of memory, line too long\n",
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": out of memory, line too long\n",
|
||||
prog, lineno);
|
||||
return EOF;
|
||||
}
|
||||
@ -463,7 +456,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
rc = readline(&data, &dbuf);
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": failed to read key value\n",
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": failed to read key value\n",
|
||||
prog, lineno);
|
||||
goto txn_abort;
|
||||
}
|
||||
@ -480,7 +473,7 @@ int main(int argc, char *argv[]) {
|
||||
if (batch == 100) {
|
||||
rc = mdbx_txn_commit(txn);
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": txn_commit: %s\n", prog,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": txn_commit: %s\n", prog,
|
||||
lineno, mdbx_strerror(rc));
|
||||
goto env_close;
|
||||
}
|
||||
@ -502,7 +495,7 @@ int main(int argc, char *argv[]) {
|
||||
rc = mdbx_txn_commit(txn);
|
||||
txn = NULL;
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: line %" PRIiPTR ": txn_commit: %s\n", prog, lineno,
|
||||
fprintf(stderr, "%s: line %" PRIiSIZE ": txn_commit: %s\n", prog, lineno,
|
||||
mdbx_strerror(rc));
|
||||
goto env_close;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -106,7 +106,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -117,7 +117,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
@ -133,7 +133,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
|
@ -18,14 +18,7 @@
|
||||
#pragma warning(disable : 4464) /* relative include path contains '..' */
|
||||
#endif
|
||||
#pragma warning(disable : 4996) /* The POSIX name is deprecated... */
|
||||
#if _MSC_VER == 1900
|
||||
/* LY: MSVC 2015 has buggy/inconsistent PRIuPTR/PRIxPTR macros and format-arg
|
||||
checker for size_t typedef. */
|
||||
#pragma warning(disable : 4777) /* format string '%10u' requires an argument \
|
||||
of type 'unsigned int', but variadic \
|
||||
argument 1 has type 'std::size_t' */
|
||||
#endif
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
#endif /* _MSC_VER (warnings) */
|
||||
|
||||
#include "../bits.h"
|
||||
|
||||
@ -247,7 +240,7 @@ int main(int argc, char *argv[]) {
|
||||
if (freinfo > 1) {
|
||||
char *bad = "";
|
||||
pgno_t pg, prev;
|
||||
ssize_t i, j, span = 0;
|
||||
intptr_t i, j, span = 0;
|
||||
j = *iptr++;
|
||||
for (i = j, prev = NUM_METAS - 1; --i >= 0;) {
|
||||
pg = iptr[i];
|
||||
|
@ -93,7 +93,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -106,7 +106,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);LIBMDBX_IMPORTS=1</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
@ -117,7 +117,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
@ -133,7 +133,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<WarningLevel>EnableAllWarnings</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
|
12
test/base.h
12
test/base.h
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2017 Leonid Yuriev <leo@yuriev.ru>
|
||||
* and other libmdbx authors: please see AUTHORS file.
|
||||
* All rights reserved.
|
||||
@ -86,6 +86,7 @@
|
||||
|
||||
#include "../mdbx.h"
|
||||
#include "../src/defs.h"
|
||||
#include "../src/osal.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
@ -98,7 +99,14 @@
|
||||
#pragma warning(disable : 4512) /* assignment operator could \
|
||||
not be generated */
|
||||
#pragma warning(disable : 4610) /* user-defined constructor required */
|
||||
#define snprintf _snprintf
|
||||
#ifndef snprintf
|
||||
#define snprintf(buffer, buffer_size, format, ...) \
|
||||
_snprintf_s(buffer, buffer_size, _TRUNCATE, format, __VA_ARGS__)
|
||||
#endif
|
||||
#ifndef vsnprintf
|
||||
#define vsnprintf(buffer, buffer_size, format, args) \
|
||||
_vsnprintf_s(buffer, buffer_size, _TRUNCATE, format, args)
|
||||
#endif
|
||||
#pragma warning(disable : 4996) /* 'vsnprintf': This function or variable \
|
||||
may be unsafe */
|
||||
#endif
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user