[PATCH 5/4] ntdll: Read the current processor with the __NR_getcpu syscall
Detlef Riekenberg
wine.dev at web.de
Thu May 17 18:03:31 CDT 2012
I tested sched_getcpu() also, but that is a glibc extension which does not work on 64bit
--
By by ... Detlef
---
dlls/ntdll/thread.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 25f091c..a53136d 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -30,6 +30,9 @@
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
#define NONAMELESSUNION
#include "ntstatus.h"
@@ -1184,6 +1187,16 @@ ULONG WINAPI NtGetCurrentProcessorNumber(void)
{
unsigned processor = 0;
+ /* the syscall is a linux extension, but SYS_getcpu is not defined for 64bit wordsize */
+#if defined(__linux__) && defined(__NR_getcpu)
+ int res;
+
+ res = syscall(__NR_getcpu, &processor, NULL, NULL);
+ if (res != -1)
+ return (ULONG) processor;
+
+#endif
+
if (NtCurrentTeb()->Peb->NumberOfProcessors > 1) {
ULONG_PTR thread_mask;
ULONG_PTR processor_mask;
@@ -1192,6 +1205,7 @@ ULONG WINAPI NtGetCurrentProcessorNumber(void)
status = NtQueryInformationThread(GetCurrentThread(), ThreadAffinityMask, &thread_mask, sizeof(thread_mask), NULL);
if (status == STATUS_SUCCESS)
{
+ processor = 0;
while (processor < (NtCurrentTeb()->Peb->NumberOfProcessors))
{
processor_mask = (1 << processor);
--
1.7.5.4
More information about the wine-patches
mailing list