Browse Source

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.
3405691582 3 years ago
parent
commit
7147ea0144
1 changed files with 3 additions and 3 deletions
  1. 3 3
      toolchain/source/source_buffer.cpp

+ 3 - 3
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`