Skip to content

Commit

Permalink
fix mmap size is 0 under win32
Browse files Browse the repository at this point in the history
  • Loading branch information
qgymib committed Aug 22, 2024
1 parent 1bc41eb commit 18f1fe1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ev.c
Original file line number Diff line number Diff line change
Expand Up @@ -6633,8 +6633,8 @@ void ev_async_wakeup(ev_async_t* handle)
// #line 56 "ev.c"
////////////////////////////////////////////////////////////////////////////////
// FILE: ev/win/fs_win.c
// SIZE: 25361
// SHA-256: 155bc78ea838a43dc37820d47b02616620673d6e08f85cc985ac2ea3dc44ec57
// SIZE: 25618
// SHA-256: 09ccbb955078ce7dc36361df1aa4ce13d475941639a08b584012ae6a29c5adb3
////////////////////////////////////////////////////////////////////////////////
// #line 1 "ev/win/fs_win.c"
#include <assert.h>
Expand Down Expand Up @@ -7487,6 +7487,17 @@ int ev_file_mmap(ev_file_map_t* view, ev_file_t* file, uint64_t size, int flags)
{
DWORD errcode;

if (size == 0)
{
LARGE_INTEGER file_sz;
if (!GetFileSizeEx(file->file, &file_sz))
{
errcode = GetLastError();
return ev__translate_sys_error(errcode);
}
size = file_sz.QuadPart;
}

const DWORD dwMaximumSizeHigh = size >> 32;
const DWORD dwMaximumSizeLow = (DWORD)size;
const DWORD flProtect = _ev_file_mmap_to_native_protect_win32(flags);
Expand Down
11 changes: 11 additions & 0 deletions src/ev/win/fs_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,17 @@ int ev_file_mmap(ev_file_map_t* view, ev_file_t* file, uint64_t size, int flags)
{
DWORD errcode;

if (size == 0)
{
LARGE_INTEGER file_sz;
if (!GetFileSizeEx(file->file, &file_sz))
{
errcode = GetLastError();
return ev__translate_sys_error(errcode);
}
size = file_sz.QuadPart;
}

const DWORD dwMaximumSizeHigh = size >> 32;
const DWORD dwMaximumSizeLow = (DWORD)size;
const DWORD flProtect = _ev_file_mmap_to_native_protect_win32(flags);
Expand Down

0 comments on commit 18f1fe1

Please sign in to comment.