public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: sysconf, getrlimit: don't call getdtablesize
Date: Mon,  1 Feb 2021 14:58:59 +0000 (GMT)	[thread overview]
Message-ID: <20210201145859.191543836C6D@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b9cbc49b70c96bed047f8c9f2e995719ca68fc01

commit b9cbc49b70c96bed047f8c9f2e995719ca68fc01
Author: Ken Brown <kbrown@cornell.edu>
Date:   Fri Jan 29 09:02:15 2021 -0500

    Cygwin: sysconf, getrlimit: don't call getdtablesize
    
    Now that getdtablesize always returns OPEN_MAX_MAX, we can simplify
    sysconf(_SC_OPEN_MAX) and getrlimit(RLIMIT_NOFILE) to just use that
    same constant instead of calling getdtablesize.

Diff:
---
 winsup/cygwin/resource.cc |  5 +----
 winsup/cygwin/sysconf.cc  | 11 +----------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc
index 9e39d3a04..ac56acf8c 100644
--- a/winsup/cygwin/resource.cc
+++ b/winsup/cygwin/resource.cc
@@ -182,10 +182,7 @@ getrlimit (int resource, struct rlimit *rlp)
 	  __get_rlimit_stack (rlp);
 	  break;
 	case RLIMIT_NOFILE:
-	  rlp->rlim_cur = getdtablesize ();
-	  if (rlp->rlim_cur < OPEN_MAX)
-	    rlp->rlim_cur = OPEN_MAX;
-	  rlp->rlim_max = OPEN_MAX_MAX;
+	  rlp->rlim_cur = rlp->rlim_max = OPEN_MAX_MAX;
 	  break;
 	case RLIMIT_CORE:
 	  rlp->rlim_cur = cygheap->rlim_core;
diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc
index 001da96ad..d5d82bb4a 100644
--- a/winsup/cygwin/sysconf.cc
+++ b/winsup/cygwin/sysconf.cc
@@ -21,15 +21,6 @@ details. */
 #include "cpuid.h"
 #include "clock.h"
 
-static long
-get_open_max (int in)
-{
-  long max = getdtablesize ();
-  if (max < OPEN_MAX)
-    max = OPEN_MAX;
-  return max;
-}
-
 static long
 get_page_size (int in)
 {
@@ -520,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 */
-  {func, {f:get_open_max}},		/*   4, _SC_OPEN_MAX */
+  {cons, {c:OPEN_MAX_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 */


                 reply	other threads:[~2021-02-01 14:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210201145859.191543836C6D@sourceware.org \
    --to=kbrown@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).