From 652ca2b5cb1c79a0ee906de8d053a4c736ee39bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Tue, 8 Nov 2022 15:52:06 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-windows:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B8=D0=BD=D0=BE?= =?UTF-8?q?=D1=80=D0=BD=D1=8B=D1=85=20=D0=BF=D1=80=D0=B5=D0=B4=D1=83=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8=D0=B9=20MingGW.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lck-windows.c | 32 ++++++++++++++------------------ src/osal.c | 37 +++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/lck-windows.c b/src/lck-windows.c index 96d416ad..3bbe3f3b 100644 --- a/src/lck-windows.c +++ b/src/lck-windows.c @@ -112,11 +112,10 @@ static #define LCK_WAITFOR 0 #define LCK_DONTWAIT LOCKFILE_FAIL_IMMEDIATELY -static int flock_with_event(HANDLE fd, HANDLE event, DWORD flags, - uint64_t offset, size_t bytes) { - TRACE("lock>>: fd %p, event %p, flags 0x%x offset %" PRId64 ", bytes %" PRId64 - " >>", - fd, event, flags, offset, bytes); +static int flock_with_event(HANDLE fd, HANDLE event, unsigned flags, + size_t offset, size_t bytes) { + TRACE("lock>>: fd %p, event %p, flags 0x%x offset %zu, bytes %zu >>", fd, + event, flags, offset, bytes); OVERLAPPED ov; ov.Internal = 0; ov.InternalHigh = 0; @@ -124,9 +123,8 @@ static int flock_with_event(HANDLE fd, HANDLE event, DWORD flags, ov.Offset = (DWORD)offset; ov.OffsetHigh = HIGH_DWORD(offset); if (LockFileEx(fd, flags, 0, (DWORD)bytes, HIGH_DWORD(bytes), &ov)) { - TRACE("lock<<: fd %p, event %p, flags 0x%x offset %" PRId64 - ", bytes %" PRId64 " << %s", - fd, event, flags, offset, bytes, "done"); + TRACE("lock<<: fd %p, event %p, flags 0x%x offset %zu, bytes %zu << %s", fd, + event, flags, offset, bytes, "done"); return MDBX_SUCCESS; } @@ -134,8 +132,7 @@ static int flock_with_event(HANDLE fd, HANDLE event, DWORD flags, if (rc == ERROR_IO_PENDING) { if (event) { if (GetOverlappedResult(fd, &ov, &rc, true)) { - TRACE("lock<<: fd %p, event %p, flags 0x%x offset %" PRId64 - ", bytes %" PRId64 " << %s", + TRACE("lock<<: fd %p, event %p, flags 0x%x offset %zu, bytes %zu << %s", fd, event, flags, offset, bytes, "overlapped-done"); return MDBX_SUCCESS; } @@ -143,25 +140,24 @@ static int flock_with_event(HANDLE fd, HANDLE event, DWORD flags, } else CancelIo(fd); } - TRACE("lock<<: fd %p, event %p, flags 0x%x offset %" PRId64 ", bytes %" PRId64 - " << err %d", - fd, event, flags, offset, bytes, rc); + TRACE("lock<<: fd %p, event %p, flags 0x%x offset %zu, bytes %zu << err %d", + fd, event, flags, offset, bytes, (int)rc); return (int)rc; } -static __inline int flock(HANDLE fd, DWORD flags, uint64_t offset, +static __inline int flock(HANDLE fd, unsigned flags, size_t offset, size_t bytes) { return flock_with_event(fd, 0, flags, offset, bytes); } -static __inline int flock_data(const MDBX_env *env, DWORD flags, - uint64_t offset, size_t bytes) { +static __inline int flock_data(const MDBX_env *env, unsigned flags, + size_t offset, size_t bytes) { return flock_with_event(env->me_fd4data, env->me_data_lock_event, flags, offset, bytes); } -static int funlock(mdbx_filehandle_t fd, uint64_t offset, size_t bytes) { - TRACE("unlock: fd %p, offset %" PRId64 ", bytes %" PRId64, fd, offset, bytes); +static int funlock(mdbx_filehandle_t fd, size_t offset, size_t bytes) { + TRACE("unlock: fd %p, offset %zu, bytes %zu", fd, offset, bytes); return UnlockFile(fd, (DWORD)offset, HIGH_DWORD(offset), (DWORD)bytes, HIGH_DWORD(bytes)) ? MDBX_SUCCESS diff --git a/src/osal.c b/src/osal.c index 5d1339d3..494290a2 100644 --- a/src/osal.c +++ b/src/osal.c @@ -853,9 +853,10 @@ osal_ioring_write(osal_ioring_t *ior) { if (unlikely(r.err != ERROR_IO_PENDING)) { ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64 ", err %d", - "WriteFileGather", ior->fd, item, item - ior->pool, - ((MDBX_page *)item->single.iov_base)->mp_pgno, bytes, - item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err); + "WriteFileGather", ior->fd, __Wpedantic_format_voidptr(item), + item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno, + bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), + r.err); goto bailout_rc; } assert(wait_for > ior->event_pool + ior->event_stack); @@ -874,9 +875,10 @@ osal_ioring_write(osal_ioring_t *ior) { default: ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64 ", err %d", - "WriteFileEx", ior->fd, item, item - ior->pool, - ((MDBX_page *)item->single.iov_base)->mp_pgno, bytes, - item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err); + "WriteFileEx", ior->fd, __Wpedantic_format_voidptr(item), + item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno, + bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), + r.err); goto bailout_rc; case ERROR_NOT_FOUND: case ERROR_USER_MAPPED_FILE: @@ -884,9 +886,10 @@ osal_ioring_write(osal_ioring_t *ior) { WARNING( "%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64 ", err %d", - "WriteFileEx", ior->fd, item, item - ior->pool, - ((MDBX_page *)item->single.iov_base)->mp_pgno, bytes, - item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err); + "WriteFileEx", ior->fd, __Wpedantic_format_voidptr(item), + item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno, + bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), + r.err); SleepEx(0, true); goto retry; case ERROR_INVALID_USER_BUFFER: @@ -906,9 +909,10 @@ osal_ioring_write(osal_ioring_t *ior) { r.err = (int)GetLastError(); ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64 ", err %d", - "WriteFile", ior->fd, item, item - ior->pool, - ((MDBX_page *)item->single.iov_base)->mp_pgno, bytes, - item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err); + "WriteFile", ior->fd, __Wpedantic_format_voidptr(item), + item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno, + bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), + r.err); goto bailout_rc; } else if (unlikely(written != bytes)) { r.err = ERROR_WRITE_FAULT; @@ -973,10 +977,11 @@ osal_ioring_write(osal_ioring_t *ior) { !GetOverlappedResult(ior->fd, &item->ov, &written, true))) { ERROR("%s: item %p (%zu), pgno %u, bytes %zu, offset %" PRId64 ", err %d", - "GetOverlappedResult", item, item - ior->pool, + "GetOverlappedResult", __Wpedantic_format_voidptr(item), + item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno, bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), - GetLastError()); + (int)GetLastError()); goto bailout_geterr; } assert(MDBX_SUCCESS == item->ov.Internal); @@ -994,10 +999,10 @@ osal_ioring_write(osal_ioring_t *ior) { r.err = (int)GetLastError(); ERROR("%s: item %p (%zu), pgno %u, bytes %zu, offset %" PRId64 ", err %d", - "Result", item, item - ior->pool, + "Result", __Wpedantic_format_voidptr(item), item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno, bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), - GetLastError()); + (int)GetLastError()); goto bailout_rc; } if (unlikely(item->ov.InternalHigh != bytes)) {