Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/memory/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,13 @@ bool map::remap_(size_t size) NOEXCEPT
// disk_full: space is set but no code is set with false return.
bool map::resize_(size_t size) NOEXCEPT
{
// Disk full detection is platform common, any other failure is an abort.
// Disk full detection, any other failure is an abort.
#if defined(HAVE_APPLE)
// TODO: implement fallocate for macOS (open and write a byte per block).
if (::ftruncate(opened_, size) == fail)
#else
if (::fallocate(opened_, 0, capacity_, size - capacity_) == fail)
#endif
{
// Disk full is the only restartable store failure (leave mapped).
if (errno == ENOSPC)
Expand Down
5 changes: 5 additions & 0 deletions src/memory/mman-win32/mman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ int fsync(int fd) noexcept
return 0;
}

int fallocate(int fd, int mode, oft__ offset, oft__ size) noexcept
{
return ftruncate(fd, offset + size);
}

int ftruncate(int fd, oft__ size) noexcept
{
LARGE_INTEGER big{};
Expand Down
1 change: 1 addition & 0 deletions src/memory/mman-win32/mman.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int msync(void* addr, size_t len, int flags) noexcept;
int mlock(const void* addr, size_t len) noexcept;
int munlock(const void* addr, size_t len) noexcept;
int fsync(int fd) noexcept;
int fallocate(int fd, int mode, oft__ offset, oft__ size) noexcept;
int ftruncate(int fd, oft__ size) noexcept;

#endif // _WIN32
Expand Down
Loading