* sysconf.cc (sysconf): Return more accurate value for _SC_AVPHYS_PAGES.

This commit is contained in:
Corinna Vinschen 2003-09-04 10:57:58 +00:00
parent 4544f7f6a2
commit 39473bba44
2 changed files with 22 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2003-09-04 Corinna Vinschen <corinna@vinschen.de>
* sysconf.cc (sysconf): Return more accurate value for _SC_AVPHYS_PAGES.
2003-09-04 Corinna Vinschen <corinna@vinschen.de> 2003-09-04 Corinna Vinschen <corinna@vinschen.de>
* mmap.cc: Restructure. Add, remove and rewrite comments throughout * mmap.cc: Restructure. Add, remove and rewrite comments throughout

View File

@ -69,7 +69,6 @@ sysconf (int in)
return 1; return 1;
/*FALLTHRU*/ /*FALLTHRU*/
case _SC_PHYS_PAGES: case _SC_PHYS_PAGES:
case _SC_AVPHYS_PAGES:
if (wincap.supports_smp ()) if (wincap.supports_smp ())
{ {
NTSTATUS ret; NTSTATUS ret;
@ -100,11 +99,27 @@ sysconf (int in)
} }
case _SC_PHYS_PAGES: case _SC_PHYS_PAGES:
return sbi.NumberOfPhysicalPages; return sbi.NumberOfPhysicalPages;
case _SC_AVPHYS_PAGES:
return sbi.HighestPhysicalPage - sbi.LowestPhysicalPage + 1;
} }
} }
break; break;
case _SC_AVPHYS_PAGES:
if (wincap.supports_smp ())
{
NTSTATUS ret;
SYSTEM_PERFORMANCE_INFORMATION spi;
if ((ret = NtQuerySystemInformation (SystemPerformanceInformation,
(PVOID) &spi,
sizeof spi, NULL))
!= STATUS_SUCCESS)
{
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
debug_printf ("NtQuerySystemInformation: ret = %d, "
"Dos(ret) = %d",
ret, RtlNtStatusToDosError (ret));
return -1;
}
return spi.AvailablePages;
}
} }
/* Invalid input or unimplemented sysconf name */ /* Invalid input or unimplemented sysconf name */