|
|
@ -245,7 +245,7 @@ union semun { |
|
|
|
#define ESECT |
|
|
|
#define ESECT |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef _MSC_VER |
|
|
|
#ifdef _WIN32 |
|
|
|
#define CALL_CONV WINAPI |
|
|
|
#define CALL_CONV WINAPI |
|
|
|
#else |
|
|
|
#else |
|
|
|
#define CALL_CONV |
|
|
|
#define CALL_CONV |
|
|
@ -458,7 +458,11 @@ typedef pthread_mutex_t mdb_mutex_t[1], *mdb_mutexref_t; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef MDB_VL32 |
|
|
|
#ifdef MDB_VL32 |
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
#define Y "I64" |
|
|
|
|
|
|
|
#else |
|
|
|
#define Y "ll" |
|
|
|
#define Y "ll" |
|
|
|
|
|
|
|
#endif |
|
|
|
#else |
|
|
|
#else |
|
|
|
#define Y Z |
|
|
|
#define Y Z |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -4096,7 +4100,7 @@ mdb_env_map(MDB_env *env, void *addr) |
|
|
|
int access = SECTION_MAP_READ; |
|
|
|
int access = SECTION_MAP_READ; |
|
|
|
HANDLE mh; |
|
|
|
HANDLE mh; |
|
|
|
void *map; |
|
|
|
void *map; |
|
|
|
size_t msize = 0; |
|
|
|
SIZE_T msize = 0; |
|
|
|
ULONG pageprot = PAGE_READONLY; |
|
|
|
ULONG pageprot = PAGE_READONLY; |
|
|
|
if (flags & MDB_WRITEMAP) { |
|
|
|
if (flags & MDB_WRITEMAP) { |
|
|
|
access |= SECTION_MAP_WRITE; |
|
|
|
access |= SECTION_MAP_WRITE; |
|
|
@ -5547,17 +5551,32 @@ mdb_cursor_push(MDB_cursor *mc, MDB_page *mp) |
|
|
|
* @return 0 on success, non-zero on failure. |
|
|
|
* @return 0 on success, non-zero on failure. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static int |
|
|
|
static int |
|
|
|
mdb_rpage_get(MDB_txn *txn, pgno_t pgno, MDB_page **ret) |
|
|
|
mdb_rpage_get(MDB_txn *txn, pgno_t pg0, MDB_page **ret) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MDB_env *env = txn->mt_env; |
|
|
|
MDB_env *env = txn->mt_env; |
|
|
|
MDB_page *p; |
|
|
|
MDB_page *p; |
|
|
|
MDB_ID3L rl = txn->mt_rpages; |
|
|
|
MDB_ID3L rl = txn->mt_rpages; |
|
|
|
MDB_ID3L el = env->me_rpages; |
|
|
|
MDB_ID3L el = env->me_rpages; |
|
|
|
unsigned x = mdb_mid3l_search(rl, pgno); |
|
|
|
unsigned x; |
|
|
|
|
|
|
|
pgno_t pgno; |
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
/* Even though Windows uses 4KB pages, all mappings must begin
|
|
|
|
|
|
|
|
* on 64KB boundaries. So we round off all pgnos to the |
|
|
|
|
|
|
|
* appropriate boundary and then offset the pointer just |
|
|
|
|
|
|
|
* before returning. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* FIXME: we need to do special handling for overflow pages. |
|
|
|
|
|
|
|
* Most likely by keeping a separate list for them. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
pgno = pg0 / 16; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
pgno = pg0; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
x = mdb_mid3l_search(rl, pgno); |
|
|
|
if (x <= rl[0].mid && rl[x].mid == pgno) { |
|
|
|
if (x <= rl[0].mid && rl[x].mid == pgno) { |
|
|
|
|
|
|
|
p = rl[x].mptr; |
|
|
|
rl[x].mref++; |
|
|
|
rl[x].mref++; |
|
|
|
*ret = rl[x].mptr; |
|
|
|
goto ok; |
|
|
|
return MDB_SUCCESS; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (rl[0].mid >= MDB_IDL_UM_MAX) { |
|
|
|
if (rl[0].mid >= MDB_IDL_UM_MAX) { |
|
|
@ -5615,16 +5634,22 @@ mdb_rpage_get(MDB_txn *txn, pgno_t pgno, MDB_page **ret) |
|
|
|
el[0].mid = y-1; |
|
|
|
el[0].mid = y-1; |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
off_t off = pgno * env->me_psize; |
|
|
|
LARGE_INTEGER off; |
|
|
|
DWORD lo, hi; |
|
|
|
SIZE_T mlen; |
|
|
|
lo = off & 0xffffffff; |
|
|
|
int rc; |
|
|
|
hi = off >> 16 >> 16; |
|
|
|
off.QuadPart = pgno * env->me_psize * 16; |
|
|
|
p = MapViewOfFile(env->me_fmh, FILE_MAP_READ, hi, lo, len); |
|
|
|
p = NULL; |
|
|
|
if (p == NULL) { |
|
|
|
np = 16; |
|
|
|
|
|
|
|
len *= 16; |
|
|
|
|
|
|
|
mlen = len; |
|
|
|
|
|
|
|
rc = NtMapViewOfSection(env->me_fmh, GetCurrentProcess(), (void **)&p, 0, |
|
|
|
|
|
|
|
mlen, &off, &mlen, ViewUnmap, MEM_RESERVE, PAGE_READONLY); |
|
|
|
|
|
|
|
if (rc) { |
|
|
|
fail: |
|
|
|
fail: |
|
|
|
UNLOCK_MUTEX(env->me_rpmutex); |
|
|
|
UNLOCK_MUTEX(env->me_rpmutex); |
|
|
|
return ErrCode(); |
|
|
|
return rc; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if 0 |
|
|
|
if (IS_OVERFLOW(p)) { |
|
|
|
if (IS_OVERFLOW(p)) { |
|
|
|
np = p->mp_pages; |
|
|
|
np = p->mp_pages; |
|
|
|
UnmapViewOfFile(p); |
|
|
|
UnmapViewOfFile(p); |
|
|
@ -5633,6 +5658,7 @@ fail: |
|
|
|
if (p == NULL) |
|
|
|
if (p == NULL) |
|
|
|
goto fail; |
|
|
|
goto fail; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
#else |
|
|
|
#else |
|
|
|
off_t off = pgno * env->me_psize; |
|
|
|
off_t off = pgno * env->me_psize; |
|
|
|
p = mmap(NULL, len, PROT_READ, MAP_SHARED, env->me_fd, off); |
|
|
|
p = mmap(NULL, len, PROT_READ, MAP_SHARED, env->me_fd, off); |
|
|
@ -5665,7 +5691,16 @@ found: |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return MDB_TXN_FULL; |
|
|
|
return MDB_TXN_FULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ok: |
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char *v = (char *)p; |
|
|
|
|
|
|
|
v += (pg0 & 0x0f) * env->me_psize; |
|
|
|
|
|
|
|
*ret = (MDB_page *)v; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
*ret = p; |
|
|
|
*ret = p; |
|
|
|
|
|
|
|
#endif |
|
|
|
return MDB_SUCCESS; |
|
|
|
return MDB_SUCCESS; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|