mdbx: fix/redefine ssize_t, PRI*PTR nad PRI*size macros for MSVC.

Change-Id: I6cb565087350cf1d1e1735bff1c5480c3d4c02db
This commit is contained in:
Leonid Yuriev 2017-07-26 18:32:46 +03:00 committed by Leo Yuriev
parent 336bef7e51
commit 092156ee4f
9 changed files with 86 additions and 106 deletions

11
mdbx.h
View File

@ -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.
*

View File

@ -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 >= (ssize_t)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++;
@ -3075,7 +3067,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 > (ssize_t)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 */
@ -3094,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);
@ -3235,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;
@ -4118,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)))
@ -4128,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;
}
@ -4147,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;
@ -4161,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;
@ -4253,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;
@ -4282,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;
}
@ -4434,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;
@ -4466,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);
}
@ -6984,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 */
@ -7389,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 */
@ -7423,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)) {
@ -7440,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;
@ -7452,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:
@ -10312,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;

View File

@ -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

View File

@ -609,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

View File

@ -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"

View File

@ -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"

View File

@ -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>

View File

@ -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;
}

View File

@ -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];