Skip to content

Commit b785e03

Browse files
Support: mapped_file_region: Pass MAP_NORESERVE to mmap
This allows mapping larger files, delaying OOM failures until too many pages of them are accessed. This is makes the behavior of the mapped_file_region in this regard consistent between its "Unix" and "Windows" implementations. Guard the code witih #if defined(MAP_NORESERVE), consistent with other uses of MAP_NORESERVE in llvm-project, because some FreeBSD versions do not provide this flag. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D96626
1 parent 3344cd3 commit b785e03

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/lib/Support/Unix/Path.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,9 @@ std::error_code mapped_file_region::init(int FD, uint64_t Offset,
815815

816816
int flags = (Mode == readwrite) ? MAP_SHARED : MAP_PRIVATE;
817817
int prot = (Mode == readonly) ? PROT_READ : (PROT_READ | PROT_WRITE);
818+
#if defined(MAP_NORESERVE)
819+
flags |= MAP_NORESERVE;
820+
#endif
818821
#if defined(__APPLE__)
819822
//----------------------------------------------------------------------
820823
// Newer versions of MacOSX have a flag that will allow us to read from

0 commit comments

Comments
 (0)