From 39473bba440668848d133e3d3a6c05266e3bd2a3 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 4 Sep 2003 10:57:58 +0000 Subject: * sysconf.cc (sysconf): Return more accurate value for _SC_AVPHYS_PAGES. --- winsup/cygwin/sysconf.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'winsup/cygwin/sysconf.cc') diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index d94b60699..fa290b945 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -69,7 +69,6 @@ sysconf (int in) return 1; /*FALLTHRU*/ case _SC_PHYS_PAGES: - case _SC_AVPHYS_PAGES: if (wincap.supports_smp ()) { NTSTATUS ret; @@ -100,11 +99,27 @@ sysconf (int in) } case _SC_PHYS_PAGES: return sbi.NumberOfPhysicalPages; - case _SC_AVPHYS_PAGES: - return sbi.HighestPhysicalPage - sbi.LowestPhysicalPage + 1; } } 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 */ -- cgit v1.2.3