Alexandre Julliard : ntdll: Fix affinity mask check for 64-bit.

Alexandre Julliard julliard at winehq.org
Fri Apr 9 11:49:54 CDT 2010


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Apr  8 21:16:29 2010 +0200

ntdll: Fix affinity mask check for 64-bit.

---

 dlls/kernel32/tests/thread.c |   12 +++++++++++-
 dlls/ntdll/thread.c          |    2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c
index afa6759..4c4e764 100644
--- a/dlls/kernel32/tests/thread.c
+++ b/dlls/kernel32/tests/thread.c
@@ -814,9 +814,19 @@ static VOID test_thread_processor(void)
    ok(SetThreadAffinityMask(curthread,processMask+1)==0,
       "SetThreadAffinityMask passed for an illegal processor\n");
 /* NOTE: Pre-Vista does not recognize the "all processors" flag (all bits set) */
-   retMask = SetThreadAffinityMask(curthread,~0UL);
+   retMask = SetThreadAffinityMask(curthread,~0);
    ok(broken(retMask==0) || retMask==processMask,
       "SetThreadAffinityMask(thread,-1) failed to request all processors.\n");
+   if (retMask == processMask && sizeof(ULONG_PTR) > sizeof(ULONG))
+   {
+       /* only the low 32-bits matter */
+       retMask = SetThreadAffinityMask(curthread,~(ULONG_PTR)0);
+       ok(retMask == processMask, "SetThreadAffinityMask failed\n");
+       retMask = SetThreadAffinityMask(curthread,~(ULONG_PTR)0 >> 3);
+       ok(retMask == processMask, "SetThreadAffinityMask failed\n");
+       retMask = SetThreadAffinityMask(curthread,~(ULONG_PTR)1);
+       ok(retMask == 0, "SetThreadAffinityMask succeeded\n");
+   }
 /* NOTE: This only works on WinNT/2000/XP) */
    if (pSetThreadIdealProcessor) {
      SetLastError(0xdeadbeef);
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index d632f39..36f1499 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -1138,7 +1138,7 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class,
 
             if (length != sizeof(ULONG_PTR)) return STATUS_INVALID_PARAMETER;
             req_aff = *(const ULONG_PTR *)data;
-            if (req_aff == ~0UL) req_aff = affinity_mask;
+            if ((ULONG)req_aff == ~0u) req_aff = affinity_mask;
             else if (req_aff & ~affinity_mask) return STATUS_INVALID_PARAMETER;
             else if (!req_aff) return STATUS_INVALID_PARAMETER;
             SERVER_START_REQ( set_thread_info )




More information about the wine-cvs mailing list