Use sysconf(_SC_NPROCESSORS_CONF) to get number of processors (#5853)
Port https://github.com/dotnet/coreclr/pull/18053/
This commit is contained in:
Родитель
ece4ed1e32
Коммит
57289ff33d
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче