summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Chesakov <Egor.Chesakov@microsoft.com>2018-05-18 15:03:00 -0700
committerRuss Keldorph <russ.keldorph@microsoft.com>2018-05-31 15:25:05 -0700
commit0ea5fc4456a859a1009b05d0949d3d878b383e9d (patch)
tree36bee11bfd35852be846a6b1b0bfc425aff601b1
parent9550fc87a8ace6347e02fb9d103185fe191dafa9 (diff)
downloadcoreclr-0ea5fc4456a859a1009b05d0949d3d878b383e9d.tar.gz
coreclr-0ea5fc4456a859a1009b05d0949d3d878b383e9d.tar.bz2
coreclr-0ea5fc4456a859a1009b05d0949d3d878b383e9d.zip
Use sysconf(_SC_NPROCESSORS_CONF) instead of sysconf(_SC_NPROCESSORS_ONLN) in PAL and GC on ARM and ARM64
-rw-r--r--src/gc/unix/gcenv.unix.cpp8
-rw-r--r--src/pal/src/misc/sysinfo.cpp12
2 files changed, 17 insertions, 3 deletions
diff --git a/src/gc/unix/gcenv.unix.cpp b/src/gc/unix/gcenv.unix.cpp
index 737c5efcf0..f34dd8993b 100644
--- a/src/gc/unix/gcenv.unix.cpp
+++ b/src/gc/unix/gcenv.unix.cpp
@@ -40,6 +40,12 @@
#include <unistd.h> // sysconf
#include "globals.h"
+#if defined(_ARM_) || defined(_ARM64_)
+#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
+#else
+#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
+#endif
+
// The cachced number of logical CPUs observed.
static uint32_t g_logicalCpuCount = 0;
@@ -67,7 +73,7 @@ bool GCToOSInterface::Initialize()
g_pageSizeUnixInl = uint32_t((pageSize > 0) ? pageSize : 0x1000);
// Calculate and cache the number of processors on this machine
- int cpuCount = sysconf(_SC_NPROCESSORS_ONLN);
+ int cpuCount = sysconf(SYSCONF_GET_NUMPROCS);
if (cpuCount == -1)
{
return false;
diff --git a/src/pal/src/misc/sysinfo.cpp b/src/pal/src/misc/sysinfo.cpp
index bc55dadd4b..495cc8bb94 100644
--- a/src/pal/src/misc/sysinfo.cpp
+++ b/src/pal/src/misc/sysinfo.cpp
@@ -103,10 +103,18 @@ PAL_GetLogicalCpuCountFromOS()
int nrcpus = 0;
#if HAVE_SYSCONF
- nrcpus = sysconf(_SC_NPROCESSORS_ONLN);
+
+#if defined(_ARM_) || defined(_ARM64_)
+#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
+#define SYSCONF_GET_NUMPROCS_NAME "_SC_NPROCESSORS_CONF"
+#else
+#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
+#define SYSCONF_GET_NUMPROCS_NAME "_SC_NPROCESSORS_ONLN"
+#endif
+ nrcpus = sysconf(SYSCONF_GET_NUMPROCS);
if (nrcpus < 1)
{
- ASSERT("sysconf failed for _SC_NPROCESSORS_ONLN (%d)\n", errno);
+ ASSERT("sysconf failed for %s (%d)\n", SYSCONF_GET_NUMPROCS_NAME, errno);
}
#elif HAVE_SYSCTL
int rc;