summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-12-31 23:23:35 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-12-31 23:23:35 +0000
commit15dcad9e36029d715163d1c374a042d1e50f281f (patch)
treeb18f66c66e626306aa8c232a319ec849343f946f /llvm/lib/Support/Unix
parentaadd30ec52c0e3a5fd478c9b89b4a33108d4affc (diff)
downloadbcm5719-llvm-15dcad9e36029d715163d1c374a042d1e50f281f.tar.gz
bcm5719-llvm-15dcad9e36029d715163d1c374a042d1e50f281f.zip
Flesh out a page size accessor in the new API.
Implement the old API in terms of the new one. This simplifies the implementation on Windows which can now re-use the self_process's once initialization. llvm-svn: 171330
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/Process.inc11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index e96d37ce563..9ad6272bab4 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -49,10 +49,7 @@ process::id_type self_process::get_id() {
return getpid();
}
-
-unsigned
-Process::GetPageSize()
-{
+static unsigned getPageSize() {
#if defined(__CYGWIN__)
// On Cygwin, getpagesize() returns 64k but the page size for the purposes of
// memory protection and mmap() is 4k.
@@ -68,6 +65,12 @@ Process::GetPageSize()
return static_cast<unsigned>(page_size);
}
+// This constructor guaranteed to be run exactly once on a single thread, and
+// sets up various process invariants that can be queried cheaply from then on.
+self_process::self_process() : PageSize(getPageSize()) {
+}
+
+
size_t Process::GetMallocUsage() {
#if defined(HAVE_MALLINFO)
struct mallinfo mi;
OpenPOWER on IntegriCloud