diff options
author | Christopher Faylor <cgf@redhat.com> | 2003-02-14 03:03:26 +0000 |
---|---|---|
committer | Christopher Faylor <cgf@redhat.com> | 2003-02-14 03:03:26 +0000 |
commit | e07f1ec5d50d3781167acad813023c327a98bfd8 (patch) | |
tree | d14e67e6282ef41f8e1efda6dcbc41cc8a62e90a /winsup/cygwin/sysconf.cc | |
parent | 335bdeb9375bfba164a07467a0ce6e9341a89a55 (diff) | |
download | gdb-e07f1ec5d50d3781167acad813023c327a98bfd8.tar.gz |
merge from trunk.
Reorganize includes throughout so that path.h comes before fhandler.h.
Eliminate path_conv arguments from fhandler functions which take them,
throughout. Use get_name() and get_win32_name() consistently throughout for
fhandler objects. Use build_fh_* functions throughout, where appropriate.
* fhandler.h (fhandler_base): Store path_conv struct here. Remove dev.
* dtable.h (dtable::build_fhandler_*): Remove.
(build_fh_dev): New.
(build_fh_pc): New.
(build_fh_name): New.
* dtable.cc (build_fh_dev): New.
(build_fh_pc): New.
(build_fh_name): New.
* fhandler.h (fhandler_base::set_name): Change argument.
* fhandler.cc (fhandler_base::set_name): Just accept a path_conv argument.
(executable_states): Move.
* path.h (executable_state): Accept.
* syscalls.cc (stat_worker): Make static.
* winsup.h (stat_worker): Remove definition.
Diffstat (limited to 'winsup/cygwin/sysconf.cc')
-rw-r--r-- | winsup/cygwin/sysconf.cc | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc new file mode 100644 index 00000000000..608f1877671 --- /dev/null +++ b/winsup/cygwin/sysconf.cc @@ -0,0 +1,102 @@ +/* sysconf.cc + + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +#include "winsup.h" +#include <unistd.h> +#include <errno.h> +#include <time.h> +#include <limits.h> +#include <ntdef.h> +#include "security.h" +#include "path.h" +#include "fhandler.h" +#include "dtable.h" +#include "cygerrno.h" +#include "cygheap.h" +#include "ntdll.h" + +/* sysconf: POSIX 4.8.1.1 */ +/* Allows a portable app to determine quantities of resources or + presence of an option at execution time. */ +long int +sysconf (int in) +{ + switch (in) + { + case _SC_ARG_MAX: + /* FIXME: what's the right value? _POSIX_ARG_MAX is only 4K */ + return 1048576; + case _SC_OPEN_MAX: + return getdtablesize (); + case _SC_PAGESIZE: + return getpagesize (); + case _SC_CLK_TCK: + return CLOCKS_PER_SEC; + case _SC_JOB_CONTROL: + return _POSIX_JOB_CONTROL; + case _SC_CHILD_MAX: + return CHILD_MAX; + case _SC_NGROUPS_MAX: + return NGROUPS_MAX; + case _SC_SAVED_IDS: + return _POSIX_SAVED_IDS; + case _SC_LOGIN_NAME_MAX: + case _SC_GETPW_R_SIZE_MAX: + case _SC_GETGR_R_SIZE_MAX: + return 16*1024; + case _SC_VERSION: + return _POSIX_VERSION; +#if 0 /* FIXME -- unimplemented */ + case _SC_TZNAME_MAX: + return _POSIX_TZNAME_MAX; + case _SC_STREAM_MAX: + return _POSIX_STREAM_MAX; +#endif + case _SC_NPROCESSORS_CONF: + case _SC_NPROCESSORS_ONLN: + if (!wincap.supports_smp ()) + return 1; + /*FALLTHRU*/ + case _SC_PHYS_PAGES: + case _SC_AVPHYS_PAGES: + if (wincap.supports_smp ()) + { + NTSTATUS ret; + SYSTEM_BASIC_INFORMATION sbi; + if ((ret = NtQuerySystemInformation (SystemBasicInformation, + (PVOID) &sbi, + sizeof sbi, NULL)) + != STATUS_SUCCESS) + { + __seterrno_from_win_error (RtlNtStatusToDosError (ret)); + debug_printf ("NtQuerySystemInformation: ret = %d, " + "Dos(ret) = %d", + ret, RtlNtStatusToDosError (ret)); + return -1; + } + switch (in) + { + case _SC_NPROCESSORS_CONF: + return sbi.NumberProcessors; + case _SC_NPROCESSORS_ONLN: + return sbi.ActiveProcessors; + case _SC_PHYS_PAGES: + return sbi.NumberOfPhysicalPages; + case _SC_AVPHYS_PAGES: + return sbi.HighestPhysicalPage - sbi.LowestPhysicalPage + 1; + } + } + break; + } + + /* Invalid input or unimplemented sysconf name */ + set_errno (EINVAL); + return -1; +} |