<< " length: " << length
<< " mapLength_: " << mapLength_;
- if (length == 0) {
- return;
+ // Include the entire start page: round down to page boundary.
+ const auto offMisalign = offset % options_.pageSize;
+ offset -= offMisalign;
+ length += offMisalign;
+
+ // Round the last page down to page boundary.
+ if (offset + length != size_t(mapLength_)) {
+ length -= length % options_.pageSize;
}
- auto offMisalign = offset % options_.pageSize;
- if (offMisalign != 0) {
- offset -= offMisalign;
- length += offMisalign;
+ if (length == 0) {
+ return;
}
- length = (length + options_.pageSize - 1) & ~(options_.pageSize - 1);
- length = std::min<size_t>(length, mapLength_ - offset);
-
char* mapStart = static_cast<char*>(mapStart_) + offset;
PLOG_IF(WARNING, ::madvise(mapStart, length, advice)) << "madvise";
}