mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 19:24:13 +08:00
mdbx: определение ior_WriteFile_flag
для ясности кода.
This commit is contained in:
parent
8c74de57ea
commit
9cee1ff799
31
src/osal.c
31
src/osal.c
@ -567,6 +567,7 @@ MDBX_MAYBE_UNUSED MDBX_INTERNAL_FUNC size_t osal_mb2w(wchar_t *dst,
|
|||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#define ior_alignment_mask (ior->pagesize - 1)
|
#define ior_alignment_mask (ior->pagesize - 1)
|
||||||
|
#define ior_WriteFile_flag 1
|
||||||
#define OSAL_IOV_MAX (4096 / sizeof(ior_sgv_element))
|
#define OSAL_IOV_MAX (4096 / sizeof(ior_sgv_element))
|
||||||
|
|
||||||
static void ior_put_event(osal_ioring_t *ior, HANDLE event) {
|
static void ior_put_event(osal_ioring_t *ior, HANDLE event) {
|
||||||
@ -677,7 +678,7 @@ MDBX_INTERNAL_FUNC int osal_ioring_add(osal_ioring_t *ior, const size_t offset,
|
|||||||
(uintptr_t)(uint64_t)item->sgv[0].Buffer) &
|
(uintptr_t)(uint64_t)item->sgv[0].Buffer) &
|
||||||
ior_alignment_mask) == 0 &&
|
ior_alignment_mask) == 0 &&
|
||||||
ior->last_sgvcnt + segments < OSAL_IOV_MAX) {
|
ior->last_sgvcnt + segments < OSAL_IOV_MAX) {
|
||||||
assert((item->single.iov_len & 1) == 0);
|
assert((item->single.iov_len & ior_WriteFile_flag) == 0);
|
||||||
assert(item->sgv[ior->last_sgvcnt].Buffer == 0);
|
assert(item->sgv[ior->last_sgvcnt].Buffer == 0);
|
||||||
ior->last_bytes += bytes;
|
ior->last_bytes += bytes;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
@ -687,13 +688,13 @@ MDBX_INTERNAL_FUNC int osal_ioring_add(osal_ioring_t *ior, const size_t offset,
|
|||||||
} while (++i < segments);
|
} while (++i < segments);
|
||||||
ior->slots_left -= segments;
|
ior->slots_left -= segments;
|
||||||
item->sgv[ior->last_sgvcnt += segments].Buffer = 0;
|
item->sgv[ior->last_sgvcnt += segments].Buffer = 0;
|
||||||
assert((item->single.iov_len & 1) == 0);
|
assert((item->single.iov_len & ior_WriteFile_flag) == 0);
|
||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
const void *end =
|
const void *end = (char *)(item->single.iov_base) + item->single.iov_len -
|
||||||
(char *)(item->single.iov_base) + item->single.iov_len - 1;
|
ior_WriteFile_flag;
|
||||||
if (unlikely(end == data)) {
|
if (unlikely(end == data)) {
|
||||||
assert((item->single.iov_len & 1) != 0);
|
assert((item->single.iov_len & ior_WriteFile_flag) != 0);
|
||||||
item->single.iov_len += bytes;
|
item->single.iov_len += bytes;
|
||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -740,8 +741,8 @@ MDBX_INTERNAL_FUNC int osal_ioring_add(osal_ioring_t *ior, const size_t offset,
|
|||||||
segments > OSAL_IOV_MAX) {
|
segments > OSAL_IOV_MAX) {
|
||||||
/* WriteFile() */
|
/* WriteFile() */
|
||||||
item->single.iov_base = data;
|
item->single.iov_base = data;
|
||||||
item->single.iov_len = bytes + 1;
|
item->single.iov_len = bytes + ior_WriteFile_flag;
|
||||||
assert((item->single.iov_len & 1) != 0);
|
assert((item->single.iov_len & ior_WriteFile_flag) != 0);
|
||||||
} else {
|
} else {
|
||||||
/* WriteFileGather() */
|
/* WriteFileGather() */
|
||||||
item->sgv[0].Buffer = PtrToPtr64(data);
|
item->sgv[0].Buffer = PtrToPtr64(data);
|
||||||
@ -750,7 +751,7 @@ MDBX_INTERNAL_FUNC int osal_ioring_add(osal_ioring_t *ior, const size_t offset,
|
|||||||
item->sgv[slots_used].Buffer = PtrToPtr64(data);
|
item->sgv[slots_used].Buffer = PtrToPtr64(data);
|
||||||
}
|
}
|
||||||
item->sgv[slots_used].Buffer = 0;
|
item->sgv[slots_used].Buffer = 0;
|
||||||
assert((item->single.iov_len & 1) == 0);
|
assert((item->single.iov_len & ior_WriteFile_flag) == 0);
|
||||||
slots_used = segments;
|
slots_used = segments;
|
||||||
}
|
}
|
||||||
ior->last_bytes = bytes;
|
ior->last_bytes = bytes;
|
||||||
@ -778,9 +779,9 @@ MDBX_INTERNAL_FUNC void osal_ioring_walk(
|
|||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
size_t offset = ior_offset(item);
|
size_t offset = ior_offset(item);
|
||||||
char *data = item->single.iov_base;
|
char *data = item->single.iov_base;
|
||||||
size_t bytes = item->single.iov_len - 1;
|
size_t bytes = item->single.iov_len - ior_WriteFile_flag;
|
||||||
size_t i = 1;
|
size_t i = 1;
|
||||||
if (bytes & 1) {
|
if (bytes & ior_WriteFile_flag) {
|
||||||
data = Ptr64ToPtr(item->sgv[0].Buffer);
|
data = Ptr64ToPtr(item->sgv[0].Buffer);
|
||||||
bytes = ior->pagesize;
|
bytes = ior->pagesize;
|
||||||
while (item->sgv[i].Buffer) {
|
while (item->sgv[i].Buffer) {
|
||||||
@ -824,9 +825,9 @@ osal_ioring_write(osal_ioring_t *ior) {
|
|||||||
LONG async_started = 0;
|
LONG async_started = 0;
|
||||||
for (ior_item_t *item = ior->pool; item <= ior->last;) {
|
for (ior_item_t *item = ior->pool; item <= ior->last;) {
|
||||||
item->ov.Internal = STATUS_PENDING;
|
item->ov.Internal = STATUS_PENDING;
|
||||||
size_t i = 1, bytes = item->single.iov_len - 1;
|
size_t i = 1, bytes = item->single.iov_len - ior_WriteFile_flag;
|
||||||
r.wops += 1;
|
r.wops += 1;
|
||||||
if (bytes & 1) {
|
if (bytes & ior_WriteFile_flag) {
|
||||||
bytes = ior->pagesize;
|
bytes = ior->pagesize;
|
||||||
while (item->sgv[i].Buffer) {
|
while (item->sgv[i].Buffer) {
|
||||||
bytes += ior->pagesize;
|
bytes += ior->pagesize;
|
||||||
@ -964,8 +965,8 @@ osal_ioring_write(osal_ioring_t *ior) {
|
|||||||
|
|
||||||
assert(ior->async_waiting == ior->async_completed);
|
assert(ior->async_waiting == ior->async_completed);
|
||||||
for (ior_item_t *item = ior->pool; item <= ior->last;) {
|
for (ior_item_t *item = ior->pool; item <= ior->last;) {
|
||||||
size_t i = 1, bytes = item->single.iov_len - 1;
|
size_t i = 1, bytes = item->single.iov_len - ior_WriteFile_flag;
|
||||||
if (bytes & 1) {
|
if (bytes & ior_WriteFile_flag) {
|
||||||
bytes = ior->pagesize;
|
bytes = ior->pagesize;
|
||||||
while (item->sgv[i].Buffer) {
|
while (item->sgv[i].Buffer) {
|
||||||
bytes += ior->pagesize;
|
bytes += ior->pagesize;
|
||||||
@ -1059,7 +1060,7 @@ MDBX_INTERNAL_FUNC void osal_ioring_reset(osal_ioring_t *ior) {
|
|||||||
if (item->ov.hEvent && item->ov.hEvent != ior)
|
if (item->ov.hEvent && item->ov.hEvent != ior)
|
||||||
ior_put_event(ior, item->ov.hEvent);
|
ior_put_event(ior, item->ov.hEvent);
|
||||||
size_t i = 1;
|
size_t i = 1;
|
||||||
if ((item->single.iov_len & 1) == 0)
|
if ((item->single.iov_len & ior_WriteFile_flag) == 0)
|
||||||
while (item->sgv[i].Buffer)
|
while (item->sgv[i].Buffer)
|
||||||
++i;
|
++i;
|
||||||
item = ior_next(item, i);
|
item = ior_next(item, i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user