From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2210) id 219103836C6D; Mon, 1 Feb 2021 14:59:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 219103836C6D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: remove the OPEN_MAX_MAX macro X-Act-Checkin: newlib-cygwin X-Git-Author: Ken Brown X-Git-Refname: refs/heads/master X-Git-Oldrev: b9cbc49b70c96bed047f8c9f2e995719ca68fc01 X-Git-Newrev: 5b8358e6ed8496f9c4a7cf6ed0fa740c79ff3719 Message-Id: <20210201145904.219103836C6D@sourceware.org> Date: Mon, 1 Feb 2021 14:59:04 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Feb 2021 14:59:04 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5b8358e6ed8496f9c4a7cf6ed0fa740c79ff3719 commit 5b8358e6ed8496f9c4a7cf6ed0fa740c79ff3719 Author: Ken Brown Date: Fri Jan 29 09:14:35 2021 -0500 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. Diff: --- winsup/cygwin/dtable.cc | 8 ++++---- winsup/cygwin/dtable.h | 2 -- winsup/cygwin/fcntl.cc | 2 +- winsup/cygwin/include/limits.h | 7 +++---- winsup/cygwin/resource.cc | 2 +- winsup/cygwin/syscalls.cc | 8 ++++---- 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 */