diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-05-10 15:39:02 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-05-10 15:39:02 +0000 |
commit | c29e693388663aaa42f041965258fa6b6bafc938 (patch) | |
tree | ab06a3773afd17d0f5c68cfa860817406fa5b670 /winsup/cygwin/fhandler_proc.cc | |
parent | 6cfbf1a573bb6fe2d0d986eeaaa0992bd9e0c176 (diff) | |
download | cygnal-c29e693388663aaa42f041965258fa6b6bafc938.tar.gz cygnal-c29e693388663aaa42f041965258fa6b6bafc938.tar.bz2 cygnal-c29e693388663aaa42f041965258fa6b6bafc938.zip |
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler_proc.cc')
-rw-r--r-- | winsup/cygwin/fhandler_proc.cc | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index dd02f80f2..bf87a4f7c 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -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; |