Module: wine Branch: master Commit: 1f80bacc659ef3472f6baf6c1bd535b48e456592 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1f80bacc659ef3472f6baf6c1b...
Author: Detlef Riekenberg wine.dev@web.de Date: Thu May 17 19:28:33 2012 +0200
ntdll: Use ThreadAffinityMask for NtGetCurrentProcessorNumber.
---
dlls/ntdll/thread.c | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index a0d414a..b34e279 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -1182,9 +1182,29 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class, */ ULONG WINAPI NtGetCurrentProcessorNumber(void) { + ULONG processor;
- if (NtCurrentTeb()->Peb->NumberOfProcessors > 1) { - FIXME("need multicore support (%d processors)\n", NtCurrentTeb()->Peb->NumberOfProcessors); + if (NtCurrentTeb()->Peb->NumberOfProcessors > 1) + { + ULONG_PTR thread_mask, processor_mask; + NTSTATUS status; + + status = NtQueryInformationThread(GetCurrentThread(), ThreadAffinityMask, + &thread_mask, sizeof(thread_mask), NULL); + if (status == STATUS_SUCCESS) + { + for (processor = 0; processor < NtCurrentTeb()->Peb->NumberOfProcessors; processor++) + { + 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; + } + } + } }
/* fallback to the first processor */