Added patch to implement some processor group functions and SetThreadIdealProcessorEx.

This commit is contained in:
Sebastian Lackner 2017-02-05 22:38:32 +01:00
parent f6d52a6a19
commit a12dca03ce
4 changed files with 347 additions and 0 deletions

View File

@ -0,0 +1,186 @@
From ea7ab1f3cb71ed5b80a0c67215b3470465f82f39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 4 Feb 2017 16:20:37 +0100
Subject: kernel32: Implement some processor group functions.
---
.../api-ms-win-core-kernel32-legacy-l1-1-0.spec | 2 +-
dlls/kernel32/cpu.c | 55 ++++++++++++++++++++++
dlls/kernel32/kernel32.spec | 8 ++--
dlls/kernel32/tests/process.c | 23 +++++++++
include/winnt.h | 2 +
5 files changed, 85 insertions(+), 5 deletions(-)
diff --git a/dlls/api-ms-win-core-kernel32-legacy-l1-1-0/api-ms-win-core-kernel32-legacy-l1-1-0.spec b/dlls/api-ms-win-core-kernel32-legacy-l1-1-0/api-ms-win-core-kernel32-legacy-l1-1-0.spec
index 7c196c932fd..4aa415bbf62 100644
--- a/dlls/api-ms-win-core-kernel32-legacy-l1-1-0/api-ms-win-core-kernel32-legacy-l1-1-0.spec
+++ b/dlls/api-ms-win-core-kernel32-legacy-l1-1-0/api-ms-win-core-kernel32-legacy-l1-1-0.spec
@@ -21,7 +21,7 @@
@ stdcall GetComputerNameW(ptr ptr) kernel32.GetComputerNameW
@ stdcall GetConsoleWindow() kernel32.GetConsoleWindow
@ stub GetDurationFormatEx
-@ stub GetMaximumProcessorGroupCount
+@ stdcall GetMaximumProcessorGroupCount() kernel32.GetMaximumProcessorGroupCount
@ stub GetNamedPipeClientProcessId
@ stub GetNamedPipeServerProcessId
@ stdcall GetShortPathNameA(str ptr long) kernel32.GetShortPathNameA
diff --git a/dlls/kernel32/cpu.c b/dlls/kernel32/cpu.c
index 756d8f94ab2..5fb806746a0 100644
--- a/dlls/kernel32/cpu.c
+++ b/dlls/kernel32/cpu.c
@@ -303,3 +303,58 @@ SIZE_T WINAPI GetLargePageMinimum(void)
FIXME("Not implemented on your platform/architecture.\n");
return 0;
}
+
+/***********************************************************************
+ * GetActiveProcessorGroupCount (KERNEL32.@)
+ */
+WORD WINAPI GetActiveProcessorGroupCount(void)
+{
+ TRACE("()\n");
+
+ /* systems with less than 64 logical processors only have group 0 */
+ return 1;
+}
+
+/***********************************************************************
+ * GetMaximumProcessorGroupCount (KERNEL32.@)
+ */
+WORD WINAPI GetMaximumProcessorGroupCount(void)
+{
+ TRACE("()\n");
+
+ /* systems with less than 64 logical processors only have group 0 */
+ return 1;
+}
+
+/***********************************************************************
+ * GetActiveProcessorCount (KERNEL32.@)
+ */
+DWORD WINAPI GetActiveProcessorCount(WORD group)
+{
+ TRACE("(%u)\n", group);
+
+ if (group && group != ALL_PROCESSOR_GROUPS)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ return system_info.NumberOfProcessors;
+}
+
+/***********************************************************************
+ * GetMaximumProcessorCount (KERNEL32.@)
+ */
+DWORD WINAPI GetMaximumProcessorCount(WORD group)
+{
+ TRACE("(%u)\n", group);
+
+ if (group && group != ALL_PROCESSOR_GROUPS)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ /* Wine only counts active processors so far */
+ return system_info.NumberOfProcessors;
+}
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index efb2bdddf32..8348621136f 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -543,8 +543,8 @@
@ stdcall GenerateConsoleCtrlEvent(long long)
@ stdcall -i386 -private Get16DLLAddress(long str) krnl386.exe16.Get16DLLAddress
@ stdcall GetACP()
-# @ stub GetActiveProcessorCount
-# @ stub GetActiveProcessorGroupCount
+@ stdcall GetActiveProcessorCount(long)
+@ stdcall GetActiveProcessorGroupCount()
# @ stub GetApplicationRecoveryCallback
# @ stub GetApplicationRestartSettings
@ stub GetApplicationUserModelId
@@ -724,8 +724,8 @@
# @ stub GetLongPathNameTransactedW
@ stdcall GetLongPathNameW (wstr long long)
@ stdcall GetMailslotInfo(long ptr ptr ptr ptr)
-# @ stub GetMaximumProcessorCount
-# @ stub GetMaximumProcessorGroupCount
+@ stdcall GetMaximumProcessorCount(long)
+@ stdcall GetMaximumProcessorGroupCount()
@ stdcall GetModuleFileNameA(long ptr long)
@ stdcall GetModuleFileNameW(long ptr long)
@ stdcall GetModuleHandleA(str)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index f66ab45b90e..b4370ca8922 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -91,6 +91,7 @@ static SIZE_T (WINAPI *pGetLargePageMinimum)(void);
static BOOL (WINAPI *pInitializeProcThreadAttributeList)(struct _PROC_THREAD_ATTRIBUTE_LIST*, DWORD, DWORD, SIZE_T*);
static BOOL (WINAPI *pUpdateProcThreadAttribute)(struct _PROC_THREAD_ATTRIBUTE_LIST*, DWORD, DWORD_PTR, void *,SIZE_T,void*,SIZE_T*);
static void (WINAPI *pDeleteProcThreadAttributeList)(struct _PROC_THREAD_ATTRIBUTE_LIST*);
+static DWORD (WINAPI *pGetActiveProcessorCount)(WORD);
/* ############################### */
static char base[MAX_PATH];
@@ -258,6 +259,7 @@ static BOOL init(void)
pInitializeProcThreadAttributeList = (void *)GetProcAddress(hkernel32, "InitializeProcThreadAttributeList");
pUpdateProcThreadAttribute = (void *)GetProcAddress(hkernel32, "UpdateProcThreadAttribute");
pDeleteProcThreadAttributeList = (void *)GetProcAddress(hkernel32, "DeleteProcThreadAttributeList");
+ pGetActiveProcessorCount = (void *)GetProcAddress(hkernel32, "GetActiveProcessorCount");
return TRUE;
}
@@ -3351,6 +3353,26 @@ static void test_ProcThreadAttributeList(void)
pDeleteProcThreadAttributeList(&list);
}
+static void test_GetActiveProcessorCount(void)
+{
+ DWORD count;
+
+ if (!pGetActiveProcessorCount)
+ {
+ win_skip("GetActiveProcessorCount not available, skipping test\n");
+ return;
+ }
+
+ count = pGetActiveProcessorCount(0);
+ ok(count, "GetActiveProcessorCount failed, error %u\n", GetLastError());
+
+ /* Test would fail on systems with more than 6400 processors */
+ SetLastError(0xdeadbeef);
+ count = pGetActiveProcessorCount(101);
+ ok(count == 0, "Expeced GetActiveProcessorCount to fail\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+}
+
START_TEST(process)
{
HANDLE job;
@@ -3425,6 +3447,7 @@ START_TEST(process)
test_GetNumaProcessorNode();
test_session_info();
test_GetLogicalProcessorInformationEx();
+ test_GetActiveProcessorCount();
test_largepages();
test_ProcThreadAttributeList();
diff --git a/include/winnt.h b/include/winnt.h
index 9e611c555a4..5cdd8a3a22f 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -5873,6 +5873,8 @@ typedef struct _GROUP_AFFINITY
WORD Reserved[3];
} GROUP_AFFINITY, *PGROUP_AFFINITY;
+#define ALL_PROCESSOR_GROUPS 0xffff
+
typedef struct _PROCESSOR_NUMBER
{
WORD Group;
--
2.11.0

View File

@ -0,0 +1,128 @@
From c4b5a58889e427b710e64566c2c90c4da8806cee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 4 Feb 2017 16:31:59 +0100
Subject: kernel32: Add stub for SetThreadIdealProcessorEx.
---
.../api-ms-win-core-processthreads-l1-1-1.spec | 2 +-
.../api-ms-win-core-processthreads-l1-1-2.spec | 2 +-
dlls/kernel32/kernel32.spec | 2 +-
dlls/kernel32/thread.c | 40 ++++++++++++++++++----
dlls/kernelbase/kernelbase.spec | 2 +-
5 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec b/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec
index 9d321af7240..04329650096 100644
--- a/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec
+++ b/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec
@@ -47,7 +47,7 @@
@ stub SetProcessMitigationPolicy
@ stdcall SetProcessShutdownParameters(long long) kernel32.SetProcessShutdownParameters
@ stdcall SetThreadContext(long ptr) kernel32.SetThreadContext
-@ stub SetThreadIdealProcessorEx
+@ stdcall SetThreadIdealProcessorEx(long ptr ptr) kernel32.SetThreadIdealProcessorEx
@ stdcall SetThreadPriority(long long) kernel32.SetThreadPriority
@ stdcall SetThreadPriorityBoost(long long) kernel32.SetThreadPriorityBoost
@ stdcall SetThreadStackGuarantee(ptr) kernel32.SetThreadStackGuarantee
diff --git a/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec b/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec
index 0e30f18e52d..7a729a50040 100644
--- a/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec
+++ b/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec
@@ -53,7 +53,7 @@
@ stdcall SetProcessPriorityBoost(long long) kernel32.SetProcessPriorityBoost
@ stdcall SetProcessShutdownParameters(long long) kernel32.SetProcessShutdownParameters
@ stdcall SetThreadContext(long ptr) kernel32.SetThreadContext
-@ stub SetThreadIdealProcessorEx
+@ stdcall SetThreadIdealProcessorEx(long ptr ptr) kernel32.SetThreadIdealProcessorEx
@ stub SetThreadInformation
@ stdcall SetThreadPriority(long long) kernel32.SetThreadPriority
@ stdcall SetThreadPriorityBoost(long long) kernel32.SetThreadPriorityBoost
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 8348621136f..75d9e229cc2 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -1476,7 +1476,7 @@
@ stdcall SetThreadExecutionState(long)
@ stdcall SetThreadGroupAffinity(long ptr ptr)
@ stdcall SetThreadIdealProcessor(long long)
-# @ stub SetThreadIdealProcessorEx
+@ stdcall SetThreadIdealProcessorEx(long ptr ptr)
@ stdcall SetThreadLocale(long)
@ stdcall SetThreadPreferredUILanguages(long ptr ptr)
@ stdcall SetThreadPriority(long long)
diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c
index fd4f299acb7..bd699831bdb 100644
--- a/dlls/kernel32/thread.c
+++ b/dlls/kernel32/thread.c
@@ -462,6 +462,28 @@ DWORD_PTR WINAPI SetThreadAffinityMask( HANDLE hThread, DWORD_PTR dwThreadAffini
return tbi.AffinityMask;
}
+/**********************************************************************
+ * SetThreadIdealProcessorEx (KERNEL32.@)
+ */
+BOOL WINAPI SetThreadIdealProcessorEx(HANDLE thread, PROCESSOR_NUMBER *processor, PROCESSOR_NUMBER *previous)
+{
+ FIXME("(%p, %p, %p): stub\n", thread, processor, previous);
+
+ if (!processor || processor->Group > 0 || processor->Number > MAXIMUM_PROCESSORS)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (previous)
+ {
+ previous->Group = 0;
+ previous->Number = 0;
+ previous->Reserved = 0;
+ }
+
+ return TRUE;
+}
/**********************************************************************
* SetThreadIdealProcessor [KERNEL32.@] Sets preferred processor for thread.
@@ -474,15 +496,19 @@ DWORD WINAPI SetThreadIdealProcessor(
HANDLE hThread, /* [in] Specifies the thread of interest */
DWORD dwIdealProcessor) /* [in] Specifies the new preferred processor */
{
- FIXME("(%p): stub\n",hThread);
- if (dwIdealProcessor > MAXIMUM_PROCESSORS)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
+ PROCESSOR_NUMBER previous, current;
+
+ TRACE("(%p, %u)\n", hThread, dwIdealProcessor);
+
+ current.Group = 0;
+ current.Number = dwIdealProcessor;
+ current.Reserved = 0;
+
+ if (!SetThreadIdealProcessorEx(hThread, &current, &previous))
return ~0u;
- }
- return 0;
-}
+ return previous.Number;
+}
/***********************************************************************
* GetThreadSelectorEntry (KERNEL32.@)
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index bdfc067cf6d..db1dbeeb0e1 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -1445,7 +1445,7 @@
@ stdcall SetThreadErrorMode(long ptr) kernel32.SetThreadErrorMode
@ stdcall SetThreadGroupAffinity(long ptr ptr) kernel32.SetThreadGroupAffinity
@ stdcall SetThreadIdealProcessor(long long) kernel32.SetThreadIdealProcessor
-@ stub SetThreadIdealProcessorEx
+@ stdcall SetThreadIdealProcessorEx(long ptr ptr) kernel32.SetThreadIdealProcessorEx
@ stub SetThreadInformation
@ stdcall SetThreadLocale(long) kernel32.SetThreadLocale
@ stdcall SetThreadPreferredUILanguages(long ptr ptr) kernel32.SetThreadPreferredUILanguages
--
2.11.0

View File

@ -0,0 +1,2 @@
Fixes: Implement some processor group functions and SetThreadIdealProcessorEx
Depends: api-ms-win-Stub_DLLs

View File

@ -191,6 +191,7 @@ patch_enable_all ()
enable_kernel32_Named_Pipe="$1"
enable_kernel32_NeedCurrentDirectoryForExePath="$1"
enable_kernel32_PE_Loader_Fixes="$1"
enable_kernel32_Processor_Group="$1"
enable_kernel32_Profile="$1"
enable_kernel32_SCSI_Sysfs="$1"
enable_kernel32_SetFileCompletionNotificationModes="$1"
@ -785,6 +786,9 @@ patch_enable ()
kernel32-PE_Loader_Fixes)
enable_kernel32_PE_Loader_Fixes="$2"
;;
kernel32-Processor_Group)
enable_kernel32_Processor_Group="$2"
;;
kernel32-Profile)
enable_kernel32_Profile="$2"
;;
@ -2278,6 +2282,13 @@ if test "$enable_ntdll_CLI_Images" -eq 1; then
enable_mscoree_CorValidateImage=1
fi
if test "$enable_kernel32_Processor_Group" -eq 1; then
if test "$enable_api_ms_win_Stub_DLLs" -gt 1; then
abort "Patchset api-ms-win-Stub_DLLs disabled, but kernel32-Processor_Group depends on that."
fi
enable_api_ms_win_Stub_DLLs=1
fi
if test "$enable_kernel32_PE_Loader_Fixes" -eq 1; then
if test "$enable_kernel32_Misalign_Workaround" -gt 1; then
abort "Patchset kernel32-Misalign_Workaround disabled, but kernel32-PE_Loader_Fixes depends on that."
@ -4719,6 +4730,26 @@ if test "$enable_kernel32_PE_Loader_Fixes" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-Processor_Group
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * combase-RoApi, kernel32-GetCurrentPackageFamilyName, kernel32-UmsStubs, api-ms-win-Stub_DLLs
# |
# | Modified files:
# | * dlls/api-ms-win-core-kernel32-legacy-l1-1-0/api-ms-win-core-kernel32-legacy-l1-1-0.spec, dlls/api-ms-win-core-
# | processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec, dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-
# | core-processthreads-l1-1-2.spec, dlls/kernel32/cpu.c, dlls/kernel32/kernel32.spec, dlls/kernel32/tests/process.c,
# | dlls/kernel32/thread.c, dlls/kernelbase/kernelbase.spec, include/winnt.h
# |
if test "$enable_kernel32_Processor_Group" -eq 1; then
patch_apply kernel32-Processor_Group/0001-kernel32-Implement-some-processor-group-functions.patch
patch_apply kernel32-Processor_Group/0002-kernel32-Add-stub-for-SetThreadIdealProcessorEx.patch
(
printf '%s\n' '+ { "Michael Müller", "kernel32: Implement some processor group functions.", 1 },';
printf '%s\n' '+ { "Michael Müller", "kernel32: Add stub for SetThreadIdealProcessorEx.", 1 },';
) >> "$patchlist"
fi
# Patchset kernel32-Profile
# |
# | This patchset fixes the following Wine bugs: