summaryrefslogtreecommitdiff
path: root/src/mongo/util/processinfo_darwin.cpp
diff options
context:
space:
mode:
authorAndrea Lattuada <andrea.lattuada@10gen.com>2012-11-13 16:34:57 -0500
committerAndrea Lattuada <andrea.lattuada@10gen.com>2012-11-13 16:34:57 -0500
commitfe38a5e9f8a06e0db57e89b97b9af1bfb789bff0 (patch)
tree50040a8c9e217f6389c4a170e3e3b6d43e2ef55e /src/mongo/util/processinfo_darwin.cpp
parent93fdafcb4c4883d401a0726b67f2141404daa9ee (diff)
downloadmongo-fe38a5e9f8a06e0db57e89b97b9af1bfb789bff0.tar.gz
SERVER-7570 changed ProcessInfo::blockInMemory to leverage getPageSize, added pagesInMemory
Diffstat (limited to 'src/mongo/util/processinfo_darwin.cpp')
-rw-r--r--src/mongo/util/processinfo_darwin.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mongo/util/processinfo_darwin.cpp b/src/mongo/util/processinfo_darwin.cpp
index 044e33b21f1..3f5658658e8 100644
--- a/src/mongo/util/processinfo_darwin.cpp
+++ b/src/mongo/util/processinfo_darwin.cpp
@@ -185,18 +185,25 @@ namespace mongo {
return true;
}
- bool ProcessInfo::blockInMemory( char * start ) {
- static long pageSize = 0;
- if ( pageSize == 0 ) {
- pageSize = sysconf( _SC_PAGESIZE );
- }
- start = start - ( (unsigned long long)start % pageSize );
+ bool ProcessInfo::blockInMemory(const void* start) {
char x = 0;
- if ( mincore( start , 128 , &x ) ) {
+ if (mincore(alignToStartOfPage(start), getPageSize(), &x)) {
log() << "mincore failed: " << errnoWithDescription() << endl;
return 1;
}
return x & 0x1;
}
+ bool ProcessInfo::pagesInMemory(const void* start, size_t numPages, vector<char>* out) {
+ out->resize(numPages);
+ if (mincore(alignToStartOfPage(start), numPages * getPageSize(), &out->front())) {
+ log() << "mincore failed: " << errnoWithDescription() << endl;
+ return false;
+ }
+ for (size_t i = 0; i < numPages; ++i) {
+ (*out)[i] &= 0x1;
+ }
+ return true;
+ }
+
}