mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 20:39:33 +08:00
* 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:
parent
6cfbf1a573
commit
c29e693388
@ -1,3 +1,19 @@
|
|||||||
|
2011-05-10 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2011-05-10 Corinna Vinschen <corinna@vinschen.de>
|
2011-05-10 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* environ.cc (set_chunksize): Remove.
|
* environ.cc (set_chunksize): Remove.
|
||||||
|
@ -480,9 +480,6 @@ format_proc_uptime (void *, char *&destbuf)
|
|||||||
PSYSTEM_PERFORMANCE_INFORMATION spi = (PSYSTEM_PERFORMANCE_INFORMATION)
|
PSYSTEM_PERFORMANCE_INFORMATION spi = (PSYSTEM_PERFORMANCE_INFORMATION)
|
||||||
alloca (sizeof_spi);
|
alloca (sizeof_spi);
|
||||||
|
|
||||||
if (!system_info.dwNumberOfProcessors)
|
|
||||||
GetSystemInfo (&system_info);
|
|
||||||
|
|
||||||
ret = NtQuerySystemInformation (SystemTimeOfDayInformation, &stodi,
|
ret = NtQuerySystemInformation (SystemTimeOfDayInformation, &stodi,
|
||||||
sizeof stodi, NULL);
|
sizeof stodi, NULL);
|
||||||
if (NT_SUCCESS (ret))
|
if (NT_SUCCESS (ret))
|
||||||
@ -493,7 +490,7 @@ format_proc_uptime (void *, char *&destbuf)
|
|||||||
|
|
||||||
if (NT_SUCCESS (NtQuerySystemInformation (SystemPerformanceInformation,
|
if (NT_SUCCESS (NtQuerySystemInformation (SystemPerformanceInformation,
|
||||||
spi, sizeof_spi, NULL)))
|
spi, sizeof_spi, NULL)))
|
||||||
idle_time = (spi->IdleTime.QuadPart / system_info.dwNumberOfProcessors)
|
idle_time = (spi->IdleTime.QuadPart / wincap.cpu_count ())
|
||||||
/ 100000ULL;
|
/ 100000ULL;
|
||||||
|
|
||||||
destbuf = (char *) crealloc_abort (destbuf, 80);
|
destbuf = (char *) crealloc_abort (destbuf, 80);
|
||||||
@ -522,19 +519,16 @@ format_proc_stat (void *, char *&destbuf)
|
|||||||
char *buf = tp.c_get ();
|
char *buf = tp.c_get ();
|
||||||
char *eobuf = buf;
|
char *eobuf = buf;
|
||||||
|
|
||||||
if (!system_info.dwNumberOfProcessors)
|
SYSTEM_PROCESSOR_TIMES spt[wincap.cpu_count ()];
|
||||||
GetSystemInfo (&system_info);
|
|
||||||
|
|
||||||
SYSTEM_PROCESSOR_TIMES spt[system_info.dwNumberOfProcessors];
|
|
||||||
ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
|
ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
|
||||||
sizeof spt[0] * system_info.dwNumberOfProcessors, NULL);
|
sizeof spt[0] * wincap.cpu_count (), NULL);
|
||||||
if (!NT_SUCCESS (ret))
|
if (!NT_SUCCESS (ret))
|
||||||
debug_printf ("NtQuerySystemInformation(SystemProcessorTimes), "
|
debug_printf ("NtQuerySystemInformation(SystemProcessorTimes), "
|
||||||
"status %p", ret);
|
"status %p", ret);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
|
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)
|
kernel_time += (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart)
|
||||||
* HZ / 10000000ULL;
|
* HZ / 10000000ULL;
|
||||||
@ -545,7 +539,7 @@ format_proc_stat (void *, char *&destbuf)
|
|||||||
eobuf += __small_sprintf (eobuf, "cpu %U %U %U %U\n",
|
eobuf += __small_sprintf (eobuf, "cpu %U %U %U %U\n",
|
||||||
user_time, 0ULL, kernel_time, idle_time);
|
user_time, 0ULL, kernel_time, idle_time);
|
||||||
user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
|
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;
|
interrupt_count += spt[i].InterruptCount;
|
||||||
kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL;
|
kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL;
|
||||||
|
@ -48,8 +48,6 @@ enum exit_states
|
|||||||
|
|
||||||
exit_states NO_COPY exit_state;
|
exit_states NO_COPY exit_state;
|
||||||
|
|
||||||
SYSTEM_INFO system_info;
|
|
||||||
|
|
||||||
/* Set in init.cc. Used to check if Cygwin DLL is dynamically loaded. */
|
/* Set in init.cc. Used to check if Cygwin DLL is dynamically loaded. */
|
||||||
int NO_COPY dynamically_loaded;
|
int NO_COPY dynamically_loaded;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* heap.cc: Cygwin heap manager.
|
/* heap.cc: Cygwin heap manager.
|
||||||
|
|
||||||
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||||
|
2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
|
||||||
|
|
||||||
This file is part of Cygwin.
|
This file is part of Cygwin.
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ heap_init ()
|
|||||||
/* If we're the forkee, we must allocate the heap at exactly the same place
|
/* If we're the forkee, we must allocate the heap at exactly the same place
|
||||||
as our parent. If not, we don't care where it ends up. */
|
as our parent. If not, we don't care where it ends up. */
|
||||||
|
|
||||||
page_const = system_info.dwPageSize;
|
page_const = wincap.page_size ();
|
||||||
if (!cygheap->user_heap.base)
|
if (!cygheap->user_heap.base)
|
||||||
{
|
{
|
||||||
cygheap->user_heap.chunk = cygwin_shared->heap_chunk_size ();
|
cygheap->user_heap.chunk = cygwin_shared->heap_chunk_size ();
|
||||||
|
@ -2287,17 +2287,13 @@ getdtablesize ()
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
getpagesize ()
|
getpagesize ()
|
||||||
{
|
{
|
||||||
if (!system_info.dwAllocationGranularity)
|
return (size_t) wincap.allocation_granularity ();
|
||||||
GetSystemInfo (&system_info);
|
|
||||||
return (size_t) system_info.dwAllocationGranularity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
getsystempagesize ()
|
getsystempagesize ()
|
||||||
{
|
{
|
||||||
if (!system_info.dwPageSize)
|
return (size_t) wincap.page_size ();
|
||||||
GetSystemInfo (&system_info);
|
|
||||||
return (size_t) system_info.dwPageSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: not all values are correct... */
|
/* FIXME: not all values are correct... */
|
||||||
|
@ -181,7 +181,7 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
|||||||
wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
heapslop:0x4,
|
heapslop:0x4,
|
||||||
max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
|
max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
|
||||||
is_server:true,
|
is_server:false,
|
||||||
has_physical_mem_access:false,
|
has_physical_mem_access:false,
|
||||||
has_create_global_privilege:true,
|
has_create_global_privilege:true,
|
||||||
has_ioctl_storage_get_media_types_ex:true,
|
has_ioctl_storage_get_media_types_ex:true,
|
||||||
@ -279,6 +279,7 @@ wincapc::init ()
|
|||||||
if (caps)
|
if (caps)
|
||||||
return; // already initialized
|
return; // already initialized
|
||||||
|
|
||||||
|
GetSystemInfo (&system_info);
|
||||||
memset (&version, 0, sizeof version);
|
memset (&version, 0, sizeof version);
|
||||||
version.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
version.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
||||||
if (!GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version)))
|
if (!GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version)))
|
||||||
@ -347,8 +348,7 @@ wincapc::init ()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version.wProductType != VER_NT_WORKSTATION)
|
((wincaps *)caps)->is_server = (version.wProductType != VER_NT_WORKSTATION);
|
||||||
((wincaps *)caps)->is_server = true;
|
|
||||||
if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
|
if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
|
||||||
ProcessWow64Information,
|
ProcessWow64Information,
|
||||||
&wow64, sizeof wow64, NULL))
|
&wow64, sizeof wow64, NULL))
|
||||||
|
@ -46,6 +46,7 @@ struct wincaps
|
|||||||
|
|
||||||
class wincapc
|
class wincapc
|
||||||
{
|
{
|
||||||
|
SYSTEM_INFO system_info;
|
||||||
OSVERSIONINFOEX version;
|
OSVERSIONINFOEX version;
|
||||||
char osnam[40];
|
char osnam[40];
|
||||||
ULONG wow64;
|
ULONG wow64;
|
||||||
@ -54,6 +55,10 @@ class wincapc
|
|||||||
public:
|
public:
|
||||||
void init ();
|
void init ();
|
||||||
|
|
||||||
|
const DWORD cpu_count () const { return system_info.dwNumberOfProcessors; }
|
||||||
|
const DWORD page_size () const { return system_info.dwPageSize; }
|
||||||
|
const DWORD allocation_granularity () const
|
||||||
|
{ return system_info.dwAllocationGranularity; }
|
||||||
const char *osname () const { return osnam; }
|
const char *osname () const { return osnam; }
|
||||||
const bool is_wow64 () const { return wow64; }
|
const bool is_wow64 () const { return wow64; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user