[PATCH] kernel32: Implement GetMaximumProcessorCount
Alex Henrie
alexhenrie24 at gmail.com
Sun Nov 11 21:52:54 CST 2018
From: Michael Müller <michael at fds-team.de>
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45961
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
https://github.com/wine-staging/wine-staging/blob/master/patches/kernel32-Processor_Group/0001-kernel32-Implement-some-processor-group-functions.patch
---
dlls/kernel32/cpu.c | 17 +++++++++++++++++
dlls/kernel32/kernel32.spec | 2 +-
dlls/kernel32/tests/process.c | 23 +++++++++++++++++++++++
include/winnt.h | 2 ++
4 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/cpu.c b/dlls/kernel32/cpu.c
index 1e99951993..452f3789c0 100644
--- a/dlls/kernel32/cpu.c
+++ b/dlls/kernel32/cpu.c
@@ -328,6 +328,23 @@ DWORD WINAPI GetActiveProcessorCount(WORD group)
return cpus;
}
+/***********************************************************************
+ * 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;
+}
+
/***********************************************************************
* GetEnabledXStateFeatures (KERNEL32.@)
*/
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 74af2a4570..c370a068c2 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -718,7 +718,7 @@
# @ stub GetLongPathNameTransactedW
@ stdcall GetLongPathNameW (wstr long long)
@ stdcall GetMailslotInfo(long ptr ptr ptr ptr)
-# @ stub GetMaximumProcessorCount
+@ stdcall GetMaximumProcessorCount(long)
# @ stub GetMaximumProcessorGroupCount
@ stdcall GetModuleFileNameA(long ptr long)
@ stdcall GetModuleFileNameW(long ptr long)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index 9f99720f32..850495bff7 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;
}
@@ -3655,6 +3657,26 @@ static void test_GetLogicalProcessorInformationEx(void)
HeapFree(GetProcessHeap(), 0, info);
}
+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());
+}
+
static void test_largepages(void)
{
SIZE_T size;
@@ -3868,6 +3890,7 @@ START_TEST(process)
test_GetNumaProcessorNode();
test_session_info();
test_GetLogicalProcessorInformationEx();
+ test_GetActiveProcessorCount();
test_largepages();
test_ProcThreadAttributeList();
test_SuspendProcessState();
diff --git a/include/winnt.h b/include/winnt.h
index b8a630e6d3..d801de9df9 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -6089,6 +6089,8 @@ typedef struct _GROUP_AFFINITY
WORD Reserved[3];
} GROUP_AFFINITY, *PGROUP_AFFINITY;
+#define ALL_PROCESSOR_GROUPS 0xffff
+
typedef struct _PROCESSOR_NUMBER
{
WORD Group;
--
2.19.1
More information about the wine-devel
mailing list