public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH 0/4] getdtablesize, OPEN_MAX, etc.
@ 2021-01-29 19:24 Ken Brown
  2021-01-29 19:24 ` [PATCH 1/4] Cygwin: getdtablesize: always return OPEN_MAX_MAX Ken Brown
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Ken Brown @ 2021-01-29 19:24 UTC (permalink / raw)
  To: cygwin-patches

This patchset is an extension of the patch submitted here:

  https://cygwin.com/pipermail/cygwin-patches/2021q1/011060.html

That patch is included as the first patch in this set.  The change to
OPEN_MAX still needs testing to see if it has too much impact on the
performance of tcsh.

I've make a first attempt to implement the suggestion of adding a new
<cygwin/limits.h> header.  At this writing I'm not completely sure
that I fully understand the purpose of that.  My choice of which
macros to define in it might need to be changed.

Ken Brown (4):
  Cygwin: getdtablesize: always return OPEN_MAX_MAX
  Cygwin: sysconf, getrlimit: don't call getdtablesize
  Cygwin: remove the OPEN_MAX_MAX macro
  Cygwin: include/cygwin/limits.h: new header

 winsup/cygwin/dtable.cc               |  8 +--
 winsup/cygwin/dtable.h                |  2 -
 winsup/cygwin/fcntl.cc                |  2 +-
 winsup/cygwin/include/cygwin/limits.h | 65 ++++++++++++++++++++
 winsup/cygwin/include/limits.h        | 85 +++++++++++----------------
 winsup/cygwin/resource.cc             |  5 +-
 winsup/cygwin/syscalls.cc             |  8 +--
 winsup/cygwin/sysconf.cc              | 11 +---
 8 files changed, 111 insertions(+), 75 deletions(-)
 create mode 100644 winsup/cygwin/include/cygwin/limits.h

-- 
2.30.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] Cygwin: getdtablesize: always return OPEN_MAX_MAX
  2021-01-29 19:24 [PATCH 0/4] getdtablesize, OPEN_MAX, etc Ken Brown
@ 2021-01-29 19:24 ` Ken Brown
  2021-01-29 19:24 ` [PATCH 2/4] Cygwin: sysconf, getrlimit: don't call getdtablesize Ken Brown
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ken Brown @ 2021-01-29 19:24 UTC (permalink / raw)
  To: cygwin-patches

According to the Linux man page for getdtablesize(3), the latter is
supposed to return "the maximum number of files a process can have
open, one more than the largest possible value for a file descriptor."
The constant OPEN_MAX_MAX is the only limit enforced by Cygwin, so we
now return that.

Previously getdtablesize returned the current size of cygheap->fdtab,
Cygwin's internal file descriptor table.  But this is a dynamically
growing table, and its current size does not reflect an actual limit
on the number of open files.

With this change, gnulib now reports that getdtablesize and
fcntl(F_DUPFD) work on Cygwin.  Packages like GNU tar that use the
corresponding gnulib modules will no longer use gnulib replacements on
Cygwin.
---
 winsup/cygwin/syscalls.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 82ddad46d..d293ff2c0 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2887,7 +2887,7 @@ setdtablesize (int size)
 extern "C" int
 getdtablesize ()
 {
-  return cygheap->fdtab.size;
+  return OPEN_MAX_MAX;
 }
 
 extern "C" int
-- 
2.30.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/4] Cygwin: sysconf, getrlimit: don't call getdtablesize
  2021-01-29 19:24 [PATCH 0/4] getdtablesize, OPEN_MAX, etc Ken Brown
  2021-01-29 19:24 ` [PATCH 1/4] Cygwin: getdtablesize: always return OPEN_MAX_MAX Ken Brown
@ 2021-01-29 19:24 ` Ken Brown
  2021-01-29 19:24 ` [PATCH 3/4] Cygwin: remove the OPEN_MAX_MAX macro Ken Brown
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ken Brown @ 2021-01-29 19:24 UTC (permalink / raw)
  To: cygwin-patches

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.
---
 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 */
-- 
2.30.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/4] Cygwin: remove the OPEN_MAX_MAX macro
  2021-01-29 19:24 [PATCH 0/4] getdtablesize, OPEN_MAX, etc Ken Brown
  2021-01-29 19:24 ` [PATCH 1/4] Cygwin: getdtablesize: always return OPEN_MAX_MAX Ken Brown
  2021-01-29 19:24 ` [PATCH 2/4] Cygwin: sysconf, getrlimit: don't call getdtablesize Ken Brown
