mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:10:14 +01:00
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.
This commit is contained in:
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user