From eef57fe1e33dddda8840188a62365393a683fb54 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 22 Feb 2007 17:09:46 +0000 Subject: * fhandler.cc (fhandler_base::set_no_inheritance): Always use SetHandleInformation. * fhandler_disk_file.cc (fhandler_disk_file::lock): Always use UnlockFileEx/LockFileEx functions. * net.cc (fdsock): Don't bother to duplicate socket for inheritance. * sysconf.cc (get_nproc_values): Take NT for granted. (get_avphys): Ditto. * syslog.cc (WIN95_EVENT_LOG_PATH): Remove define. (get_win95_event_log_path): Remove. (vsyslog): Fix formatting. Take NT for granted. * wincap.cc: Remove has_lock_file_ex, has_signal_object_and_wait, has_eventlog, has_set_handle_information, has_set_handle_information_on_console_handles and supports_smp throughout. * wincap.h: Ditto. --- winsup/cygwin/sysconf.cc | 81 ++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 50 deletions(-) (limited to 'winsup/cygwin/sysconf.cc') diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index 7a4ee9c64..64f5bfaa1 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -40,46 +40,32 @@ get_page_size (int in) static long get_nproc_values (int in) { + NTSTATUS ret; + SYSTEM_BASIC_INFORMATION sbi; + if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi, + sizeof sbi, NULL)) != STATUS_SUCCESS) + { + __seterrno_from_nt_status (ret); + debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", + ret); + return -1; + } switch (in) { case _SC_NPROCESSORS_CONF: + return sbi.NumberProcessors; case _SC_NPROCESSORS_ONLN: - if (!wincap.supports_smp ()) - return 1; - /*FALLTHRU*/ + { + int i = 0; + do + if (sbi.ActiveProcessors & 1) + i++; + while (sbi.ActiveProcessors >>= 1); + return i; + } case _SC_PHYS_PAGES: - if (wincap.supports_smp ()) - { - NTSTATUS ret; - SYSTEM_BASIC_INFORMATION sbi; - if ((ret = NtQuerySystemInformation (SystemBasicInformation, - (PVOID) &sbi, - sizeof sbi, NULL)) - != STATUS_SUCCESS) - { - __seterrno_from_nt_status (ret); - debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", - ret); - return -1; - } - switch (in) - { - case _SC_NPROCESSORS_CONF: - return sbi.NumberProcessors; - case _SC_NPROCESSORS_ONLN: - { - int i = 0; - do - if (sbi.ActiveProcessors & 1) - i++; - while (sbi.ActiveProcessors >>= 1); - return i; - } - case _SC_PHYS_PAGES: - return sbi.NumberOfPhysicalPages - / (getpagesize () / getsystempagesize ()); - } - } + return sbi.NumberOfPhysicalPages + / (getpagesize () / getsystempagesize ()); } return -1; } @@ -87,23 +73,18 @@ get_nproc_values (int in) static long get_avphys (int in) { - if (wincap.supports_smp ()) + NTSTATUS ret; + SYSTEM_PERFORMANCE_INFORMATION spi; + if ((ret = NtQuerySystemInformation (SystemPerformanceInformation, + (PVOID) &spi, sizeof spi, NULL)) + != STATUS_SUCCESS) { - NTSTATUS ret; - SYSTEM_PERFORMANCE_INFORMATION spi; - if ((ret = NtQuerySystemInformation (SystemPerformanceInformation, - (PVOID) &spi, - sizeof spi, NULL)) - != STATUS_SUCCESS) - { - __seterrno_from_nt_status (ret); - debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", - ret); - return -1; - } - return spi.AvailablePages / (getpagesize () / getsystempagesize ()); + __seterrno_from_nt_status (ret); + debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", + ret); + return -1; } - return -1; + return spi.AvailablePages / (getpagesize () / getsystempagesize ()); } enum sc_type { nsup, cons, func }; -- cgit v1.2.3