@ 2021-01-29 19:24 ` Ken Brown
  2021-01-29 19:24 ` [PATCH 4/4] Cygwin: include/cygwin/limits.h: new header Ken Brown
  2021-02-01 10:46 ` [PATCH 0/4] getdtablesize, OPEN_MAX, etc Corinna Vinschen
  4 siblings, 0 replies; 6+ messages in thread
From: Ken Brown @ 2021-01-29 19:24 UTC (permalink / raw)
  To: cygwin-patches

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.
---
 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 */
-- 
2.30.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/4] Cygwin: include/cygwin/limits.h: new header
  2021-01-29 19:24 [PATCH 0/4] getdtablesize, OPEN_MAX, etc Ken Brown
                   ` (2 preceding siblings ...)
  2021-01-29 19:24 ` [PATCH 3/4] Cygwin: remove the OPEN_MAX_MAX macro Ken Brown
@ 2021-01-29 19:24 ` Ken Brown
  2021-02-01 10:46 ` [PATCH 0/4] getdtablesize, OPEN_MAX, etc Corinna Vinschen
  4 siblings, 0 replies; 6+ messages in thread
From: Ken Brown @ 2021-01-29 19:24 UTC (permalink / raw)
  To: cygwin-patches

The new header defines some Cygwin-specific limits, using private
names.  It is included by include/limits.h.

For example, we now have

  #define __OPEN_MAX 3200

in include/cygwin/limits.h and

  #define OPEN_MAX __OPEN_MAX

in include/limits.h.  The purpose is to hide implementation details
from users who view <limits.h>.
---
 winsup/cygwin/include/cygwin/limits.h | 65 ++++++++++++++++++++++
 winsup/cygwin/include/limits.h        | 80 +++++++++++----------------
 2 files changed, 98 insertions(+), 47 deletions(-)
 create mode 100644 winsup/cygwin/include/cygwin/limits.h

diff --git a/winsup/cygwin/include/cygwin/limits.h b/winsup/cygwin/include/cygwin/limits.h
new file mode 100644
index 000000000..f005d5742
--- /dev/null
+++ b/winsup/cygwin/include/cygwin/limits.h
@@ -0,0 +1,65 @@
+/* cygwin/limits.h
+
+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. */
+
+#ifndef _CYGWIN_LIMITS_H__
+#define _CYGWIN_LIMITS_H__
+
+#define __AIO_LISTIO_MAX 32
+#define __AIO_MAX 8
+#define __AIO_PRIO_DELTA_MAX 0
+
+/* 32000 is the safe value used for Windows processes when called from
+   Cygwin processes. */
+#define __ARG_MAX 32000
+#define __ATEXIT_MAX 32
+#define __CHILD_MAX 256
+#define __DELAYTIMER_MAX __INT_MAX__
+#define __HOST_NAME_MAX 255
+#define __IOV_MAX 1024
+#define __LOGIN_NAME_MAX 256	/* equal to UNLEN defined in w32api/lmcons.h */
+#define __MQ_OPEN_MAX 256
+#define __MQ_PRIO_MAX INT_MAX
+#define __OPEN_MAX 3200		/* value of the old OPEN_MAX_MAX */
+#define __PAGESIZE 65536
+#define __PTHREAD_DESTRUCTOR_ITERATIONS 4
+
+/* Tls has 1088 items - and we don't want to use them all :] */
+#define __PTHREAD_KEYS_MAX 1024
+/* Actually the minimum stack size is somewhat of a split personality.
+   The size parameter in a CreateThread call is the size of the initially
+   commited stack size, which can be specified as low as 4K.  However, the
+   default *reserved* stack size is 1 Meg, unless the .def file specifies
+   another STACKSIZE value.  And even if you specify a stack size below 64K,
+   the allocation granularity is in the way.  You can never squeeze multiple
+   threads in the same allocation granularity slot.  Oh well. */
+#define __PTHREAD_STACK_MIN 65536
+
+/* FIXME: We only support one realtime signal in 32 bit mode, but
+	 _POSIX_RTSIG_MAX is 8. */
+#if __WORDSIZE == 64
+#define __RTSIG_MAX 33
+#else
+#define __RTSIG_MAX 1
+#endif
+#define __SEM_VALUE_MAX 1147483648
+#define __SIGQUEUE_MAX 32
+#define __STREAM_MAX 20
+#define __SYMLOOP_MAX 10
+#define __TIMER_MAX 32
+#define __TTY_NAME_MAX 32
+#define __FILESIZEBITS 64
+#define __LINK_MAX 1024
+#define __MAX_CANON 255
+#define __MAX_INPUT 255
+#define __NAME_MAX 255
+
+/* Keep in sync with __PATHNAME_MAX__ in cygwin/config.h */
+#define __PATH_MAX 4096
+#define __PIPE_BUF 4096
+
+#endif /* _CYGWIN_LIMITS_H__ */
diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h
index 497d45419..6bdc9b40b 100644
--- a/winsup/cygwin/include/limits.h
+++ b/winsup/cygwin/include/limits.h
@@ -10,6 +10,7 @@ details. */
 
 #include <features.h>
 #include <bits/wordsize.h>
+#include <cygwin/limits.h>
 
 #ifndef _MACH_MACHLIMITS_H_
 
@@ -156,67 +157,66 @@ details. */
 
 /* Maximum number of I/O operations in a single list I/O call supported by
    the implementation. */
-#define AIO_LISTIO_MAX 32
+#define AIO_LISTIO_MAX __AIO_LISTIO_MAX
 
 /* Maximum number of outstanding asynchronous I/O operations supported by
    the implementation. */
-#define AIO_MAX 8
+#define AIO_MAX __AIO_MAX
 
 /* The maximum amount by which a process can decrease its asynchronous I/O
    priority level from its own scheduling priority. Not yet implemented. */
-#define AIO_PRIO_DELTA_MAX 0
+#define AIO_PRIO_DELTA_MAX __AIO_PRIO_DELTA_MAX
 
 /* Maximum number of bytes in arguments and environment passed in an exec
-   call.  32000 is the safe value used for Windows processes when called
-   from Cygwin processes. */
+   call. */
 #undef ARG_MAX
-#define ARG_MAX 32000
+#define ARG_MAX __ARG_MAX
 
 #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
 /* Maximum number of functions that may be registered with atexit(). */
 #undef ATEXIT_MAX
-#define ATEXIT_MAX 32
+#define ATEXIT_MAX __ATEXIT_MAX
 #endif
 
 /* Maximum number of simultaneous processes per real user ID. */
 #undef CHILD_MAX
-#define CHILD_MAX 256
+#define CHILD_MAX __CHILD_MAX
 
 /* Maximum number of timer expiration overruns.  Not yet implemented. */
 #undef DELAYTIMER_MAX
-#define DELAYTIMER_MAX __INT_MAX__
+#define DELAYTIMER_MAX __DELAYTIMER_MAX
 
 /* Maximum length of a host name. */
 #undef HOST_NAME_MAX
-#define HOST_NAME_MAX 255
+#define HOST_NAME_MAX __HOST_NAME_MAX
 
 #if __XSI_VISIBLE
 /* Maximum number of iovcnt in a writev (an arbitrary number) */
 #undef IOV_MAX
-#define IOV_MAX 1024
+#define IOV_MAX __IOV_MAX
 #endif
 
 /* Maximum number of characters in a login name. */
 #undef LOGIN_NAME_MAX
-#define LOGIN_NAME_MAX 256	/* equal to UNLEN defined in w32api/lmcons.h */
+#define LOGIN_NAME_MAX __LOGIN_NAME_MAX
 
 /* The maximum number of open message queue descriptors a process may hold. */
 #undef MQ_OPEN_MAX
-#define MQ_OPEN_MAX OPEN_MAX
+#define MQ_OPEN_MAX __MQ_OPEN_MAX
 
 /* The maximum number of message priorities supported by the implementation. */
 #undef MQ_PRIO_MAX
-#define MQ_PRIO_MAX INT_MAX
+#define MQ_PRIO_MAX __MQ_PRIO_MAX
 
 /* # 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 3200
+#define OPEN_MAX __OPEN_MAX
 
 /* Size in bytes of a page. */
 #undef PAGESIZE
-#define PAGESIZE 65536
+#define PAGESIZE __PAGESIZE
 #if __XSI_VISIBLE
 #undef PAGE_SIZE
 #define PAGE_SIZE PAGESIZE
@@ -225,23 +225,15 @@ details. */
 /* Maximum number of attempts made to destroy a thread's thread-specific
    data values on thread exit. */
 #undef PTHREAD_DESTRUCTOR_ITERATIONS
-#define PTHREAD_DESTRUCTOR_ITERATIONS 4
+#define PTHREAD_DESTRUCTOR_ITERATIONS __PTHREAD_DESTRUCTOR_ITERATIONS
 
 /* Maximum number of data keys that can be created by a process. */
-/* Tls has 1088 items - and we don't want to use them all :] */
 #undef PTHREAD_KEYS_MAX
-#define PTHREAD_KEYS_MAX 1024
+#define PTHREAD_KEYS_MAX __PTHREAD_KEYS_MAX
 
 /* Minimum size in bytes of thread stack storage. */
-/* Actually the minimum stack size is somewhat of a split personality.
-   The size parameter in a CreateThread call is the size of the initially
-   commited stack size, which can be specified as low as 4K.  However, the
-   default *reserved* stack size is 1 Meg, unless the .def file specifies
-   another STACKSIZE value.  And even if you specify a stack size below 64K,
-   the allocation granularity is in the way.  You can never squeeze multiple
-   threads in the same allocation granularity slot.  Oh well. */
 #undef PTHREAD_STACK_MIN
-#define PTHREAD_STACK_MIN 65536
+#define PTHREAD_STACK_MIN __PTHREAD_STACK_MIN
 
 /* Maximum number of threads that can be created per process. */
 /* Windows allows any arbitrary number of threads per process. */
@@ -249,14 +241,8 @@ details. */
 /* #define PTHREAD_THREADS_MAX unspecified */
 
 /* Maximum number of realtime signals reserved for application use. */
-/* FIXME: We only support one realtime signal in 32 bit mode, but
-	 _POSIX_RTSIG_MAX is 8. */
 #undef RTSIG_MAX
-#if __WORDSIZE == 64
-#define RTSIG_MAX 33
-#else
-#define RTSIG_MAX 1
-#endif
+#define RTSIG_MAX __RTSIG_MAX
 
 /* Maximum number of semaphores that a process may have. */
 /* Windows allows any arbitrary number of semaphores per process. */
@@ -265,12 +251,12 @@ details. */
 
 /* The maximum value a semaphore may have. */
 #undef SEM_VALUE_MAX
-#define SEM_VALUE_MAX 1147483648
+#define SEM_VALUE_MAX __SEM_VALUE_MAX
 
 /* Maximum number of queued signals that a process may send and have pending
    at the receiver(s) at any time. */
 #undef SIGQUEUE_MAX
-#define SIGQUEUE_MAX 32
+#define SIGQUEUE_MAX __SIGQUEUE_MAX
 
 /* The maximum number of replenishment operations that may be simultaneously
    pending for a particular sporadic server scheduler.  Not implemented. */
@@ -279,15 +265,15 @@ details. */
 
 /* Number of streams that one process can have open at one time. */
 #undef STREAM_MAX
-#define STREAM_MAX 20
+#define STREAM_MAX __STREAM_MAX
 
 /* Maximum number of nested symbolic links. */
 #undef SYMLOOP_MAX
-#define SYMLOOP_MAX 10
+#define SYMLOOP_MAX __SYMLOOP_MAX
 
 /* Maximum number of timer expiration overruns. */
 #undef TIMER_MAX
-#define TIMER_MAX 32
+#define TIMER_MAX __TIMER_MAX
 
 /* Maximum length of the trace event name.  Not implemented. */
 #undef TRACE_EVENT_NAME_MAX
@@ -311,7 +297,7 @@ details. */
 
 /* Maximum number of characters in a tty name. */
 #undef TTY_NAME_MAX
-#define TTY_NAME_MAX 32
+#define TTY_NAME_MAX __TTY_NAME_MAX
 
 /* Maximum number of bytes supported for the name of a timezone (not of the TZ variable).  Not implemented. */
 #undef TZNAME_MAX
@@ -322,35 +308,35 @@ details. */
 
 /* Minimum bits needed to represent the maximum size of a regular file. */
 #undef FILESIZEBITS
-#define FILESIZEBITS 64
+#define FILESIZEBITS __FILESIZEBITS
 
 /* Maximum number of hardlinks to a file. */
 #undef LINK_MAX
-#define LINK_MAX 1024
+#define LINK_MAX __LINK_MAX
 
 /* Maximum number of bytes in a terminal canonical input line. */
 #undef MAX_CANON
-#define MAX_CANON 255
+#define MAX_CANON __MAX_CANON
 
 /* Minimum number of bytes available in a terminal input queue. */
 #undef MAX_INPUT
-#define MAX_INPUT 255
+#define MAX_INPUT __MAX_INPUT
 
 /* Maximum length of a path component. */
 #undef NAME_MAX
-#define NAME_MAX 255
+#define NAME_MAX __NAME_MAX
 
 /* Maximum length of a path given to API functions including trailing NUL.
    Deliberately set to the same default value as on Linux.  Internal paths
    may be longer. */
 /* Keep in sync with __PATHNAME_MAX__ in cygwin/config.h */
 #undef PATH_MAX
-#define PATH_MAX 4096
+#define PATH_MAX __PATH_MAX
 
 /* # of bytes in a pipe buf. This is the max # of bytes which can be
    written to a pipe in one atomic operation. */
 #undef PIPE_BUF
-#define PIPE_BUF 4096
+#define PIPE_BUF __PIPE_BUF
 
 /* Minimum number of bytes of storage actually allocated for any portion
    of a file.  Not implemented. */
-- 
2.30.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] getdtablesize, OPEN_MAX, etc.
  2021-01-29 19:24 [PATCH 0/4] getdtablesize, OPEN_MAX, etc Ken Brown
                   ` (3 preceding siblings ...)
  2021-01-29 19:24 ` [PATCH 4/4] Cygwin: include/cygwin/limits.h: new header Ken Brown
@ 2021-02-01 10:46 ` Corinna Vinschen
  4 siblings, 0 replies; 6+ messages in thread
