From f6a2add230fd8d30101e29a9ac5d3420a8c3ca57 Mon Sep 17 00:00:00 2001 From: Igor Bonadio and Helton Alponti Date: Mon, 23 Oct 2017 16:58:15 +0000 Subject: [PATCH] Activate flag MAP_POPULATE when compiled with -DMAP_POPULATE --- lib/marisa/grimoire/io/mapper.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/marisa/grimoire/io/mapper.cc b/lib/marisa/grimoire/io/mapper.cc index 6ae0ee3..2c397ba 100644 --- a/lib/marisa/grimoire/io/mapper.cc +++ b/lib/marisa/grimoire/io/mapper.cc @@ -145,7 +145,12 @@ void Mapper::open_(const char *filename) { fd_ = ::open(filename, O_RDONLY); MARISA_THROW_IF(fd_ == -1, MARISA_IO_ERROR); +#ifdef MAP_POPULATE + origin_ = ::mmap(NULL, size_, PROT_READ, MAP_SHARED | MAP_POPULATE, fd_, 0); +#else origin_ = ::mmap(NULL, size_, PROT_READ, MAP_SHARED, fd_, 0); +#endif + MARISA_THROW_IF(origin_ == MAP_FAILED, MARISA_IO_ERROR); ptr_ = static_cast(origin_);