diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-12-31 23:23:35 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-12-31 23:23:35 +0000 |
commit | 814afe91ccad0e5e1f767303d780fa0318fa5212 (patch) | |
tree | 9905492e5626775b81a12370475b4325f59b8e3e /lib/Support/Unix | |
parent | 02d75477cd9bed5acf46979869f041e7f9726200 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171330 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r-- | lib/Support/Unix/Process.inc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Support/Unix/Process.inc b/lib/Support/Unix/Process.inc index e96d37ce56..9ad6272bab 100644 --- a/lib/Support/Unix/Process.inc +++ b/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; |