Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Use sysconf(_SC_NPROCESSORS_CONF) to get number of processors (#5853)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas authored May 25, 2018
1 parent ece4ed1 commit 57289ff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Native/Runtime/unix/PalRedhawkUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,10 @@ bool QueryCacheSize()
bool QueryLogicalProcessorCount()
{
#if HAVE_SYSCONF
g_cLogicalCpus = sysconf(_SC_NPROCESSORS_ONLN);
g_cLogicalCpus = sysconf(_SC_NPROCESSORS_CONF);
if (g_cLogicalCpus < 1)
{
ASSERT_UNCONDITIONALLY("sysconf failed for _SC_NPROCESSORS_ONLN\n");
ASSERT_UNCONDITIONALLY("sysconf failed for _SC_NPROCESSORS_CONF\n");
return false;
}
#elif HAVE_SYSCTL
Expand Down Expand Up @@ -1268,10 +1268,10 @@ bool InitializeSystemInfo()
int nrcpus = 0;

#if HAVE_SYSCONF
nrcpus = sysconf(_SC_NPROCESSORS_ONLN);
nrcpus = sysconf(_SC_NPROCESSORS_CONF);
if (nrcpus < 1)
{
ASSERT_UNCONDITIONALLY("sysconf failed for _SC_NPROCESSORS_ONLN\n");
ASSERT_UNCONDITIONALLY("sysconf failed for _SC_NPROCESSORS_CONF\n");
return false;
}
#elif HAVE_SYSCTL
Expand Down
2 changes: 1 addition & 1 deletion src/Native/System.Private.CoreLib.Native/pal_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extern "C" int32_t CoreLibNative_GetCpuUtilization(ProcessCpuInformation* previo
{
if (numProcessors <= 0)
{
numProcessors = sysconf(_SC_NPROCESSORS_ONLN);
numProcessors = sysconf(_SC_NPROCESSORS_CONF);
if (numProcessors <= 0)
{
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Native/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static pthread_mutex_t g_flushProcessWriteBuffersMutex;
bool GCToOSInterface::Initialize()
{
// Calculate and cache the number of processors on this machine
int cpuCount = sysconf(_SC_NPROCESSORS_ONLN);
int cpuCount = sysconf(_SC_NPROCESSORS_CONF);
if (cpuCount == -1)
{
return false;
Expand Down

0 comments on commit 57289ff

Please sign in to comment.