[PATCH 3/4] ntdll: Use ThreadAffinityMask for NtGetCurrentProcessorNumber
Detlef Riekenberg
wine.dev at web.de
Thu May 17 12:28:33 CDT 2012
The first valid of all possible processors is returned.
This is only a fallback,
when the thread is allowed to run on more than one processor.
--
By by ... Detlef
---
dlls/ntdll/thread.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 282e86a..25f091c 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -1182,9 +1182,28 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class,
*/
ULONG WINAPI NtGetCurrentProcessorNumber(void)
{
+ unsigned processor = 0;
if (NtCurrentTeb()->Peb->NumberOfProcessors > 1) {
- FIXME("need multicore support (%d processors)\n", NtCurrentTeb()->Peb->NumberOfProcessors);
+ ULONG_PTR thread_mask;
+ ULONG_PTR processor_mask;
+ NTSTATUS status;
+
+ status = NtQueryInformationThread(GetCurrentThread(), ThreadAffinityMask, &thread_mask, sizeof(thread_mask), NULL);
+ if (status == STATUS_SUCCESS)
+ {
+ while (processor < (NtCurrentTeb()->Peb->NumberOfProcessors))
+ {
+ processor_mask = (1 << processor);
+ if (thread_mask & processor_mask) {
+ if (thread_mask != processor_mask)
+ FIXME("need multicore support (%d processors)\n", NtCurrentTeb()->Peb->NumberOfProcessors);
+
+ return processor;
+ }
+ processor++;
+ }
+ }
}
/* fallback to the first processor */
--
1.7.5.4
More information about the wine-patches
mailing list