/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
if (pageSize == 0) {
- pageSize = sysconf(_SC_PAGESIZE);
+ pageSize = off_t(sysconf(_SC_PAGESIZE));
}
CHECK_GT(pageSize, 0);
CHECK_GE(offset, 0);
// Round down the start of the mapped region
- size_t skipStart = offset % pageSize;
+ off_t skipStart = offset % pageSize;
offset -= skipStart;
mapLength_ = length;
return chunkSize;
}
- chunkSize = FLAGS_mlock_chunk_size;
+ chunkSize = off_t(FLAGS_mlock_chunk_size);
off_t r = chunkSize % pageSize;
if (r) {
chunkSize += (pageSize - r);
// chunks breaks the locking into intervals and lets other threads do memory
// operations of their own.
- size_t chunkSize = memOpChunkSize(bufSize, pageSize);
+ size_t chunkSize = memOpChunkSize(off_t(bufSize), pageSize);
char* addr = static_cast<char*>(mem);
amountSucceeded = 0;
}
auto msg =
- folly::sformat("mlock({}) failed at {}", mapLength_, amountSucceeded);
-
- if (lock == LockMode::TRY_LOCK && (errno == EPERM || errno == ENOMEM)) {
+ folly::format("mlock({}) failed at {}", mapLength_, amountSucceeded);
+ if (lock == LockMode::TRY_LOCK && errno == EPERM) {
PLOG(WARNING) << msg;
+ } else if (lock == LockMode::TRY_LOCK && errno == ENOMEM) {
+ VLOG(1) << msg;
} else {
PLOG(FATAL) << msg;
}
void MemoryMapping::advise(int advice) const { advise(advice, 0, mapLength_); }
void MemoryMapping::advise(int advice, size_t offset, size_t length) const {
- CHECK_LE(offset + length, mapLength_)
+ CHECK_LE(offset + length, size_t(mapLength_))
<< " offset: " << offset
<< " length: " << length
<< " mapLength_: " << mapLength_;
MemoryMapping destMap(
File(dest, O_RDWR | O_CREAT | O_TRUNC, mode),
0,
- srcMap.range().size(),
+ off_t(srcMap.range().size()),
MemoryMapping::writable());
alignedForwardMemcpy(destMap.writableRange().data(),