From: Corinna Vinschen @ 2021-02-01 10:46 UTC (permalink / raw)
  To: cygwin-patches

On Jan 29 14:24, Ken Brown via Cygwin-patches wrote:
> This patchset is an extension of the patch submitted here:
> 
>   https://cygwin.com/pipermail/cygwin-patches/2021q1/011060.html
> 
> That patch is included as the first patch in this set.  The change to
> OPEN_MAX still needs testing to see if it has too much impact on the
> performance of tcsh.
> 
> I've make a first attempt to implement the suggestion of adding a new
> <cygwin/limits.h> header.  At this writing I'm not completely sure
> that I fully understand the purpose of that.  My choice of which
> macros to define in it might need to be changed.
> 
> Ken Brown (4):
>   Cygwin: getdtablesize: always return OPEN_MAX_MAX
>   Cygwin: sysconf, getrlimit: don't call getdtablesize
>   Cygwin: remove the OPEN_MAX_MAX macro
>   Cygwin: include/cygwin/limits.h: new header
> 
>  winsup/cygwin/dtable.cc               |  8 +--
>  winsup/cygwin/dtable.h                |  2 -
>  winsup/cygwin/fcntl.cc                |  2 +-
>  winsup/cygwin/include/cygwin/limits.h | 65 ++++++++++++++++++++
>  winsup/cygwin/include/limits.h        | 85 +++++++++++----------------
>  winsup/cygwin/resource.cc             |  5 +-
>  winsup/cygwin/syscalls.cc             |  8 +--
>  winsup/cygwin/sysconf.cc              | 11 +---
>  8 files changed, 111 insertions(+), 75 deletions(-)
>  create mode 100644 winsup/cygwin/include/cygwin/limits.h
> 
> -- 
> 2.30.0

Looks great, please push.


Corinna

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-01 10:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 19:24 [PATCH 0/4] getdtablesize, OPEN_MAX, etc Ken Brown
2021-01-29 19:24 ` [PATCH 1/4] Cygwin: getdtablesize: always return OPEN_MAX_MAX Ken Brown
2021-01-29 19:24 ` [PATCH 2/4] Cygwin: sysconf, getrlimit: don't call getdtablesize Ken Brown
2021-01-29 19:24 ` [PATCH 3/4] Cygwin: remove the OPEN_MAX_MAX macro Ken Brown
2021-01-29 19:24 ` [PATCH 4/4] Cygwin: include/cygwin/limits.h: new header Ken Brown
2021-02-01 10:46 ` [PATCH 0/4] getdtablesize, OPEN_MAX, etc Corinna Vinschen

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).