diff options
author | David Wrighton <davidwr@microsoft.com> | 2017-09-13 14:50:39 -0700 |
---|---|---|
committer | David Wrighton <davidwr@microsoft.com> | 2017-09-13 14:50:39 -0700 |
commit | d68f0916d0a2bf3787bc85261ef4a4f1f27f1f24 (patch) | |
tree | 6c21ac239ae268096f20d98a8db16a4b80394fd9 /src/gc/unix/gcenv.unix.cpp | |
parent | 96fa98525e0d64459148228cde5211c475b0c25c (diff) | |
parent | e866d072042f4ad9e0811aa36e338dac781c09a5 (diff) | |
download | coreclr-d68f0916d0a2bf3787bc85261ef4a4f1f27f1f24.tar.gz coreclr-d68f0916d0a2bf3787bc85261ef4a4f1f27f1f24.tar.bz2 coreclr-d68f0916d0a2bf3787bc85261ef4a4f1f27f1f24.zip |
Merge branch 'master' into update_from_master
Diffstat (limited to 'src/gc/unix/gcenv.unix.cpp')
-rw-r--r-- | src/gc/unix/gcenv.unix.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/gc/unix/gcenv.unix.cpp b/src/gc/unix/gcenv.unix.cpp index 5693fb4ff5..f564b28239 100644 --- a/src/gc/unix/gcenv.unix.cpp +++ b/src/gc/unix/gcenv.unix.cpp @@ -6,32 +6,15 @@ #include <cstddef> #include <cassert> #include <memory> - -// The CoreCLR PAL defines _POSIX_C_SOURCE to avoid calling non-posix pthread functions. -// This isn't something we want, because we're totally fine using non-posix functions. -#if defined(__APPLE__) - #define _DARWIN_C_SOURCE -#endif // definfed(__APPLE__) - #include <pthread.h> #include <signal.h> #include "config.h" -// clang typedefs uint64_t to be unsigned long long, which clashes with -// PAL/MSVC's unsigned long, causing linker errors. This ugly hack -// will go away once the GC doesn't depend on PAL headers. -typedef unsigned long uint64_t_hack; -#define uint64_t uint64_t_hack -static_assert(sizeof(uint64_t) == 8, "unsigned long isn't 8 bytes"); - -#ifndef __out_z -#define __out_z -#endif // __out_z - #include "gcenv.structs.h" #include "gcenv.base.h" #include "gcenv.os.h" #include "gcenv.unix.inl" +#include "volatile.h" #if HAVE_SYS_TIME_H #include <sys/time.h> @@ -66,6 +49,7 @@ static pthread_mutex_t g_flushProcessWriteBuffersMutex; size_t GetRestrictedPhysicalMemoryLimit(); bool GetWorkingSetSize(size_t* val); +bool GetCpuLimit(uint32_t* val); static size_t g_RestrictedPhysicalMemoryLimit = 0; @@ -507,6 +491,7 @@ bool GCToOSInterface::GetCurrentProcessAffinityMask(uintptr_t* processAffinityMa uint32_t GCToOSInterface::GetCurrentProcessCpuCount() { uintptr_t pmask, smask; + uint32_t cpuLimit; if (!GetCurrentProcessAffinityMask(&pmask, &smask)) return 1; @@ -530,6 +515,9 @@ uint32_t GCToOSInterface::GetCurrentProcessCpuCount() if (count == 0 || count > 64) count = 64; + if (GetCpuLimit(&cpuLimit) && cpuLimit < count) + count = cpuLimit; + return count; } |