Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog16
-rw-r--r--winsup/cygwin/fhandler_proc.cc16
-rw-r--r--winsup/cygwin/globals.cc2
-rw-r--r--winsup/cygwin/heap.cc5
-rw-r--r--winsup/cygwin/syscalls.cc8
-rw-r--r--winsup/cygwin/wincap.cc6
-rw-r--r--winsup/cygwin/wincap.h5
7 files changed, 34 insertions, 24 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index fb4018a11..6e3f2fbd6 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,21 @@
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>
+
* environ.cc (set_chunksize): Remove.
(parse_thing): Remove forkchunk entry.
* fork.cc (child_copy): Drop handling external chunksize setting.
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;
diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc
index 94823d7cf..f27429c6b 100644
--- a/winsup/cygwin/globals.cc
+++ b/winsup/cygwin/globals.cc
@@ -48,8 +48,6 @@ enum exit_states
exit_states NO_COPY exit_state;
-SYSTEM_INFO system_info;
-
/* Set in init.cc. Used to check if Cygwin DLL is dynamically loaded. */
int NO_COPY dynamically_loaded;
diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc
index be4946d25..21516d5c9 100644
--- a/winsup/cygwin/heap.cc
+++ b/winsup/cygwin/heap.cc
@@ -1,6 +1,7 @@
/* 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.
@@ -31,7 +32,7 @@ heap_init ()
/* 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. */
- page_const = system_info.dwPageSize;
+ page_const = wincap.page_size ();
if (!cygheap->user_heap.base)
{
cygheap->user_heap.chunk = cygwin_shared->heap_chunk_size ();
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 70eb8ea1f..14561cdba 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2287,17 +2287,13 @@ getdtablesize ()
extern "C" int
getpagesize ()
{
- if (!system_info.dwAllocationGranularity)
- GetSystemInfo (&system_info);
- return (size_t) system_info.dwAllocationGranularity;
+ return (size_t) wincap.allocation_granularity ();
}
size_t
getsystempagesize ()
{
- if (!system_info.dwPageSize)
- GetSystemInfo (&system_info);
- return (size_t) system_info.dwPageSize;
+ return (size_t) wincap.page_size ();
}
/* FIXME: not all values are correct... */
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index b36bc0876..aac916ba4 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -181,7 +181,7 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
heapslop:0x4,
max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
- is_server:true,
+ is_server:false,
has_physical_mem_access:false,
has_create_global_privilege:true,
has_ioctl_storage_get_media_types_ex:true,
@@ -279,6 +279,7 @@ wincapc::init ()
if (caps)
return; // already initialized
+ GetSystemInfo (&system_info);
memset (&version, 0, sizeof version);
version.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
if (!GetVersionEx (reinterpret_cast<LPOSVERSIONINFO>(&version)))
@@ -347,8 +348,7 @@ wincapc::init ()
break;
}
- if (version.wProductType != VER_NT_WORKSTATION)
- ((wincaps *)caps)->is_server = true;
+ ((wincaps *)caps)->is_server = (version.wProductType != VER_NT_WORKSTATION);
if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
ProcessWow64Information,
&wow64, sizeof wow64, NULL))
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index c1e467275..52af5b96b 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -46,6 +46,7 @@ struct wincaps
class wincapc
{
+ SYSTEM_INFO system_info;
OSVERSIONINFOEX version;
char osnam[40];
ULONG wow64;
@@ -54,6 +55,10 @@ class wincapc
public:
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 bool is_wow64 () const { return wow64; }