Skip to content

Commit 5bfa91f

Browse files
committed
Use WITH_MADVISE and WITH_FALLOCATE pp defines to bypass.
1 parent b043003 commit 5bfa91f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/memory/map.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,11 @@ bool map::resize_(size_t size) NOEXCEPT
562562
// TODO: implement fallocate for macOS (open and write a byte per block).
563563
if (::ftruncate(opened_, size) == fail)
564564
#else
565+
#if defined (WITH_FALLOCATE)
565566
if (::fallocate(opened_, 0, capacity_, size - capacity_) == fail)
567+
#else
568+
if (::ftruncate(opened_, size) == fail)
569+
#endif
566570
#endif
567571
{
568572
// Disk full is the only restartable store failure (leave mapped).
@@ -594,6 +598,7 @@ bool map::finalize_(size_t size) NOEXCEPT
594598
return false;
595599
}
596600

601+
#if defined (WITH_MADVISE)
597602
#if !defined(HAVE_MSC)
598603
// Get page size (usually 4KB).
599604
const int page_size = ::sysconf(_SC_PAGESIZE);
@@ -629,6 +634,7 @@ bool map::finalize_(size_t size) NOEXCEPT
629634
}
630635
}
631636
#endif
637+
#endif // WITH_MADVISE
632638

633639
loaded_ = true;
634640
capacity_ = size;

0 commit comments

Comments
 (0)