ITS#9017 LMDB: fix off_t usage on Windows

mdb.master3
Howard Chu 4 years ago
parent 485465b6a7
commit 7deed69202
  1. 16
      libraries/liblmdb/mdb.c

@ -96,6 +96,7 @@ static NtCloseFunc *NtClose;
# define SSIZE_MAX INT_MAX
# endif
#endif
#define MDB_OFF_T LARGE_INTEGER
#else
#include <sys/types.h>
#include <sys/stat.h>
@ -108,6 +109,7 @@ static NtCloseFunc *NtClose;
#include <sys/file.h>
#endif
#include <fcntl.h>
#define MDB_OFF_T off_t
#endif
#if defined(__mips) && defined(__linux)
@ -1596,7 +1598,7 @@ struct MDB_env {
MDB_txn *me_txn; /**< current write transaction */
MDB_txn *me_txn0; /**< prealloc'd write transaction */
mdb_size_t me_mapsize; /**< size of the data memory map */
off_t me_size; /**< current file size */
MDB_OFF_T me_size; /**< current file size */
pgno_t me_maxpg; /**< me_mapsize / me_psize */
MDB_dbx *me_dbxs; /**< array of static DB info */
uint16_t *me_dbflags; /**< array of flags from MDB_db.md_flags */
@ -3907,7 +3909,7 @@ mdb_page_flush(MDB_txn *txn, int keep)
unsigned psize = env->me_psize, j;
int i, pagecount = dl[0].mid, rc;
size_t size = 0;
off_t pos = 0;
MDB_OFF_T pos = 0;
pgno_t pgno = 0;
MDB_page *dp = NULL;
#if MDB_RPAGE_CACHE
@ -3924,7 +3926,7 @@ mdb_page_flush(MDB_txn *txn, int keep)
HANDLE fd = env->me_fd;
#endif
ssize_t wsize = 0, wres;
off_t wpos = 0, next_pos = 1; /* impossible pos, so pos != next_pos */
MDB_OFF_T wpos = 0, next_pos = 1; /* impossible pos, so pos != next_pos */
int n = 0;
j = i = keep;
@ -4560,7 +4562,7 @@ mdb_env_write_meta(MDB_txn *txn)
MDB_meta meta, metab, *mp;
unsigned flags;
mdb_size_t mapsize;
off_t off;
MDB_OFF_T off;
int rc, len, toggle;
char *ptr;
HANDLE mfd;
@ -5586,7 +5588,7 @@ mdb_env_setup_locks(MDB_env *env, MDB_name *fname, int mode, int *excl)
union semun semu;
#endif
int rc;
off_t size, rsize;
MDB_OFF_T size, rsize;
rc = mdb_fopen(env, fname, MDB_O_LOCKS, mode, &env->me_lfd);
if (rc) {
@ -6535,7 +6537,7 @@ mdb_rpage_get(MDB_txn *txn, pgno_t pg0, int numpgs, MDB_page **ret)
pgno_t pgno;
int rc, retries = 1;
#ifdef _WIN32
LARGE_INTEGER off;
MDB_OFF_T off;
SIZE_T len;
#define SET_OFF(off,val) off.QuadPart = val
#define MAP(rc,env,addr,len,off) \
@ -6544,7 +6546,7 @@ mdb_rpage_get(MDB_txn *txn, pgno_t pg0, int numpgs, MDB_page **ret)
len, &off, &len, ViewUnmap, (env->me_flags & MDB_RDONLY) ? 0 : MEM_RESERVE, PAGE_READONLY); \
if (rc) rc = mdb_nt2win32(rc)
#else
off_t off;
MDB_OFF_T off;
size_t len;
#define SET_OFF(off,val) off = val
#define MAP(rc,env,addr,len,off) \

Loading…
Cancel
Save