Cygwin: wincap: expose more SYSTEM_INFO members and use as appropriate

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2018-04-11 11:59:35 +02:00
parent 402d68af1a
commit 92f4e0500b
3 changed files with 10 additions and 12 deletions

View File

@ -98,10 +98,7 @@ static bool get_load (double *load)
if (ret != ERROR_SUCCESS)
return false;
SYSTEM_INFO sysinfo;
GetSystemInfo (&sysinfo);
double running = fmtvalue1.doubleValue * sysinfo.dwNumberOfProcessors / 100;
double running = fmtvalue1.doubleValue * wincap.cpu_count () / 100;
/* Estimate the number of runnable processes using ProcessorQueueLength */
PDH_FMT_COUNTERVALUE fmtvalue2;

View File

@ -19,8 +19,6 @@ extern "C" int cygwin_gethostname (char *__name, size_t __len);
extern "C" int
uname (struct utsname *name)
{
SYSTEM_INFO sysinfo;
__try
{
char *snp = strstr (cygwin_version.dll_build_date, "SNP");
@ -34,8 +32,6 @@ uname (struct utsname *name)
strncat (name->sysname, "-WOW",
sizeof name->sysname - strlen (name->sysname) - 1);
GetSystemInfo (&sysinfo);
/* Computer name */
cygwin_gethostname (name->nodename, sizeof (name->nodename) - 1);
@ -56,16 +52,16 @@ uname (struct utsname *name)
name->version[snp - cygwin_version.dll_build_date] = '\0';
/* CPU type */
switch (sysinfo.wProcessorArchitecture)
switch (wincap.cpu_arch ())
{
case PROCESSOR_ARCHITECTURE_INTEL:
unsigned int ptype;
if (sysinfo.wProcessorLevel < 3) /* Shouldn't happen. */
if (wincap.cpu_level () < 3) /* Shouldn't happen. */
ptype = 3;
else if (sysinfo.wProcessorLevel > 9) /* P4 */
else if (wincap.cpu_level () > 9) /* P4 */
ptype = 6;
else
ptype = sysinfo.wProcessorLevel;
ptype = wincap.cpu_level ();
__small_sprintf (name->machine, "i%d86", ptype);
break;
case PROCESSOR_ARCHITECTURE_IA64:

View File

@ -42,6 +42,11 @@ public:
void init ();
const DWORD cpu_count () const { return system_info.dwNumberOfProcessors; }
const DWORD_PTR cpu_mask () const { return system_info.dwActiveProcessorMask;}
const WORD cpu_arch () const { return system_info.wProcessorArchitecture; }
const WORD cpu_level () const { return system_info.wProcessorLevel; }
/* The casts to size_t make sure that the returned value has the size of
a pointer on any system. This is important when using them for bit
mask operations, like in roundup2. */