summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pal/inc/pal.h12
-rw-r--r--src/pal/src/config.h.in1
-rw-r--r--src/pal/src/configure.cmake13
-rw-r--r--src/pal/src/misc/sysinfo.cpp15
4 files changed, 39 insertions, 2 deletions
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index aa51b1959b..294502b73b 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -5613,6 +5613,18 @@ PALIMPORT
DWORD
PALAPI
GetCurrentProcessorNumber();
+
+/*++
+Function:
+PAL_HasGetCurrentProcessorNumber
+
+Checks if GetCurrentProcessorNumber is available in the current environment
+
+--*/
+PALIMPORT
+BOOL
+PALAPI
+PAL_HasGetCurrentProcessorNumber();
#define FORMAT_MESSAGE_ALLOCATE_BUFFER 0x00000100
#define FORMAT_MESSAGE_IGNORE_INSERTS 0x00000200
diff --git a/src/pal/src/config.h.in b/src/pal/src/config.h.in
index 6760d25bc5..f3274076e8 100644
--- a/src/pal/src/config.h.in
+++ b/src/pal/src/config.h.in
@@ -80,6 +80,7 @@
#cmakedefine01 HAVE_BROKEN_FIFO_KEVENT
#cmakedefine01 HAS_FTRUNCATE_LENGTH_ISSUE
#cmakedefine01 HAVE_SCHED_GET_PRIORITY
+#cmakedefine01 HAVE_SCHED_GETCPU
#cmakedefine01 HAVE_WORKING_GETTIMEOFDAY
#cmakedefine01 HAVE_WORKING_CLOCK_GETTIME
#cmakedefine01 HAVE_CLOCK_MONOTONIC
diff --git a/src/pal/src/configure.cmake b/src/pal/src/configure.cmake
index 8e6b7251c7..4b09fc0492 100644
--- a/src/pal/src/configure.cmake
+++ b/src/pal/src/configure.cmake
@@ -290,6 +290,19 @@ int main(void)
exit(-1 == max_priority || -1 == min_priority);
}" HAVE_SCHED_GET_PRIORITY)
+set(CMAKE_REQUIRED_LIBRARIES pthread)
+check_cxx_source_runs("
+#include <stdlib.h>
+#include <sched.h>
+
+int main(void)
+{
+ if (sched_getcpu() >= 0)
+ {
+ exit(0);
+ }
+ exit(1);
+}" HAVE_SCHED_GETCPU)
set(CMAKE_REQUIRED_LIBRARIES)
check_cxx_source_runs("
#include <stdlib.h>
diff --git a/src/pal/src/misc/sysinfo.cpp b/src/pal/src/misc/sysinfo.cpp
index 5bb13bd90f..f444e8c131 100644
--- a/src/pal/src/misc/sysinfo.cpp
+++ b/src/pal/src/misc/sysinfo.cpp
@@ -23,6 +23,7 @@ Revision History:
#include "pal/palinternal.h"
+#include <sched.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
@@ -308,8 +309,18 @@ DWORD
PALAPI
GetCurrentProcessorNumber()
{
- // TODO: implement this
- return 0;
+#if HAVE_SCHED_GETCPU
+ return sched_getcpu();
+#else //HAVE_SCHED_GETCPU
+ return -1;
+#endif //HAVE_SCHED_GETCPU
+}
+
+BOOL
+PALAPI
+PAL_HasGetCurrentProcessorNumber()
+{
+ return HAVE_SCHED_GETCPU;
}
DWORD