ntoskrnl.exe: Add KeSetSystemAffinityThreadEx() function.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
25f4da665d
commit
c3bc7689b1
|
@ -2455,6 +2455,25 @@ VOID WINAPI KeSetSystemAffinityThread(KAFFINITY Affinity)
|
||||||
FIXME("(%lx) stub\n", Affinity);
|
FIXME("(%lx) stub\n", Affinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KAFFINITY WINAPI KeSetSystemAffinityThreadEx(KAFFINITY affinity)
|
||||||
|
{
|
||||||
|
DWORD_PTR system_affinity = KeQueryActiveProcessors();
|
||||||
|
GROUP_AFFINITY old, new;
|
||||||
|
|
||||||
|
TRACE("affinity %#lx.\n", affinity);
|
||||||
|
|
||||||
|
affinity &= system_affinity;
|
||||||
|
|
||||||
|
NtQueryInformationThread(GetCurrentThread(), ThreadGroupInformation,
|
||||||
|
&old, sizeof(old), NULL);
|
||||||
|
|
||||||
|
memset(&new, 0, sizeof(new));
|
||||||
|
new.Mask = affinity;
|
||||||
|
|
||||||
|
return NtSetInformationThread(GetCurrentThread(), ThreadGroupInformation, &new, sizeof(new))
|
||||||
|
? 0 : old.Mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* KeRevertToUserAffinityThread (NTOSKRNL.EXE.@)
|
* KeRevertToUserAffinityThread (NTOSKRNL.EXE.@)
|
||||||
|
|
|
@ -634,6 +634,7 @@
|
||||||
@ stdcall KeSetPriorityThread(ptr long)
|
@ stdcall KeSetPriorityThread(ptr long)
|
||||||
@ stub KeSetProfileIrql
|
@ stub KeSetProfileIrql
|
||||||
@ stdcall KeSetSystemAffinityThread(long)
|
@ stdcall KeSetSystemAffinityThread(long)
|
||||||
|
@ stdcall KeSetSystemAffinityThreadEx(long)
|
||||||
@ stdcall KeSetTargetProcessorDpc(ptr long)
|
@ stdcall KeSetTargetProcessorDpc(ptr long)
|
||||||
@ stub KeSetTimeIncrement
|
@ stub KeSetTimeIncrement
|
||||||
@ stub KeSetTimer
|
@ stub KeSetTimer
|
||||||
|
|
|
@ -1712,10 +1712,11 @@ static void test_executable_pool(void)
|
||||||
|
|
||||||
static void test_affinity(void)
|
static void test_affinity(void)
|
||||||
{
|
{
|
||||||
|
KAFFINITY (WINAPI *pKeSetSystemAffinityThreadEx)(KAFFINITY affinity);
|
||||||
ULONG (WINAPI *pKeQueryActiveProcessorCountEx)(USHORT);
|
ULONG (WINAPI *pKeQueryActiveProcessorCountEx)(USHORT);
|
||||||
KAFFINITY (WINAPI *pKeQueryActiveProcessors)(void);
|
KAFFINITY (WINAPI *pKeQueryActiveProcessors)(void);
|
||||||
|
KAFFINITY mask, mask_all_cpus;
|
||||||
ULONG cpu_count, count;
|
ULONG cpu_count, count;
|
||||||
KAFFINITY mask;
|
|
||||||
|
|
||||||
pKeQueryActiveProcessorCountEx = get_proc_address("KeQueryActiveProcessorCountEx");
|
pKeQueryActiveProcessorCountEx = get_proc_address("KeQueryActiveProcessorCountEx");
|
||||||
if (!pKeQueryActiveProcessorCountEx)
|
if (!pKeQueryActiveProcessorCountEx)
|
||||||
|
@ -1727,6 +1728,9 @@ static void test_affinity(void)
|
||||||
pKeQueryActiveProcessors = get_proc_address("KeQueryActiveProcessors");
|
pKeQueryActiveProcessors = get_proc_address("KeQueryActiveProcessors");
|
||||||
ok(!!pKeQueryActiveProcessors, "KeQueryActiveProcessors is not available.\n");
|
ok(!!pKeQueryActiveProcessors, "KeQueryActiveProcessors is not available.\n");
|
||||||
|
|
||||||
|
pKeSetSystemAffinityThreadEx = get_proc_address("KeSetSystemAffinityThreadEx");
|
||||||
|
ok(!!pKeSetSystemAffinityThreadEx, "KeSetSystemAffinityThreadEx is not available.\n");
|
||||||
|
|
||||||
count = pKeQueryActiveProcessorCountEx(1);
|
count = pKeQueryActiveProcessorCountEx(1);
|
||||||
todo_wine ok(!count, "Got unexpected count %u.\n", count);
|
todo_wine ok(!count, "Got unexpected count %u.\n", count);
|
||||||
|
|
||||||
|
@ -1736,8 +1740,19 @@ static void test_affinity(void)
|
||||||
count = pKeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS);
|
count = pKeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS);
|
||||||
ok(count == cpu_count, "Got unexpected count %u.\n", count);
|
ok(count == cpu_count, "Got unexpected count %u.\n", count);
|
||||||
|
|
||||||
|
mask_all_cpus = ~((~0u) << cpu_count);
|
||||||
|
|
||||||
mask = pKeQueryActiveProcessors();
|
mask = pKeQueryActiveProcessors();
|
||||||
ok(mask == ~((~0u) << cpu_count), "Got unexpected mask %#lx.\n", mask);
|
ok(mask == mask_all_cpus, "Got unexpected mask %#lx.\n", mask);
|
||||||
|
|
||||||
|
mask = pKeSetSystemAffinityThreadEx(0);
|
||||||
|
ok(!mask, "Got unexpected mask %#lx.\n", mask);
|
||||||
|
|
||||||
|
mask = pKeSetSystemAffinityThreadEx(0x1);
|
||||||
|
ok(mask == mask_all_cpus, "Got unexpected mask %#lx.\n", mask);
|
||||||
|
|
||||||
|
mask = pKeSetSystemAffinityThreadEx(~(KAFFINITY)0);
|
||||||
|
ok(mask == 0x1, "Got unexpected mask %#lx.\n", mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack)
|
static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack)
|
||||||
|
|
|
@ -1709,6 +1709,7 @@ void WINAPI KeRevertToUserAffinityThread(void);
|
||||||
LONG WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN);
|
LONG WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN);
|
||||||
KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
|
KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
|
||||||
void WINAPI KeSetSystemAffinityThread(KAFFINITY);
|
void WINAPI KeSetSystemAffinityThread(KAFFINITY);
|
||||||
|
KAFFINITY WINAPI KeSetSystemAffinityThreadEx(KAFFINITY affinity);
|
||||||
BOOLEAN WINAPI KeSetTimerEx(KTIMER*,LARGE_INTEGER,LONG,KDPC*);
|
BOOLEAN WINAPI KeSetTimerEx(KTIMER*,LARGE_INTEGER,LONG,KDPC*);
|
||||||
NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG,void*[],WAIT_TYPE,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*,KWAIT_BLOCK*);
|
NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG,void*[],WAIT_TYPE,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*,KWAIT_BLOCK*);
|
||||||
NTSTATUS WINAPI KeWaitForSingleObject(void*,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
|
NTSTATUS WINAPI KeWaitForSingleObject(void*,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
|
||||||
|
|
Loading…
Reference in New Issue