* fhandler_proc.cc (format_proc_uptime): Don't call GetSystemInfo.
Fetch CPU count from wincap. (format_proc_stat): Ditto. * globals.cc (system_info): Move to wincap. * heap.cc (heap_init): Fetch page size from wincap. * syscalls.cc (getpagesize): Fetch allocation granularity from wincap. (getsystempagesize): Fetch page size from wincap. * wincap.cc (wincap_2003): Default is_server to false. (wincapc::init): Call GetSystemInfo here. Always set is_server value. * wincap.h (class wincapc): Add system_info as private member. (wincapc::cpu_count): New public method. (wincapc::page_size): Ditto. (wincapc::allocation_granularity): Ditto.
This commit is contained in:
@ -480,9 +480,6 @@ format_proc_uptime (void *, char *&destbuf)
|
||||
PSYSTEM_PERFORMANCE_INFORMATION spi = (PSYSTEM_PERFORMANCE_INFORMATION)
|
||||
alloca (sizeof_spi);
|
||||
|
||||
if (!system_info.dwNumberOfProcessors)
|
||||
GetSystemInfo (&system_info);
|
||||
|
||||
ret = NtQuerySystemInformation (SystemTimeOfDayInformation, &stodi,
|
||||
sizeof stodi, NULL);
|
||||
if (NT_SUCCESS (ret))
|
||||
@ -493,7 +490,7 @@ format_proc_uptime (void *, char *&destbuf)
|
||||
|
||||
if (NT_SUCCESS (NtQuerySystemInformation (SystemPerformanceInformation,
|
||||
spi, sizeof_spi, NULL)))
|
||||
idle_time = (spi->IdleTime.QuadPart / system_info.dwNumberOfProcessors)
|
||||
idle_time = (spi->IdleTime.QuadPart / wincap.cpu_count ())
|
||||
/ 100000ULL;
|
||||
|
||||
destbuf = (char *) crealloc_abort (destbuf, 80);
|
||||
@ -522,19 +519,16 @@ format_proc_stat (void *, char *&destbuf)
|
||||
char *buf = tp.c_get ();
|
||||
char *eobuf = buf;
|
||||
|
||||
if (!system_info.dwNumberOfProcessors)
|
||||
GetSystemInfo (&system_info);
|
||||
|
||||
SYSTEM_PROCESSOR_TIMES spt[system_info.dwNumberOfProcessors];
|
||||
SYSTEM_PROCESSOR_TIMES spt[wincap.cpu_count ()];
|
||||
ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
|
||||
sizeof spt[0] * system_info.dwNumberOfProcessors, NULL);
|
||||
sizeof spt[0] * wincap.cpu_count (), NULL);
|
||||
if (!NT_SUCCESS (ret))
|
||||
debug_printf ("NtQuerySystemInformation(SystemProcessorTimes), "
|
||||
"status %p", ret);
|
||||
else
|
||||
{
|
||||
unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
|
||||
for (unsigned long i = 0; i < system_info.dwNumberOfProcessors; i++)
|
||||
for (unsigned long i = 0; i < wincap.cpu_count (); i++)
|
||||
{
|
||||
kernel_time += (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart)
|
||||
* HZ / 10000000ULL;
|
||||
@ -545,7 +539,7 @@ format_proc_stat (void *, char *&destbuf)
|
||||
eobuf += __small_sprintf (eobuf, "cpu %U %U %U %U\n",
|
||||
user_time, 0ULL, kernel_time, idle_time);
|
||||
user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
|
||||
for (unsigned long i = 0; i < system_info.dwNumberOfProcessors; i++)
|
||||
for (unsigned long i = 0; i < wincap.cpu_count (); i++)
|
||||
{
|
||||
interrupt_count += spt[i].InterruptCount;
|
||||
kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL;
|
||||
|
Reference in New Issue
Block a user