summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pal/inc/pal.h5
-rw-r--r--src/pal/src/misc/sysinfo.cpp13
-rw-r--r--src/vm/util.cpp6
3 files changed, 21 insertions, 3 deletions
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index 8516ce95c9..a92f3b4f13 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -3029,6 +3029,11 @@ void *
PALAPI
PAL_GetStackLimit();
+PALIMPORT
+DWORD
+PALAPI
+PAL_GetLogicalCpuCountFromOS();
+
#ifdef PLATFORM_UNIX
#if defined(__FreeBSD__) && defined(_X86_)
diff --git a/src/pal/src/misc/sysinfo.cpp b/src/pal/src/misc/sysinfo.cpp
index a7f47735a1..9bd442f490 100644
--- a/src/pal/src/misc/sysinfo.cpp
+++ b/src/pal/src/misc/sysinfo.cpp
@@ -298,4 +298,17 @@ GetCurrentProcessorNumber()
return 0;
}
+DWORD
+PALAPI
+PAL_GetLogicalCpuCountFromOS()
+{
+ DWORD numLogicalCores = 0;
+
+#if HAVE_SYSCONF
+ numLogicalCores = sysconf(_SC_NPROCESSORS_ONLN);
+#endif
+
+ return numLogicalCores;
+}
+
#endif // defined(_AMD64_)
diff --git a/src/vm/util.cpp b/src/vm/util.cpp
index 6fd3cc2b34..f9f8718a22 100644
--- a/src/vm/util.cpp
+++ b/src/vm/util.cpp
@@ -1948,8 +1948,9 @@ DWORD GetLogicalCpuCountFromOS()
static DWORD val = 0;
DWORD retVal = 0;
-// UNIXTODO: Implement the functionality in PAL?
-#ifndef FEATURE_PAL
+#ifdef FEATURE_PAL
+ retVal = PAL_GetLogicalCpuCountFromOS();
+#else // FEATURE_PAL
DWORD nEntries = 0;
@@ -2020,7 +2021,6 @@ lDone:
{
delete[] pslpi; // release the memory allocated for the SLPI array
}
-
#endif // FEATURE_PAL
return retVal;