Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorgan Brown <morganbr@users.noreply.github.com>2018-06-05 12:35:28 +0300
committerGitHub <noreply@github.com>2018-06-05 12:35:28 +0300
commit9ff16bea4e48e16edf38675b6e79bcb2c011609f (patch)
treeab09aeb319ea8ba593c3d5481b53bd55dc5fdca3 /src/Native
parent0013143136d98f1052cc349761609d91da4e95cc (diff)
Switch back to SC_NPROCESSORS_ONLN for WebAssembly (#5861)
* Switch back to SC_NPROCESSORS_ONLN for WebAssembly because SC_NPROCESSORS_CONF isn't implemented in Emscripten. Fixes an assert on startup.
Diffstat (limited to 'src/Native')
-rw-r--r--src/Native/Runtime/unix/PalRedhawkUnix.cpp17
-rw-r--r--src/Native/gc/unix/gcenv.unix.cpp9
2 files changed, 23 insertions, 3 deletions
diff --git a/src/Native/Runtime/unix/PalRedhawkUnix.cpp b/src/Native/Runtime/unix/PalRedhawkUnix.cpp
index 05847a2bf..d65007052 100644
--- a/src/Native/Runtime/unix/PalRedhawkUnix.cpp
+++ b/src/Native/Runtime/unix/PalRedhawkUnix.cpp
@@ -834,7 +834,14 @@ bool QueryCacheSize()
bool QueryLogicalProcessorCount()
{
#if HAVE_SYSCONF
- g_cLogicalCpus = sysconf(_SC_NPROCESSORS_CONF);
+ int sysConfName;
+#if defined(_WASM_)
+ sysConfName = _SC_NPROCESSORS_ONLN;
+#else
+ sysConfName = _SC_NPROCESSORS_CONF;
+#endif
+
+ g_cLogicalCpus = sysconf(sysConfName);
if (g_cLogicalCpus < 1)
{
ASSERT_UNCONDITIONALLY("sysconf failed for _SC_NPROCESSORS_CONF\n");
@@ -1268,7 +1275,13 @@ bool InitializeSystemInfo()
int nrcpus = 0;
#if HAVE_SYSCONF
- nrcpus = sysconf(_SC_NPROCESSORS_CONF);
+ int sysConfName;
+#if defined(_WASM_)
+ sysConfName = _SC_NPROCESSORS_ONLN;
+#else
+ sysConfName = _SC_NPROCESSORS_CONF;
+#endif
+ nrcpus = sysconf(sysConfName);
if (nrcpus < 1)
{
ASSERT_UNCONDITIONALLY("sysconf failed for _SC_NPROCESSORS_CONF\n");
diff --git a/src/Native/gc/unix/gcenv.unix.cpp b/src/Native/gc/unix/gcenv.unix.cpp
index 56d21ef01..dfddbaba3 100644
--- a/src/Native/gc/unix/gcenv.unix.cpp
+++ b/src/Native/gc/unix/gcenv.unix.cpp
@@ -84,7 +84,14 @@ static pthread_mutex_t g_flushProcessWriteBuffersMutex;
bool GCToOSInterface::Initialize()
{
// Calculate and cache the number of processors on this machine
- int cpuCount = sysconf(_SC_NPROCESSORS_CONF);
+ int sysConfName;
+#if defined(_TARGET_WASM_)
+ sysConfName = _SC_NPROCESSORS_ONLN;
+#else
+ sysConfName = _SC_NPROCESSORS_CONF;
+#endif
+
+ int cpuCount = sysconf(sysConfName);
if (cpuCount == -1)
{
return false;