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/Windows/Process.inc | |
parent | 02d75477cd9bed5acf46979869f041e7f9726200 (diff) | |
download | external_llvm-814afe91ccad0e5e1f767303d780fa0318fa5212.zip external_llvm-814afe91ccad0e5e1f767303d780fa0318fa5212.tar.gz external_llvm-814afe91ccad0e5e1f767303d780fa0318fa5212.tar.bz2 |
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/Windows/Process.inc')
-rw-r--r-- | lib/Support/Windows/Process.inc | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc index d3a0c94..9eb611b 100644 --- a/lib/Support/Windows/Process.inc +++ b/lib/Support/Windows/Process.inc @@ -43,11 +43,9 @@ process::id_type self_process::get_id() { return GetCurrentProcess(); } - // This function retrieves the page size using GetSystemInfo and is present -// solely so it can be called once in Process::GetPageSize to initialize the -// static variable PageSize. -inline unsigned GetPageSizeOnce() { +// solely so it can be called once to initialize the self_process member below. +static unsigned getPageSize() { // NOTE: A 32-bit application running under WOW64 is supposed to use // GetNativeSystemInfo. However, this interface is not present prior // to Windows XP so to use it requires dynamic linking. It is not clear @@ -58,12 +56,12 @@ inline unsigned GetPageSizeOnce() { return static_cast<unsigned>(info.dwPageSize); } -unsigned -Process::GetPageSize() { - static const unsigned PageSize = GetPageSizeOnce(); - return PageSize; +// 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() { |