Detlef Riekenberg : ntdll: Use ThreadAffinityMask for NtGetCurrentProcessorNumber.

Alexandre Julliard julliard at winehq.org
Mon May 21 15:31:07 CDT 2012


Module: wine
Branch: master
Commit: 1f80bacc659ef3472f6baf6c1bd535b48e456592
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1f80bacc659ef3472f6baf6c1bd535b48e456592

Author: Detlef Riekenberg <wine.dev at 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 */




More information about the wine-cvs mailing list