4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-19 04:49:25 +08:00

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.
This commit is contained in:
Ken Brown 2021-01-29 09:14:35 -05:00
parent b9cbc49b70
commit 5b8358e6ed
7 changed files with 14 additions and 17 deletions

View File

@ -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);

View File

@ -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"

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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 */