From 7147ea0144add7d1716e2c4da62aea7368db3f1f Mon Sep 17 00:00:00 2001 From: 3405691582 Date: Mon, 8 Aug 2022 19:38:02 -0400 Subject: [PATCH] Make platform-specific mmap flags the exception. (#1929) MAP_POPULATE is a Linux mmap flag that optionally assists read-ahead on the mapping. It is nonstandard and omission does not affect the underlying mapping, so fall back to not including the flag, rather than the reverse. --- toolchain/source/source_buffer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toolchain/source/source_buffer.cpp b/toolchain/source/source_buffer.cpp index d123d96de640..51128d52ba17 100644 --- a/toolchain/source/source_buffer.cpp +++ b/toolchain/source/source_buffer.cpp @@ -79,10 +79,10 @@ auto SourceBuffer::CreateFromFile(llvm::StringRef filename) errno = 0; void* mapped_text = mmap(nullptr, size, PROT_READ, -#ifdef __APPLE__ - MAP_PRIVATE, -#else +#if defined(__linux__) MAP_PRIVATE | MAP_POPULATE, +#else + MAP_PRIVATE, #endif file_descriptor, /*offset=*/0); // The `MAP_FAILED` macro may expand to a cast to pointer that `clang-tidy`