diff options
author | Ken Brown <kbrown@cornell.edu> | 2021-01-29 17:14:35 +0300 |
---|---|---|
committer | Ken Brown <kbrown@cornell.edu> | 2021-02-01 17:55:08 +0300 |
commit | 5b8358e6ed8496f9c4a7cf6ed0fa740c79ff3719 (patch) | |
tree | de203e68efc3206377bdb1647550c6fcc773cf1c /winsup | |
parent | b9cbc49b70c96bed047f8c9f2e995719ca68fc01 (diff) |
Cygwin: remove the OPEN_MAX_MAX macro
Replace all occurrences of OPEN_MAX_MAX by OPEN_MAX, and define the
latter to be 3200, which was the value of the former. In view of the
recent change to getdtablesize, there is no longer a need to
distinguish between these two macros.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/dtable.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/dtable.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/fcntl.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/include/limits.h | 7 | ||||
-rw-r--r-- | winsup/cygwin/resource.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/sysconf.cc | 2 |
7 files changed, 14 insertions, 17 deletions
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 9f4210797..ad4b59211 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -74,10 +74,10 @@ dtable::extend (size_t howmuch, size_t min) size_t new_size = size + howmuch; fhandler_base **newfds; - if (new_size <= OPEN_MAX_MAX) + if (new_size <= OPEN_MAX) /* ok */; - else if (size < OPEN_MAX_MAX && min < OPEN_MAX_MAX) - new_size = OPEN_MAX_MAX; + else if (size < OPEN_MAX && min < OPEN_MAX) + new_size = OPEN_MAX; else { set_errno (EMFILE); @@ -735,7 +735,7 @@ dtable::dup3 (int oldfd, int newfd, int flags) set_errno (EBADF); goto done; } - if (newfd >= OPEN_MAX_MAX || newfd < 0) + if (newfd >= OPEN_MAX || newfd < 0) { syscall_printf ("new fd out of bounds: %d", newfd); set_errno (EBADF); diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h index 0f745a75a..e1a8461b8 100644 --- a/winsup/cygwin/dtable.h +++ b/winsup/cygwin/dtable.h @@ -10,8 +10,6 @@ details. */ /* Initial and increment values for cygwin's fd table */ #define NOFILE_INCR 32 -/* Maximum size we allow expanding to. */ -#define OPEN_MAX_MAX (100 * NOFILE_INCR) #include "thread.h" #include "sync.h" diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index 9ef7e521f..507ba61f7 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -57,7 +57,7 @@ fcntl64 (int fd, int cmd, ...) { case F_DUPFD: case F_DUPFD_CLOEXEC: - if (arg >= 0 && arg < OPEN_MAX_MAX) + if (arg >= 0 && arg < OPEN_MAX) { int flags = cmd == F_DUPFD_CLOEXEC ? O_CLOEXEC : 0; res = cygheap->fdtab.dup3 (fd, cygheap_fdnew ((arg) - 1), flags); diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h index 6a55578f3..497d45419 100644 --- a/winsup/cygwin/include/limits.h +++ b/winsup/cygwin/include/limits.h @@ -208,12 +208,11 @@ details. */ #undef MQ_PRIO_MAX #define MQ_PRIO_MAX INT_MAX -/* # of open files per process. Actually it can be more since Cygwin - grows the dtable as necessary. We define a reasonable limit here - which is returned by getdtablesize(), sysconf(_SC_OPEN_MAX) and +/* # of open files per process. This limit is returned by + getdtablesize(), sysconf(_SC_OPEN_MAX), and getrlimit(RLIMIT_NOFILE). */ #undef OPEN_MAX -#define OPEN_MAX 256 +#define OPEN_MAX 3200 /* Size in bytes of a page. */ #undef PAGESIZE diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index ac56acf8c..97777e9d2 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -182,7 +182,7 @@ getrlimit (int resource, struct rlimit *rlp) __get_rlimit_stack (rlp); break; case RLIMIT_NOFILE: - rlp->rlim_cur = rlp->rlim_max = OPEN_MAX_MAX; + rlp->rlim_cur = rlp->rlim_max = OPEN_MAX; break; case RLIMIT_CORE: rlp->rlim_cur = cygheap->rlim_core; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index d293ff2c0..52a020f07 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -143,7 +143,7 @@ extern "C" int dup2 (int oldfd, int newfd) { int res; - if (newfd >= OPEN_MAX_MAX || newfd < 0) + if (newfd >= OPEN_MAX || newfd < 0) { set_errno (EBADF); res = -1; @@ -164,7 +164,7 @@ extern "C" int dup3 (int oldfd, int newfd, int flags) { int res; - if (newfd >= OPEN_MAX_MAX) + if (newfd >= OPEN_MAX) { set_errno (EBADF); res = -1; @@ -2878,7 +2878,7 @@ setdtablesize (int size) } if (size <= (int) cygheap->fdtab.size - || cygheap->fdtab.extend (size - cygheap->fdtab.size, OPEN_MAX_MAX)) + || cygheap->fdtab.extend (size - cygheap->fdtab.size, OPEN_MAX)) return 0; return -1; @@ -2887,7 +2887,7 @@ setdtablesize (int size) extern "C" int getdtablesize () { - return OPEN_MAX_MAX; + return OPEN_MAX; } extern "C" int diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index d5d82bb4a..70cdb0fbd 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -511,7 +511,7 @@ static struct {cons, {c:CHILD_MAX}}, /* 1, _SC_CHILD_MAX */ {cons, {c:CLOCKS_PER_SEC}}, /* 2, _SC_CLK_TCK */ {cons, {c:NGROUPS_MAX}}, /* 3, _SC_NGROUPS_MAX */ - {cons, {c:OPEN_MAX_MAX}}, /* 4, _SC_OPEN_MAX */ + {cons, {c:OPEN_MAX}}, /* 4, _SC_OPEN_MAX */ {cons, {c:_POSIX_JOB_CONTROL}}, /* 5, _SC_JOB_CONTROL */ {cons, {c:_POSIX_SAVED_IDS}}, /* 6, _SC_SAVED_IDS */ {cons, {c:_POSIX_VERSION}}, /* 7, _SC_VERSION */ |