mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:14:14 +08:00
mdbx: Merge branch 'devel'.
This commit is contained in:
commit
5f90052274
14
src/mdbx.c
14
src/mdbx.c
@ -4188,8 +4188,9 @@ static int mdbx_sync_locked(MDBX_env *env, unsigned flags,
|
||||
if ((flags & (MDBX_NOSYNC | MDBX_NOMETASYNC)) == 0) {
|
||||
mdbx_assert(env, ((flags ^ env->me_flags) & MDBX_WRITEMAP) == 0);
|
||||
if (flags & MDBX_WRITEMAP) {
|
||||
const size_t offset = (uint8_t *)container_of(head, MDBX_page, mp_meta) -
|
||||
env->me_dxb_mmap.dxb;
|
||||
const size_t offset =
|
||||
((uint8_t *)container_of(head, MDBX_page, mp_meta)) -
|
||||
env->me_dxb_mmap.dxb;
|
||||
const size_t paged_offset = offset & ~(env->me_os_psize - 1);
|
||||
const size_t paged_length = mdbx_roundup2(
|
||||
env->me_psize + offset - paged_offset, env->me_os_psize);
|
||||
@ -4852,7 +4853,7 @@ static int __cold mdbx_setup_dxb(MDBX_env *env, int lck_rc) {
|
||||
head->mm_datasync_sign = MDBX_DATASIGN_WEAK;
|
||||
head->mm_txnid_b = 0;
|
||||
const size_t offset =
|
||||
(uint8_t *)container_of(head, MDBX_page, mp_meta) -
|
||||
((uint8_t *)container_of(head, MDBX_page, mp_meta)) -
|
||||
env->me_dxb_mmap.dxb;
|
||||
const size_t paged_offset = offset & ~(env->me_os_psize - 1);
|
||||
const size_t paged_length = mdbx_roundup2(
|
||||
@ -10750,9 +10751,10 @@ int mdbx_txn_straggler(MDBX_txn *txn, int *percent)
|
||||
|
||||
MDBX_env *env = txn->mt_env;
|
||||
if (unlikely((txn->mt_flags & MDBX_RDONLY) == 0)) {
|
||||
*percent =
|
||||
(int)((txn->mt_next_pgno * UINT64_C(100) + txn->mt_end_pgno / 2) /
|
||||
txn->mt_end_pgno);
|
||||
if (percent)
|
||||
*percent =
|
||||
(int)((txn->mt_next_pgno * UINT64_C(100) + txn->mt_end_pgno / 2) /
|
||||
txn->mt_end_pgno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
29
src/osal.c
29
src/osal.c
@ -17,6 +17,8 @@
|
||||
#include "./bits.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <winternl.h>
|
||||
|
||||
static int waitstatus2errcode(DWORD result) {
|
||||
switch (result) {
|
||||
case WAIT_OBJECT_0:
|
||||
@ -53,25 +55,6 @@ static int ntstatus2errcode(NTSTATUS status) {
|
||||
* ntdll.dll, which is not linked by default in user code. */
|
||||
#pragma comment(lib, "ntdll.lib")
|
||||
|
||||
#ifndef NT_SUCCESS
|
||||
#define NT_SUCCESS(x) ((x) >= 0)
|
||||
#define STATUS_SUCCESS ((NTSTATUS)0)
|
||||
#endif
|
||||
typedef struct _UNICODE_STRING {
|
||||
USHORT Length;
|
||||
USHORT MaximumLength;
|
||||
PWSTR Buffer;
|
||||
} UNICODE_STRING, *PUNICODE_STRING;
|
||||
|
||||
typedef struct _OBJECT_ATTRIBUTES {
|
||||
ULONG Length;
|
||||
HANDLE RootDirectory;
|
||||
PUNICODE_STRING ObjectName;
|
||||
ULONG Attributes;
|
||||
PVOID SecurityDescriptor;
|
||||
PVOID SecurityQualityOfService;
|
||||
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
|
||||
|
||||
extern NTSTATUS NTAPI NtCreateSection(
|
||||
OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess,
|
||||
IN OPTIONAL POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
@ -104,14 +87,6 @@ extern NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||
IN OUT PULONG RegionSize,
|
||||
IN ULONG FreeType);
|
||||
|
||||
typedef struct _IO_STATUS_BLOCK {
|
||||
union {
|
||||
NTSTATUS Status;
|
||||
PVOID Pointer;
|
||||
};
|
||||
ULONG_PTR Information;
|
||||
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
|
||||
|
||||
#ifndef FILE_PROVIDER_CURRENT_VERSION
|
||||
typedef struct _FILE_PROVIDER_EXTERNAL_INFO_V1 {
|
||||
ULONG Version;
|
||||
|
@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
|
||||
rc = mdbx_env_create(&env);
|
||||
if (rc != MDBX_SUCCESS) {
|
||||
fprintf(stderr, "mdbx_env_create: (%d) %s\n", rc, mdbx_strerror(rc));
|
||||
return 0;
|
||||
goto bailout;
|
||||
}
|
||||
rc = mdbx_env_open(env, "./example-db",
|
||||
MDBX_NOSUBDIR | MDBX_COALESCE | MDBX_LIFORECLAIM, 0664);
|
||||
|
Loading…
x
Reference in New Issue
Block a user