[PATCH resend 2/3] ntdll: Fill in SYSTEM_CPU_INFORMATION.MaximumCpus
Alex Henrie
alexhenrie24 at gmail.com
Thu Jan 14 18:53:26 CST 2021
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/processor.htm
---
dlls/ntdll/unix/system.c | 29 +++++++++++++++++++++++++++++
include/winternl.h | 2 +-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index a889b2e020c..d34a3229816 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -170,6 +170,31 @@ struct smbios_boot_info
static SYSTEM_CPU_INFORMATION cpu_info;
+static int get_possible_cpus(void)
+{
+ int ret = NtCurrentTeb()->Peb->NumberOfProcessors;
+#ifdef linux
+ FILE *f = fopen("/sys/devices/system/cpu/possible", "r");
+ char line[32];
+ char *value;
+ if (f)
+ {
+ if (fgets(line, sizeof(line), f))
+ {
+ value = strchr(line, '-');
+ if (value)
+ {
+ *value = 0;
+ value++;
+ ret = atoi(value) - atoi(line) + 1;
+ }
+ }
+ fclose(f);
+ }
+#endif
+ return ret;
+}
+
/*******************************************************************************
* Architecture specific feature detection for CPUs
*
@@ -267,6 +292,8 @@ static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info )
info->Architecture = PROCESSOR_ARCHITECTURE_AMD64;
#endif
+ info->MaximumCpus = get_possible_cpus();
+
/* We're at least a 386 */
info->FeatureSet = CPU_FEATURE_VME | CPU_FEATURE_X86 | CPU_FEATURE_PGE;
info->Level = 3;
@@ -415,6 +442,7 @@ static inline void get_cpuinfo( SYSTEM_CPU_INFORMATION *info )
FIXME("CPU Feature detection not implemented.\n");
#endif
info->Architecture = PROCESSOR_ARCHITECTURE_ARM;
+ info->MaximumCpus = get_possible_cpus();
}
#elif defined(__aarch64__)
@@ -463,6 +491,7 @@ static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info )
#endif
info->Level = max(info->Level, 8);
info->Architecture = PROCESSOR_ARCHITECTURE_ARM64;
+ info->MaximumCpus = get_possible_cpus();
}
#endif /* End architecture specific feature detection for CPUs */
diff --git a/include/winternl.h b/include/winternl.h
index a7b0e04aade..4d207f9cd17 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -1691,7 +1691,7 @@ typedef struct _SYSTEM_CPU_INFORMATION {
WORD Architecture;
WORD Level;
WORD Revision; /* combination of CPU model and stepping */
- WORD Reserved; /* always zero */
+ WORD MaximumCpus; /* number of CPUs if as many as possible are hot-added */
DWORD FeatureSet; /* see bit flags below */
} SYSTEM_CPU_INFORMATION, *PSYSTEM_CPU_INFORMATION;
--
2.30.0
More information about the wine-devel
mailing list