* [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
@ 2021-07-09 21:09 H.J. Lu
2021-07-09 22:07 ` Carlos O'Donell
2021-07-12 19:07 ` Maxim Kuvyrkov
0 siblings, 2 replies; 7+ messages in thread
From: H.J. Lu @ 2021-07-09 21:09 UTC (permalink / raw)
To: libc-alpha
The constant PTHREAD_STACK_MIN may be too small for some processors.
Rename _SC_SIGSTKSZ_SOURCE to _DYNAMIC_STACK_SIZE_SOURCE. When
_DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined, define
PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) which is changed
to MIN (PTHREAD_STACK_MIN, sysconf(_SC_MINSIGSTKSZ)).
Consolidate <bits/local_lim.h> with <bits/pthread_stack_min.h> to
provide a constant target specific PTHREAD_STACK_MIN value.
---
NEWS | 8 +-
include/bits/local_lim.h | 7 ++
include/features.h | 18 ++--
manual/creature.texi | 4 +-
nptl/tst-context1.c | 15 ++-
stdlib/test-atexit-race-common.c | 11 +-
support/support_path_support_time64.c | 1 +
sysdeps/posix/sysconf-pthread_stack_min.h | 29 +++++
sysdeps/posix/sysconf.c | 7 +-
sysdeps/unix/sysv/linux/Makefile | 3 +-
.../unix/sysv/linux/aarch64/bits/local_lim.h | 101 ------------------
.../linux/aarch64/bits/pthread_stack_min.h | 22 ++++
.../unix/sysv/linux/alpha/bits/local_lim.h | 99 -----------------
.../sysv/linux/alpha/bits/pthread_stack_min.h | 20 ++++
sysdeps/unix/sysv/linux/bits/local_lim.h | 8 +-
.../unix/sysv/linux/bits/pthread_stack_min.h | 20 ++++
sysdeps/unix/sysv/linux/bits/sigstksz.h | 2 +-
sysdeps/unix/sysv/linux/ia64/bits/local_lim.h | 99 -----------------
.../sysv/linux/ia64/bits/pthread_stack_min.h | 20 ++++
sysdeps/unix/sysv/linux/mips/bits/local_lim.h | 99 -----------------
.../sysv/linux/mips/bits/pthread_stack_min.h | 20 ++++
.../unix/sysv/linux/powerpc/bits/local_lim.h | 100 -----------------
.../linux/powerpc/bits/pthread_stack_min.h | 21 ++++
.../unix/sysv/linux/sparc/bits/local_lim.h | 99 -----------------
.../sysv/linux/sparc/bits/pthread_stack_min.h | 20 ++++
.../sysv/linux/sysconf-pthread_stack_min.h | 39 +++++++
26 files changed, 266 insertions(+), 626 deletions(-)
create mode 100644 include/bits/local_lim.h
create mode 100644 sysdeps/posix/sysconf-pthread_stack_min.h
delete mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
create mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
delete mode 100644 sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
create mode 100644 sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
create mode 100644 sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
delete mode 100644 sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
create mode 100644 sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
delete mode 100644 sysdeps/unix/sysv/linux/mips/bits/local_lim.h
create mode 100644 sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
create mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
delete mode 100644 sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
create mode 100644 sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
create mode 100644 sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
diff --git a/NEWS b/NEWS
index 91d5f17598..13ffe627da 100644
--- a/NEWS
+++ b/NEWS
@@ -9,8 +9,12 @@ Version 2.34
Major new features:
-* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _SC_SIGSTKSZ_SOURCE or
- _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
+* When _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined,
+ PTHREAD_STACK_MIN is no longer constant and is redefined to
+ sysconf(_SC_THREAD_STACK_MIN).
+
+* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _DYNAMIC_STACK_SIZE_SOURCE
+ or _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
constant on Linux. MINSIGSTKSZ is redefined to sysconf(_SC_MINSIGSTKSZ)
and SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ).
diff --git a/include/bits/local_lim.h b/include/bits/local_lim.h
new file mode 100644
index 0000000000..46d82dc729
--- /dev/null
+++ b/include/bits/local_lim.h
@@ -0,0 +1,7 @@
+/* Don't define PTHREAD_STACK_MIN to sysconf (_SC_THREAD_STACK_MIN) for
+ glibc build. */
+#if !defined _ISOMAC
+# undef __USE_DYNAMIC_STACK_SIZE
+#endif
+
+#include_next <bits/local_lim.h>
diff --git a/include/features.h b/include/features.h
index 039bcb112b..51c8a98fb0 100644
--- a/include/features.h
+++ b/include/features.h
@@ -50,8 +50,8 @@
_LARGEFILE64_SOURCE Additional functionality from LFS for large files.
_FILE_OFFSET_BITS=N Select default filesystem interface.
_ATFILE_SOURCE Additional *at interfaces.
- _SC_SIGSTKSZ_SOURCE Select correct (but non compile-time constant)
- MINSIGSTKSZ and SIGSTKSZ.
+ _DYNAMIC_STACK_SIZE_SOURCE Select correct (but non compile-time constant)
+ MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
_GNU_SOURCE All of the above, plus GNU extensions.
_DEFAULT_SOURCE The default set of features (taking precedence over
__STRICT_ANSI__).
@@ -98,8 +98,8 @@
__USE_FILE_OFFSET64 Define 64bit interface as default.
__USE_MISC Define things from 4.3BSD or System V Unix.
__USE_ATFILE Define *at interfaces and AT_* constants for them.
- __USE_SC_SIGSTKSZ Define correct (but non compile-time constant)
- MINSIGSTKSZ and SIGSTKSZ.
+ __USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant)
+ MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
__USE_GNU Define GNU extensions.
__USE_FORTIFY_LEVEL Additional security measures used, according to level.
@@ -143,7 +143,7 @@
#undef __USE_FILE_OFFSET64
#undef __USE_MISC
#undef __USE_ATFILE
-#undef __USE_SC_SIGSTKSZ
+#undef __USE_DYNAMIC_STACK_SIZE
#undef __USE_GNU
#undef __USE_FORTIFY_LEVEL
#undef __KERNEL_STRICT_NAMES
@@ -220,8 +220,8 @@
# define _DEFAULT_SOURCE 1
# undef _ATFILE_SOURCE
# define _ATFILE_SOURCE 1
-# undef _SC_SIGSTKSZ_SOURCE
-# define _SC_SIGSTKSZ_SOURCE 1
+# undef _DYNAMIC_STACK_SIZE_SOURCE
+# define _DYNAMIC_STACK_SIZE_SOURCE 1
#endif
/* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,
@@ -399,8 +399,8 @@
# define __USE_ATFILE 1
#endif
-#ifdef _SC_SIGSTKSZ_SOURCE
-# define __USE_SC_SIGSTKSZ 1
+#ifdef _DYNAMIC_STACK_SIZE_SOURCE
+# define __USE_DYNAMIC_STACK_SIZE 1
#endif
#ifdef _GNU_SOURCE
diff --git a/manual/creature.texi b/manual/creature.texi
index d3c4fa4702..c13de52f1f 100644
--- a/manual/creature.texi
+++ b/manual/creature.texi
@@ -308,10 +308,10 @@ checks are applied. If defined to @math{3}, @theglibc{} may also use
checks that may have an additional performance overhead.
@end defvr
-@defvr Macro _SC_SIGSTKSZ_SOURCE
+@defvr Macro _DYNAMIC_STACK_SIZE_SOURCE
@standards{GNU, (none)}
If this macro is defined, correct (but non compile-time constant)
-MINSIGSTKSZ and SIGSTKSZ are defined.
+MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN are defined.
@end defvr
@defvr Macro _REENTRANT
diff --git a/nptl/tst-context1.c b/nptl/tst-context1.c
index 821f3c2133..00e39aff9f 100644
--- a/nptl/tst-context1.c
+++ b/nptl/tst-context1.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ucontext.h>
+#include <support/support.h>
#define N 4
#if __WORDSIZE == 64
@@ -36,7 +37,8 @@ typedef struct {
unsigned long guard[3];
} tst_context_t;
-static char stacks[N][2 * PTHREAD_STACK_MIN];
+static char *stacks[N];
+static size_t stack_size;
static tst_context_t ctx[N][2];
static volatile int failures;
@@ -79,7 +81,7 @@ fct (long int n)
exit (1);
}
- if (on_stack < stacks[n] || on_stack >= stacks[n] + sizeof (stacks[0]))
+ if (on_stack < stacks[n] || on_stack >= stacks[n] + stack_size)
{
printf ("%ld: on_stack not on appropriate stack\n", n);
exit (1);
@@ -109,7 +111,7 @@ tf (void *arg)
printf ("%d: %s: before makecontext\n", n, __FUNCTION__);
ctx[n][1].uctx.uc_stack.ss_sp = stacks[n];
- ctx[n][1].uctx.uc_stack.ss_size = sizeof (stacks[n]);
+ ctx[n][1].uctx.uc_stack.ss_size = stack_size;
ctx[n][1].uctx.uc_link = &ctx[n][0].uctx;
makecontext (&ctx[n][1].uctx, (void (*) (void)) fct, 1, (long int) n);
@@ -137,6 +139,10 @@ do_test (void)
pthread_t th[N];
ucontext_t mctx;
+ stack_size = 2 * PTHREAD_STACK_MIN;
+ for (int i = 0; i < N; i++)
+ stacks[i] = xmalloc (stack_size);
+
puts ("making contexts");
if (getcontext (&mctx) != 0)
{
@@ -198,6 +204,9 @@ do_test (void)
exit (1);
}
+ for (int i = 0; i < N; i++)
+ free (stacks[i]);
+
return failures;
}
diff --git a/stdlib/test-atexit-race-common.c b/stdlib/test-atexit-race-common.c
index a2b5468580..b48bb16285 100644
--- a/stdlib/test-atexit-race-common.c
+++ b/stdlib/test-atexit-race-common.c
@@ -38,11 +38,6 @@
const size_t kNumThreads = 1024;
const size_t kNumHandlers = 1024;
-const size_t kStacksize =
-#ifdef PTHREAD_STACK_MIN
- 0x20000 < PTHREAD_STACK_MIN ? PTHREAD_STACK_MIN :
-#endif
- 0x20000;
static void *
threadfunc (void *unused)
@@ -66,6 +61,12 @@ do_test (void)
/* With default 8MiB Linux stack size, creating 1024 threads can cause
VM exhausiton on 32-bit machines. Reduce stack size of each thread to
128KiB for a maximum required VM size of 128MiB. */
+ size_t kStacksize =
+#ifdef PTHREAD_STACK_MIN
+ 0x20000 < PTHREAD_STACK_MIN ? PTHREAD_STACK_MIN :
+#endif
+ 0x20000;
+
xpthread_attr_setstacksize (&attr, kStacksize);
for (i = 0; i < kNumThreads; ++i) {
diff --git a/support/support_path_support_time64.c b/support/support_path_support_time64.c
index 33b2bdff66..619a4eab00 100644
--- a/support/support_path_support_time64.c
+++ b/support/support_path_support_time64.c
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <fcntl.h>
+#include <unistd.h>
#include <support/check.h>
#include <support/support.h>
#include <sys/stat.h>
diff --git a/sysdeps/posix/sysconf-pthread_stack_min.h b/sysdeps/posix/sysconf-pthread_stack_min.h
new file mode 100644
index 0000000000..f5be2e6f9f
--- /dev/null
+++ b/sysdeps/posix/sysconf-pthread_stack_min.h
@@ -0,0 +1,29 @@
+/* __get_pthread_stack_min (). POSIX version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Return sysconf (_SC_THREAD_STACK_MIN). */
+
+static inline long int
+__get_pthread_stack_min (void)
+{
+#ifdef PTHREAD_STACK_MIN
+ return PTHREAD_STACK_MIN;
+#else
+ return -1;
+#endif
+}
diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
index 3e8ec5cd51..5fb3fb6c1c 100644
--- a/sysdeps/posix/sysconf.c
+++ b/sysdeps/posix/sysconf.c
@@ -31,6 +31,7 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <regex.h>
+#include <sysconf-pthread_stack_min.h>
#define NEED_SPEC_ARRAY 0
#include <posix-conf-vars.h>
@@ -569,11 +570,7 @@ __sysconf (int name)
#endif
case _SC_THREAD_STACK_MIN:
-#ifdef PTHREAD_STACK_MIN
- return PTHREAD_STACK_MIN;
-#else
- return -1;
-#endif
+ return __get_pthread_stack_min ();
case _SC_THREAD_THREADS_MAX:
#ifdef PTHREAD_THREADS_MAX
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index d45a16af8b..7d43dc95f2 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -108,7 +108,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
bits/types/struct_semid64_ds.h \
bits/types/struct_semid64_ds_helper.h \
bits/types/struct_shmid64_ds.h \
- bits/types/struct_shmid64_ds_helper.h
+ bits/types/struct_shmid64_ds_helper.h \
+ bits/pthread_stack_min.h
tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h b/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
deleted file mode 100644
index 0652bf4a06..0000000000
--- a/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Minimum guaranteed maximum values for system limits. Linux version.
- Copyright (C) 1993-2021 Free Software Foundation, Inc.
-
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <https://www.gnu.org/licenses/>. */
-
-/* The kernel header pollutes the namespace with the NR_OPEN symbol
- and defines LINK_MAX although filesystems have different maxima. A
- similar thing is true for OPEN_MAX: the limit can be changed at
- runtime and therefore the macro must not be defined. Remove this
- after including the header if necessary. */
-#ifndef NR_OPEN
-# define __undef_NR_OPEN
-#endif
-#ifndef LINK_MAX
-# define __undef_LINK_MAX
-#endif
-#ifndef OPEN_MAX
-# define __undef_OPEN_MAX
-#endif
-#ifndef ARG_MAX
-# define __undef_ARG_MAX
-#endif
-
-/* The kernel sources contain a file with all the needed information. */
-#include <linux/limits.h>
-
-/* Have to remove NR_OPEN? */
-#ifdef __undef_NR_OPEN
-# undef NR_OPEN
-# undef __undef_NR_OPEN
-#endif
-/* Have to remove LINK_MAX? */
-#ifdef __undef_LINK_MAX
-# undef LINK_MAX
-# undef __undef_LINK_MAX
-#endif
-/* Have to remove OPEN_MAX? */
-#ifdef __undef_OPEN_MAX
-# undef OPEN_MAX
-# undef __undef_OPEN_MAX
-#endif
-/* Have to remove ARG_MAX? */
-#ifdef __undef_ARG_MAX
-# undef ARG_MAX
-# undef __undef_ARG_MAX
-#endif
-
-/* The number of data keys per process. */
-#define _POSIX_THREAD_KEYS_MAX 128
-/* This is the value this implementation supports. */
-#define PTHREAD_KEYS_MAX 1024
-
-/* Controlling the iterations of destructors for thread-specific data. */
-#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-/* Number of iterations this implementation does. */
-#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-
-/* The number of threads per process. */
-#define _POSIX_THREAD_THREADS_MAX 64
-/* We have no predefined limit on the number of threads. */
-#undef PTHREAD_THREADS_MAX
-
-/* Maximum amount by which a process can descrease its asynchronous I/O
- priority level. */
-#define AIO_PRIO_DELTA_MAX 20
-
-/* Minimum size for a thread. At least two pages for systems with 64k
- pages. */
-#define PTHREAD_STACK_MIN 131072
-
-/* Maximum number of timer expiration overruns. */
-#define DELAYTIMER_MAX 2147483647
-
-/* Maximum tty name length. */
-#define TTY_NAME_MAX 32
-
-/* Maximum login name length. This is arbitrary. */
-#define LOGIN_NAME_MAX 256
-
-/* Maximum host name length. */
-#define HOST_NAME_MAX 64
-
-/* Maximum message queue priority level. */
-#define MQ_PRIO_MAX 32768
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX (2147483647)
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
new file mode 100644
index 0000000000..97215687ad
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
@@ -0,0 +1,22 @@
+/* Definition of PTHREAD_STACK_MIN. Linux/aarch64 version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Minimum size for a thread. At least two pages for systems with 64k
+ pages. */
+#define PTHREAD_STACK_MIN 131072
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h b/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
deleted file mode 100644
index 523407dc48..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Minimum guaranteed maximum values for system limits. Linux/Alpha version.
- Copyright (C) 1993-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library. If not, see
- <https://www.gnu.org/licenses/>. */
-
-/* The kernel header pollutes the namespace with the NR_OPEN symbol
- and defines LINK_MAX although filesystems have different maxima. A
- similar thing is true for OPEN_MAX: the limit can be changed at
- runtime and therefore the macro must not be defined. Remove this
- after including the header if necessary. */
-#ifndef NR_OPEN
-# define __undef_NR_OPEN
-#endif
-#ifndef LINK_MAX
-# define __undef_LINK_MAX
-#endif
-#ifndef OPEN_MAX
-# define __undef_OPEN_MAX
-#endif
-#ifndef ARG_MAX
-# define __undef_ARG_MAX
-#endif
-
-/* The kernel sources contain a file with all the needed information. */
-#include <linux/limits.h>
-
-/* Have to remove NR_OPEN? */
-#ifdef __undef_NR_OPEN
-# undef NR_OPEN
-# undef __undef_NR_OPEN
-#endif
-/* Have to remove LINK_MAX? */
-#ifdef __undef_LINK_MAX
-# undef LINK_MAX
-# undef __undef_LINK_MAX
-#endif
-/* Have to remove OPEN_MAX? */
-#ifdef __undef_OPEN_MAX
-# undef OPEN_MAX
-# undef __undef_OPEN_MAX
-#endif
-/* Have to remove ARG_MAX? */
-#ifdef __undef_ARG_MAX
-# undef ARG_MAX
-# undef __undef_ARG_MAX
-#endif
-
-/* The number of data keys per process. */
-#define _POSIX_THREAD_KEYS_MAX 128
-/* This is the value this implementation supports. */
-#define PTHREAD_KEYS_MAX 1024
-
-/* Controlling the iterations of destructors for thread-specific data. */
-#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-/* Number of iterations this implementation does. */
-#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-
-/* The number of threads per process. */
-#define _POSIX_THREAD_THREADS_MAX 64
-/* We have no predefined limit on the number of threads. */
-#undef PTHREAD_THREADS_MAX
-
-/* Maximum amount by which a process can descrease its asynchronous I/O
- priority level. */
-#define AIO_PRIO_DELTA_MAX 20
-
-/* Minimum size for a thread. We are free to choose a reasonable value. */
-#define PTHREAD_STACK_MIN 24576
-
-/* Maximum number of timer expiration overruns. */
-#define DELAYTIMER_MAX 2147483647
-
-/* Maximum tty name length. */
-#define TTY_NAME_MAX 32
-
-/* Maximum login name length. This is arbitrary. */
-#define LOGIN_NAME_MAX 256
-
-/* Maximum host name length. */
-#define HOST_NAME_MAX 64
-
-/* Maximum message queue priority level. */
-#define MQ_PRIO_MAX 32768
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX (2147483647)
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
new file mode 100644
index 0000000000..5bfb0e10dd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
@@ -0,0 +1,20 @@
+/* Definition of PTHREAD_STACK_MIN. Linux/Alpha version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 24576
diff --git a/sysdeps/unix/sysv/linux/bits/local_lim.h b/sysdeps/unix/sysv/linux/bits/local_lim.h
index b88ca3d4d2..0b1c7f40be 100644
--- a/sysdeps/unix/sysv/linux/bits/local_lim.h
+++ b/sysdeps/unix/sysv/linux/bits/local_lim.h
@@ -78,7 +78,13 @@
#define AIO_PRIO_DELTA_MAX 20
/* Minimum size for a thread. We are free to choose a reasonable value. */
-#define PTHREAD_STACK_MIN 16384
+#undef PTHREAD_STACK_MIN
+#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
+# include <unistd.h>
+# define PTHREAD_STACK_MIN sysconf (_SC_THREAD_STACK_MIN)
+#else
+# include <bits/pthread_stack_min.h>
+#endif
/* Maximum number of timer expiration overruns. */
#define DELAYTIMER_MAX 2147483647
diff --git a/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
new file mode 100644
index 0000000000..7bd6fa1242
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
@@ -0,0 +1,20 @@
+/* Definition of PTHREAD_STACK_MIN. Linux version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 16384
diff --git a/sysdeps/unix/sysv/linux/bits/sigstksz.h b/sysdeps/unix/sysv/linux/bits/sigstksz.h
index 926508f2b4..cd45d122e0 100644
--- a/sysdeps/unix/sysv/linux/bits/sigstksz.h
+++ b/sysdeps/unix/sysv/linux/bits/sigstksz.h
@@ -20,7 +20,7 @@
# error "Never include <bits/sigstksz.h> directly; use <signal.h> instead."
#endif
-#if defined __USE_SC_SIGSTKSZ && __USE_SC_SIGSTKSZ
+#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
# include <unistd.h>
/* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ). */
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h b/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
deleted file mode 100644
index 7a9f677ec8..0000000000
--- a/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Minimum guaranteed maximum values for system limits. Linux/IA-64 version.
- Copyright (C) 1993-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* The kernel header pollutes the namespace with the NR_OPEN symbol
- and defines LINK_MAX although filesystems have different maxima. A
- similar thing is true for OPEN_MAX: the limit can be changed at
- runtime and therefore the macro must not be defined. Remove this
- after including the header if necessary. */
-#ifndef NR_OPEN
-# define __undef_NR_OPEN
-#endif
-#ifndef LINK_MAX
-# define __undef_LINK_MAX
-#endif
-#ifndef OPEN_MAX
-# define __undef_OPEN_MAX
-#endif
-#ifndef ARG_MAX
-# define __undef_ARG_MAX
-#endif
-
-/* The kernel sources contain a file with all the needed information. */
-#include <linux/limits.h>
-
-/* Have to remove NR_OPEN? */
-#ifdef __undef_NR_OPEN
-# undef NR_OPEN
-# undef __undef_NR_OPEN
-#endif
-/* Have to remove LINK_MAX? */
-#ifdef __undef_LINK_MAX
-# undef LINK_MAX
-# undef __undef_LINK_MAX
-#endif
-/* Have to remove OPEN_MAX? */
-#ifdef __undef_OPEN_MAX
-# undef OPEN_MAX
-# undef __undef_OPEN_MAX
-#endif
-/* Have to remove ARG_MAX? */
-#ifdef __undef_ARG_MAX
-# undef ARG_MAX
-# undef __undef_ARG_MAX
-#endif
-
-/* The number of data keys per process. */
-#define _POSIX_THREAD_KEYS_MAX 128
-/* This is the value this implementation supports. */
-#define PTHREAD_KEYS_MAX 1024
-
-/* Controlling the iterations of destructors for thread-specific data. */
-#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-/* Number of iterations this implementation does. */
-#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-
-/* The number of threads per process. */
-#define _POSIX_THREAD_THREADS_MAX 64
-/* We have no predefined limit on the number of threads. */
-#undef PTHREAD_THREADS_MAX
-
-/* Maximum amount by which a process can descrease its asynchronous I/O
- priority level. */
-#define AIO_PRIO_DELTA_MAX 20
-
-/* Minimum size for a thread. We are free to choose a reasonable value. */
-#define PTHREAD_STACK_MIN 196608
-
-/* Maximum number of timer expiration overruns. */
-#define DELAYTIMER_MAX 2147483647
-
-/* Maximum tty name length. */
-#define TTY_NAME_MAX 32
-
-/* Maximum login name length. This is arbitrary. */
-#define LOGIN_NAME_MAX 256
-
-/* Maximum host name length. */
-#define HOST_NAME_MAX 64
-
-/* Maximum message queue priority level. */
-#define MQ_PRIO_MAX 32768
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX (2147483647)
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
new file mode 100644
index 0000000000..73581506b2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
@@ -0,0 +1,20 @@
+/* Definition of PTHREAD_STACK_MIN. Linux/IA-64 version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 196608
diff --git a/sysdeps/unix/sysv/linux/mips/bits/local_lim.h b/sysdeps/unix/sysv/linux/mips/bits/local_lim.h
deleted file mode 100644
index a6a0d8a980..0000000000
--- a/sysdeps/unix/sysv/linux/mips/bits/local_lim.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Minimum guaranteed maximum values for system limits. MIPS Linux version.
- Copyright (C) 1993-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <https://www.gnu.org/licenses/>. */
-
-/* The kernel header pollutes the namespace with the NR_OPEN symbol
- and defines LINK_MAX although filesystems have different maxima. A
- similar thing is true for OPEN_MAX: the limit can be changed at
- runtime and therefore the macro must not be defined. Remove this
- after including the header if necessary. */
-#ifndef NR_OPEN
-# define __undef_NR_OPEN
-#endif
-#ifndef LINK_MAX
-# define __undef_LINK_MAX
-#endif
-#ifndef OPEN_MAX
-# define __undef_OPEN_MAX
-#endif
-#ifndef ARG_MAX
-# define __undef_ARG_MAX
-#endif
-
-/* The kernel sources contain a file with all the needed information. */
-#include <linux/limits.h>
-
-/* Have to remove NR_OPEN? */
-#ifdef __undef_NR_OPEN
-# undef NR_OPEN
-# undef __undef_NR_OPEN
-#endif
-/* Have to remove LINK_MAX? */
-#ifdef __undef_LINK_MAX
-# undef LINK_MAX
-# undef __undef_LINK_MAX
-#endif
-/* Have to remove OPEN_MAX? */
-#ifdef __undef_OPEN_MAX
-# undef OPEN_MAX
-# undef __undef_OPEN_MAX
-#endif
-/* Have to remove ARG_MAX? */
-#ifdef __undef_ARG_MAX
-# undef ARG_MAX
-# undef __undef_ARG_MAX
-#endif
-
-/* The number of data keys per process. */
-#define _POSIX_THREAD_KEYS_MAX 128
-/* This is the value this implementation supports. */
-#define PTHREAD_KEYS_MAX 1024
-
-/* Controlling the iterations of destructors for thread-specific data. */
-#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-/* Number of iterations this implementation does. */
-#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-
-/* The number of threads per process. */
-#define _POSIX_THREAD_THREADS_MAX 64
-/* We have no predefined limit on the number of threads. */
-#undef PTHREAD_THREADS_MAX
-
-/* Maximum amount by which a process can descrease its asynchronous I/O
- priority level. */
-#define AIO_PRIO_DELTA_MAX 20
-
-/* Minimum size for a thread. At least two pages with 64k pages. */
-#define PTHREAD_STACK_MIN 131072
-
-/* Maximum number of timer expiration overruns. */
-#define DELAYTIMER_MAX 2147483647
-
-/* Maximum tty name length. */
-#define TTY_NAME_MAX 32
-
-/* Maximum login name length. This is arbitrary. */
-#define LOGIN_NAME_MAX 256
-
-/* Maximum host name length. */
-#define HOST_NAME_MAX 64
-
-/* Maximum message queue priority level. */
-#define MQ_PRIO_MAX 32768
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX (2147483647)
diff --git a/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
new file mode 100644
index 0000000000..132f1704a5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
@@ -0,0 +1,20 @@
+/* Definition of PTHREAD_STACK_MIN. MIPS Linux version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Minimum size for a thread. At least two pages with 64k pages. */
+#define PTHREAD_STACK_MIN 131072
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h b/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
deleted file mode 100644
index 6caa627506..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Minimum guaranteed maximum values for system limits. Linux/PPC version.
- Copyright (C) 1993-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <https://www.gnu.org/licenses/>. */
-
-/* The kernel header pollutes the namespace with the NR_OPEN symbol
- and defines LINK_MAX although filesystems have different maxima. A
- similar thing is true for OPEN_MAX: the limit can be changed at
- runtime and therefore the macro must not be defined. Remove this
- after including the header if necessary. */
-#ifndef NR_OPEN
-# define __undef_NR_OPEN
-#endif
-#ifndef LINK_MAX
-# define __undef_LINK_MAX
-#endif
-#ifndef OPEN_MAX
-# define __undef_OPEN_MAX
-#endif
-#ifndef ARG_MAX
-# define __undef_ARG_MAX
-#endif
-
-/* The kernel sources contain a file with all the needed information. */
-#include <linux/limits.h>
-
-/* Have to remove NR_OPEN? */
-#ifdef __undef_NR_OPEN
-# undef NR_OPEN
-# undef __undef_NR_OPEN
-#endif
-/* Have to remove LINK_MAX? */
-#ifdef __undef_LINK_MAX
-# undef LINK_MAX
-# undef __undef_LINK_MAX
-#endif
-/* Have to remove OPEN_MAX? */
-#ifdef __undef_OPEN_MAX
-# undef OPEN_MAX
-# undef __undef_OPEN_MAX
-#endif
-/* Have to remove ARG_MAX? */
-#ifdef __undef_ARG_MAX
-# undef ARG_MAX
-# undef __undef_ARG_MAX
-#endif
-
-/* The number of data keys per process. */
-#define _POSIX_THREAD_KEYS_MAX 128
-/* This is the value this implementation supports. */
-#define PTHREAD_KEYS_MAX 1024
-
-/* Controlling the iterations of destructors for thread-specific data. */
-#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-/* Number of iterations this implementation does. */
-#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-
-/* The number of threads per process. */
-#define _POSIX_THREAD_THREADS_MAX 64
-/* We have no predefined limit on the number of threads. */
-#undef PTHREAD_THREADS_MAX
-
-/* Maximum amount by which a process can descrease its asynchronous I/O
- priority level. */
-#define AIO_PRIO_DELTA_MAX 20
-
-/* Minimum size for a thread. At least two pages for systems with 64k
- pages. */
-#define PTHREAD_STACK_MIN 131072
-
-/* Maximum number of timer expiration overruns. */
-#define DELAYTIMER_MAX 2147483647
-
-/* Maximum tty name length. */
-#define TTY_NAME_MAX 32
-
-/* Maximum login name length. This is arbitrary. */
-#define LOGIN_NAME_MAX 256
-
-/* Maximum host name length. */
-#define HOST_NAME_MAX 64
-
-/* Maximum message queue priority level. */
-#define MQ_PRIO_MAX 32768
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX (2147483647)
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
new file mode 100644
index 0000000000..d7017e7b24
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
@@ -0,0 +1,21 @@
+/* Definition of PTHREAD_STACK_MIN. Linux/PPC version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <https://www.gnu.org/licenses/>. */
+
+/* Minimum size for a thread. At least two pages for systems with 64k
+ pages. */
+#define PTHREAD_STACK_MIN 131072
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h b/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
deleted file mode 100644
index 4a9a8c1325..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Minimum guaranteed maximum values for system limits. Linux/SPARC version.
- Copyright (C) 1993-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <https://www.gnu.org/licenses/>. */
-
-/* The kernel header pollutes the namespace with the NR_OPEN symbol
- and defines LINK_MAX although filesystems have different maxima. A
- similar thing is true for OPEN_MAX: the limit can be changed at
- runtime and therefore the macro must not be defined. Remove this
- after including the header if necessary. */
-#ifndef NR_OPEN
-# define __undef_NR_OPEN
-#endif
-#ifndef LINK_MAX
-# define __undef_LINK_MAX
-#endif
-#ifndef OPEN_MAX
-# define __undef_OPEN_MAX
-#endif
-#ifndef ARG_MAX
-# define __undef_ARG_MAX
-#endif
-
-/* The kernel sources contain a file with all the needed information. */
-#include <linux/limits.h>
-
-/* Have to remove NR_OPEN? */
-#ifdef __undef_NR_OPEN
-# undef NR_OPEN
-# undef __undef_NR_OPEN
-#endif
-/* Have to remove LINK_MAX? */
-#ifdef __undef_LINK_MAX
-# undef LINK_MAX
-# undef __undef_LINK_MAX
-#endif
-/* Have to remove OPEN_MAX? */
-#ifdef __undef_OPEN_MAX
-# undef OPEN_MAX
-# undef __undef_OPEN_MAX
-#endif
-/* Have to remove ARG_MAX? */
-#ifdef __undef_ARG_MAX
-# undef ARG_MAX
-# undef __undef_ARG_MAX
-#endif
-
-/* The number of data keys per process. */
-#define _POSIX_THREAD_KEYS_MAX 128
-/* This is the value this implementation supports. */
-#define PTHREAD_KEYS_MAX 1024
-
-/* Controlling the iterations of destructors for thread-specific data. */
-#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-/* Number of iterations this implementation does. */
-#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-
-/* The number of threads per process. */
-#define _POSIX_THREAD_THREADS_MAX 64
-/* We have no predefined limit on the number of threads. */
-#undef PTHREAD_THREADS_MAX
-
-/* Maximum amount by which a process can descrease its asynchronous I/O
- priority level. */
-#define AIO_PRIO_DELTA_MAX 20
-
-/* Minimum size for a thread. We are free to choose a reasonable value. */
-#define PTHREAD_STACK_MIN 24576
-
-/* Maximum number of timer expiration overruns. */
-#define DELAYTIMER_MAX 2147483647
-
-/* Maximum tty name length. */
-#define TTY_NAME_MAX 32
-
-/* Maximum login name length. This is arbitrary. */
-#define LOGIN_NAME_MAX 256
-
-/* Maximum host name length. */
-#define HOST_NAME_MAX 64
-
-/* Maximum message queue priority level. */
-#define MQ_PRIO_MAX 32768
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX (2147483647)
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
new file mode 100644
index 0000000000..bcacedb73b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
@@ -0,0 +1,20 @@
+/* Definition of PTHREAD_STACK_MIN. Linux/SPARC version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <https://www.gnu.org/licenses/>. */
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 24576
diff --git a/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
new file mode 100644
index 0000000000..9e0eb0f7fc
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
@@ -0,0 +1,39 @@
+/* __get_pthread_stack_min (). Linux version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Return sysconf (_SC_THREAD_STACK_MIN). */
+
+static inline long int
+__get_pthread_stack_min (void)
+{
+ /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */
+ long int pthread_stack_min = GLRO(dl_minsigstacksize);
+ assert (pthread_stack_min != 0);
+ _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
+ "PTHREAD_STACK_MIN is constant");
+ /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */
+ if (pthread_stack_min < PTHREAD_STACK_MIN)
+ pthread_stack_min = PTHREAD_STACK_MIN;
+ /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
+ which returns a larger size that includes the required TLS variable
+ space which has been determined at startup. For sysconf here we are
+ conservative and don't include the space required for TLS access.
+ Eventually the TLS variable space will not be part of the stack
+ (Bug 11787). */
+ return pthread_stack_min;
+}
--
2.31.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
2021-07-09 21:09 [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) H.J. Lu
@ 2021-07-09 22:07 ` Carlos O'Donell
2021-07-12 19:07 ` Maxim Kuvyrkov
1 sibling, 0 replies; 7+ messages in thread
From: Carlos O'Donell @ 2021-07-09 22:07 UTC (permalink / raw)
To: H.J. Lu, libc-alpha
On 7/9/21 5:09 PM, H.J. Lu wrote:
> The constant PTHREAD_STACK_MIN may be too small for some processors.
> Rename _SC_SIGSTKSZ_SOURCE to _DYNAMIC_STACK_SIZE_SOURCE. When
> _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined, define
> PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) which is changed
> to MIN (PTHREAD_STACK_MIN, sysconf(_SC_MINSIGSTKSZ)).
>
> Consolidate <bits/local_lim.h> with <bits/pthread_stack_min.h> to
> provide a constant target specific PTHREAD_STACK_MIN value.
OK for 2.34.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> ---
> NEWS | 8 +-
> include/bits/local_lim.h | 7 ++
> include/features.h | 18 ++--
> manual/creature.texi | 4 +-
> nptl/tst-context1.c | 15 ++-
> stdlib/test-atexit-race-common.c | 11 +-
> support/support_path_support_time64.c | 1 +
> sysdeps/posix/sysconf-pthread_stack_min.h | 29 +++++
> sysdeps/posix/sysconf.c | 7 +-
> sysdeps/unix/sysv/linux/Makefile | 3 +-
> .../unix/sysv/linux/aarch64/bits/local_lim.h | 101 ------------------
> .../linux/aarch64/bits/pthread_stack_min.h | 22 ++++
> .../unix/sysv/linux/alpha/bits/local_lim.h | 99 -----------------
> .../sysv/linux/alpha/bits/pthread_stack_min.h | 20 ++++
> sysdeps/unix/sysv/linux/bits/local_lim.h | 8 +-
> .../unix/sysv/linux/bits/pthread_stack_min.h | 20 ++++
> sysdeps/unix/sysv/linux/bits/sigstksz.h | 2 +-
> sysdeps/unix/sysv/linux/ia64/bits/local_lim.h | 99 -----------------
> .../sysv/linux/ia64/bits/pthread_stack_min.h | 20 ++++
> sysdeps/unix/sysv/linux/mips/bits/local_lim.h | 99 -----------------
> .../sysv/linux/mips/bits/pthread_stack_min.h | 20 ++++
> .../unix/sysv/linux/powerpc/bits/local_lim.h | 100 -----------------
> .../linux/powerpc/bits/pthread_stack_min.h | 21 ++++
> .../unix/sysv/linux/sparc/bits/local_lim.h | 99 -----------------
> .../sysv/linux/sparc/bits/pthread_stack_min.h | 20 ++++
> .../sysv/linux/sysconf-pthread_stack_min.h | 39 +++++++
> 26 files changed, 266 insertions(+), 626 deletions(-)
> create mode 100644 include/bits/local_lim.h
> create mode 100644 sysdeps/posix/sysconf-pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> create mode 100644 sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> create mode 100644 sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
>
> diff --git a/NEWS b/NEWS
> index 91d5f17598..13ffe627da 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -9,8 +9,12 @@ Version 2.34
>
> Major new features:
>
> -* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _SC_SIGSTKSZ_SOURCE or
> - _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
> +* When _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined,
> + PTHREAD_STACK_MIN is no longer constant and is redefined to
> + sysconf(_SC_THREAD_STACK_MIN).
> +
> +* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _DYNAMIC_STACK_SIZE_SOURCE
> + or _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
> constant on Linux. MINSIGSTKSZ is redefined to sysconf(_SC_MINSIGSTKSZ)
> and SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ).
>
> diff --git a/include/bits/local_lim.h b/include/bits/local_lim.h
> new file mode 100644
> index 0000000000..46d82dc729
> --- /dev/null
> +++ b/include/bits/local_lim.h
> @@ -0,0 +1,7 @@
> +/* Don't define PTHREAD_STACK_MIN to sysconf (_SC_THREAD_STACK_MIN) for
> + glibc build. */
> +#if !defined _ISOMAC
> +# undef __USE_DYNAMIC_STACK_SIZE
> +#endif
> +
> +#include_next <bits/local_lim.h>
> diff --git a/include/features.h b/include/features.h
> index 039bcb112b..51c8a98fb0 100644
> --- a/include/features.h
> +++ b/include/features.h
> @@ -50,8 +50,8 @@
> _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
> _FILE_OFFSET_BITS=N Select default filesystem interface.
> _ATFILE_SOURCE Additional *at interfaces.
> - _SC_SIGSTKSZ_SOURCE Select correct (but non compile-time constant)
> - MINSIGSTKSZ and SIGSTKSZ.
> + _DYNAMIC_STACK_SIZE_SOURCE Select correct (but non compile-time constant)
> + MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
> _GNU_SOURCE All of the above, plus GNU extensions.
> _DEFAULT_SOURCE The default set of features (taking precedence over
> __STRICT_ANSI__).
> @@ -98,8 +98,8 @@
> __USE_FILE_OFFSET64 Define 64bit interface as default.
> __USE_MISC Define things from 4.3BSD or System V Unix.
> __USE_ATFILE Define *at interfaces and AT_* constants for them.
> - __USE_SC_SIGSTKSZ Define correct (but non compile-time constant)
> - MINSIGSTKSZ and SIGSTKSZ.
> + __USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant)
> + MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
> __USE_GNU Define GNU extensions.
> __USE_FORTIFY_LEVEL Additional security measures used, according to level.
>
> @@ -143,7 +143,7 @@
> #undef __USE_FILE_OFFSET64
> #undef __USE_MISC
> #undef __USE_ATFILE
> -#undef __USE_SC_SIGSTKSZ
> +#undef __USE_DYNAMIC_STACK_SIZE
> #undef __USE_GNU
> #undef __USE_FORTIFY_LEVEL
> #undef __KERNEL_STRICT_NAMES
> @@ -220,8 +220,8 @@
> # define _DEFAULT_SOURCE 1
> # undef _ATFILE_SOURCE
> # define _ATFILE_SOURCE 1
> -# undef _SC_SIGSTKSZ_SOURCE
> -# define _SC_SIGSTKSZ_SOURCE 1
> +# undef _DYNAMIC_STACK_SIZE_SOURCE
> +# define _DYNAMIC_STACK_SIZE_SOURCE 1
> #endif
>
> /* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,
> @@ -399,8 +399,8 @@
> # define __USE_ATFILE 1
> #endif
>
> -#ifdef _SC_SIGSTKSZ_SOURCE
> -# define __USE_SC_SIGSTKSZ 1
> +#ifdef _DYNAMIC_STACK_SIZE_SOURCE
> +# define __USE_DYNAMIC_STACK_SIZE 1
> #endif
>
> #ifdef _GNU_SOURCE
> diff --git a/manual/creature.texi b/manual/creature.texi
> index d3c4fa4702..c13de52f1f 100644
> --- a/manual/creature.texi
> +++ b/manual/creature.texi
> @@ -308,10 +308,10 @@ checks are applied. If defined to @math{3}, @theglibc{} may also use
> checks that may have an additional performance overhead.
> @end defvr
>
> -@defvr Macro _SC_SIGSTKSZ_SOURCE
> +@defvr Macro _DYNAMIC_STACK_SIZE_SOURCE
> @standards{GNU, (none)}
> If this macro is defined, correct (but non compile-time constant)
> -MINSIGSTKSZ and SIGSTKSZ are defined.
> +MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN are defined.
> @end defvr
>
> @defvr Macro _REENTRANT
> diff --git a/nptl/tst-context1.c b/nptl/tst-context1.c
> index 821f3c2133..00e39aff9f 100644
> --- a/nptl/tst-context1.c
> +++ b/nptl/tst-context1.c
> @@ -23,6 +23,7 @@
> #include <stdio.h>
> #include <stdlib.h>
> #include <ucontext.h>
> +#include <support/support.h>
>
> #define N 4
> #if __WORDSIZE == 64
> @@ -36,7 +37,8 @@ typedef struct {
> unsigned long guard[3];
> } tst_context_t;
>
> -static char stacks[N][2 * PTHREAD_STACK_MIN];
> +static char *stacks[N];
> +static size_t stack_size;
> static tst_context_t ctx[N][2];
> static volatile int failures;
>
> @@ -79,7 +81,7 @@ fct (long int n)
> exit (1);
> }
>
> - if (on_stack < stacks[n] || on_stack >= stacks[n] + sizeof (stacks[0]))
> + if (on_stack < stacks[n] || on_stack >= stacks[n] + stack_size)
> {
> printf ("%ld: on_stack not on appropriate stack\n", n);
> exit (1);
> @@ -109,7 +111,7 @@ tf (void *arg)
> printf ("%d: %s: before makecontext\n", n, __FUNCTION__);
>
> ctx[n][1].uctx.uc_stack.ss_sp = stacks[n];
> - ctx[n][1].uctx.uc_stack.ss_size = sizeof (stacks[n]);
> + ctx[n][1].uctx.uc_stack.ss_size = stack_size;
> ctx[n][1].uctx.uc_link = &ctx[n][0].uctx;
> makecontext (&ctx[n][1].uctx, (void (*) (void)) fct, 1, (long int) n);
>
> @@ -137,6 +139,10 @@ do_test (void)
> pthread_t th[N];
> ucontext_t mctx;
>
> + stack_size = 2 * PTHREAD_STACK_MIN;
> + for (int i = 0; i < N; i++)
> + stacks[i] = xmalloc (stack_size);
> +
> puts ("making contexts");
> if (getcontext (&mctx) != 0)
> {
> @@ -198,6 +204,9 @@ do_test (void)
> exit (1);
> }
>
> + for (int i = 0; i < N; i++)
> + free (stacks[i]);
> +
> return failures;
> }
>
> diff --git a/stdlib/test-atexit-race-common.c b/stdlib/test-atexit-race-common.c
> index a2b5468580..b48bb16285 100644
> --- a/stdlib/test-atexit-race-common.c
> +++ b/stdlib/test-atexit-race-common.c
> @@ -38,11 +38,6 @@
>
> const size_t kNumThreads = 1024;
> const size_t kNumHandlers = 1024;
> -const size_t kStacksize =
> -#ifdef PTHREAD_STACK_MIN
> - 0x20000 < PTHREAD_STACK_MIN ? PTHREAD_STACK_MIN :
> -#endif
> - 0x20000;
>
> static void *
> threadfunc (void *unused)
> @@ -66,6 +61,12 @@ do_test (void)
> /* With default 8MiB Linux stack size, creating 1024 threads can cause
> VM exhausiton on 32-bit machines. Reduce stack size of each thread to
> 128KiB for a maximum required VM size of 128MiB. */
> + size_t kStacksize =
> +#ifdef PTHREAD_STACK_MIN
> + 0x20000 < PTHREAD_STACK_MIN ? PTHREAD_STACK_MIN :
> +#endif
> + 0x20000;
> +
> xpthread_attr_setstacksize (&attr, kStacksize);
>
> for (i = 0; i < kNumThreads; ++i) {
> diff --git a/support/support_path_support_time64.c b/support/support_path_support_time64.c
> index 33b2bdff66..619a4eab00 100644
> --- a/support/support_path_support_time64.c
> +++ b/support/support_path_support_time64.c
> @@ -17,6 +17,7 @@
> <https://www.gnu.org/licenses/>. */
>
> #include <fcntl.h>
> +#include <unistd.h>
> #include <support/check.h>
> #include <support/support.h>
> #include <sys/stat.h>
> diff --git a/sysdeps/posix/sysconf-pthread_stack_min.h b/sysdeps/posix/sysconf-pthread_stack_min.h
> new file mode 100644
> index 0000000000..f5be2e6f9f
> --- /dev/null
> +++ b/sysdeps/posix/sysconf-pthread_stack_min.h
> @@ -0,0 +1,29 @@
> +/* __get_pthread_stack_min (). POSIX version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Return sysconf (_SC_THREAD_STACK_MIN). */
> +
> +static inline long int
> +__get_pthread_stack_min (void)
> +{
> +#ifdef PTHREAD_STACK_MIN
> + return PTHREAD_STACK_MIN;
> +#else
> + return -1;
> +#endif
> +}
> diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
> index 3e8ec5cd51..5fb3fb6c1c 100644
> --- a/sysdeps/posix/sysconf.c
> +++ b/sysdeps/posix/sysconf.c
> @@ -31,6 +31,7 @@
> #include <sys/types.h>
> #include <sys/uio.h>
> #include <regex.h>
> +#include <sysconf-pthread_stack_min.h>
>
> #define NEED_SPEC_ARRAY 0
> #include <posix-conf-vars.h>
> @@ -569,11 +570,7 @@ __sysconf (int name)
> #endif
>
> case _SC_THREAD_STACK_MIN:
> -#ifdef PTHREAD_STACK_MIN
> - return PTHREAD_STACK_MIN;
> -#else
> - return -1;
> -#endif
> + return __get_pthread_stack_min ();
>
> case _SC_THREAD_THREADS_MAX:
> #ifdef PTHREAD_THREADS_MAX
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index d45a16af8b..7d43dc95f2 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -108,7 +108,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
> bits/types/struct_semid64_ds.h \
> bits/types/struct_semid64_ds_helper.h \
> bits/types/struct_shmid64_ds.h \
> - bits/types/struct_shmid64_ds_helper.h
> + bits/types/struct_shmid64_ds_helper.h \
> + bits/pthread_stack_min.h
>
> tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
> tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
> diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h b/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> deleted file mode 100644
> index 0652bf4a06..0000000000
> --- a/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> +++ /dev/null
> @@ -1,101 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> -
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public License as
> - published by the Free Software Foundation; either version 2.1 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library. If not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. At least two pages for systems with 64k
> - pages. */
> -#define PTHREAD_STACK_MIN 131072
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..97215687ad
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> @@ -0,0 +1,22 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/aarch64 version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> +
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public License as
> + published by the Free Software Foundation; either version 2.1 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. At least two pages for systems with 64k
> + pages. */
> +#define PTHREAD_STACK_MIN 131072
> diff --git a/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h b/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> deleted file mode 100644
> index 523407dc48..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> +++ /dev/null
> @@ -1,99 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux/Alpha version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Library General Public License as
> - published by the Free Software Foundation; either version 2 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Library General Public License for more details.
> -
> - You should have received a copy of the GNU Library General Public
> - License along with the GNU C Library. If not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. We are free to choose a reasonable value. */
> -#define PTHREAD_STACK_MIN 24576
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..5bfb0e10dd
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/Alpha version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Library General Public License as
> + published by the Free Software Foundation; either version 2 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Library General Public License for more details.
> +
> + You should have received a copy of the GNU Library General Public
> + License along with the GNU C Library. If not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. We are free to choose a reasonable value. */
> +#define PTHREAD_STACK_MIN 24576
> diff --git a/sysdeps/unix/sysv/linux/bits/local_lim.h b/sysdeps/unix/sysv/linux/bits/local_lim.h
> index b88ca3d4d2..0b1c7f40be 100644
> --- a/sysdeps/unix/sysv/linux/bits/local_lim.h
> +++ b/sysdeps/unix/sysv/linux/bits/local_lim.h
> @@ -78,7 +78,13 @@
> #define AIO_PRIO_DELTA_MAX 20
>
> /* Minimum size for a thread. We are free to choose a reasonable value. */
> -#define PTHREAD_STACK_MIN 16384
> +#undef PTHREAD_STACK_MIN
> +#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
> +# include <unistd.h>
> +# define PTHREAD_STACK_MIN sysconf (_SC_THREAD_STACK_MIN)
> +#else
> +# include <bits/pthread_stack_min.h>
> +#endif
>
> /* Maximum number of timer expiration overruns. */
> #define DELAYTIMER_MAX 2147483647
> diff --git a/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..7bd6fa1242
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. We are free to choose a reasonable value. */
> +#define PTHREAD_STACK_MIN 16384
> diff --git a/sysdeps/unix/sysv/linux/bits/sigstksz.h b/sysdeps/unix/sysv/linux/bits/sigstksz.h
> index 926508f2b4..cd45d122e0 100644
> --- a/sysdeps/unix/sysv/linux/bits/sigstksz.h
> +++ b/sysdeps/unix/sysv/linux/bits/sigstksz.h
> @@ -20,7 +20,7 @@
> # error "Never include <bits/sigstksz.h> directly; use <signal.h> instead."
> #endif
>
> -#if defined __USE_SC_SIGSTKSZ && __USE_SC_SIGSTKSZ
> +#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
> # include <unistd.h>
>
> /* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ). */
> diff --git a/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h b/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> deleted file mode 100644
> index 7a9f677ec8..0000000000
> --- a/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> +++ /dev/null
> @@ -1,99 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux/IA-64 version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public
> - License as published by the Free Software Foundation; either
> - version 2.1 of the License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library; if not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. We are free to choose a reasonable value. */
> -#define PTHREAD_STACK_MIN 196608
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..73581506b2
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/IA-64 version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. We are free to choose a reasonable value. */
> +#define PTHREAD_STACK_MIN 196608
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/local_lim.h b/sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> deleted file mode 100644
> index a6a0d8a980..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> +++ /dev/null
> @@ -1,99 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. MIPS Linux version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public License as
> - published by the Free Software Foundation; either version 2.1 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library. If not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. At least two pages with 64k pages. */
> -#define PTHREAD_STACK_MIN 131072
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..132f1704a5
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. MIPS Linux version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public License as
> + published by the Free Software Foundation; either version 2.1 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. At least two pages with 64k pages. */
> +#define PTHREAD_STACK_MIN 131072
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h b/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> deleted file mode 100644
> index 6caa627506..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> +++ /dev/null
> @@ -1,100 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux/PPC version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public License as
> - published by the Free Software Foundation; either version 2.1 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library; see the file COPYING.LIB. If
> - not, see <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. At least two pages for systems with 64k
> - pages. */
> -#define PTHREAD_STACK_MIN 131072
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..d7017e7b24
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> @@ -0,0 +1,21 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/PPC version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public License as
> + published by the Free Software Foundation; either version 2.1 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; see the file COPYING.LIB. If
> + not, see <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. At least two pages for systems with 64k
> + pages. */
> +#define PTHREAD_STACK_MIN 131072
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h b/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> deleted file mode 100644
> index 4a9a8c1325..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> +++ /dev/null
> @@ -1,99 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux/SPARC version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Library General Public License as
> - published by the Free Software Foundation; either version 2 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Library General Public License for more details.
> -
> - You should have received a copy of the GNU Library General Public
> - License along with the GNU C Library; see the file COPYING.LIB. If
> - not, see <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. We are free to choose a reasonable value. */
> -#define PTHREAD_STACK_MIN 24576
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..bcacedb73b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/SPARC version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Library General Public License as
> + published by the Free Software Foundation; either version 2 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Library General Public License for more details.
> +
> + You should have received a copy of the GNU Library General Public
> + License along with the GNU C Library; see the file COPYING.LIB. If
> + not, see <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. We are free to choose a reasonable value. */
> +#define PTHREAD_STACK_MIN 24576
> diff --git a/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
> new file mode 100644
> index 0000000000..9e0eb0f7fc
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
> @@ -0,0 +1,39 @@
> +/* __get_pthread_stack_min (). Linux version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Return sysconf (_SC_THREAD_STACK_MIN). */
> +
> +static inline long int
> +__get_pthread_stack_min (void)
> +{
> + /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */
> + long int pthread_stack_min = GLRO(dl_minsigstacksize);
> + assert (pthread_stack_min != 0);
> + _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
> + "PTHREAD_STACK_MIN is constant");
> + /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */
> + if (pthread_stack_min < PTHREAD_STACK_MIN)
> + pthread_stack_min = PTHREAD_STACK_MIN;
> + /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
> + which returns a larger size that includes the required TLS variable
> + space which has been determined at startup. For sysconf here we are
> + conservative and don't include the space required for TLS access.
> + Eventually the TLS variable space will not be part of the stack
> + (Bug 11787). */
> + return pthread_stack_min;
> +}
>
--
Cheers,
Carlos.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
2021-07-09 21:09 [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) H.J. Lu
2021-07-09 22:07 ` Carlos O'Donell
@ 2021-07-12 19:07 ` Maxim Kuvyrkov
2021-07-12 19:45 ` H.J. Lu
2021-07-12 19:50 ` Florian Weimer
1 sibling, 2 replies; 7+ messages in thread
From: Maxim Kuvyrkov @ 2021-07-12 19:07 UTC (permalink / raw)
To: H.J. Lu; +Cc: libc-alpha
Hi H.J.,
This breaks GCC’s libgomp build on at least aarch64-linux-gnu:
/builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/env.o: in function `initialize_env':
/snapshots/gcc.git~master/libgomp/env.c:1536: undefined reference to `sysconf'
/snapshots/gcc.git~master/libgomp/env.c:1538: undefined reference to `sysconf'
/snapshots/gcc.git~master/libgomp/env.c:1539: undefined reference to `sysconf'
/builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/proc.o: in function `gomp_init_num_threads':
/snapshots/gcc.git~master/libgomp/config/linux/proc.c:85: undefined reference to `sysconf'
/snapshots/gcc.git~master/libgomp/config/linux/proc.c:143: undefined reference to `sysconf'
/snapshots/gcc.git~master/libgomp/config/linux/proc.c:174: more undefined references to `sysconf' follow
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:728: libgomp.la] Error 1
Both GCC and Glibc are tip of trunk.
Would you please take a look? Please let me know if it doesn’t easily reproduce and I’ll take a look.
Thanks,
--
Maxim Kuvyrkov
https://www.linaro.org
> On 10 Jul 2021, at 00:09, H.J. Lu via Libc-alpha <libc-alpha@sourceware.org> wrote:
>
> The constant PTHREAD_STACK_MIN may be too small for some processors.
> Rename _SC_SIGSTKSZ_SOURCE to _DYNAMIC_STACK_SIZE_SOURCE. When
> _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined, define
> PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) which is changed
> to MIN (PTHREAD_STACK_MIN, sysconf(_SC_MINSIGSTKSZ)).
>
> Consolidate <bits/local_lim.h> with <bits/pthread_stack_min.h> to
> provide a constant target specific PTHREAD_STACK_MIN value.
> ---
> NEWS | 8 +-
> include/bits/local_lim.h | 7 ++
> include/features.h | 18 ++--
> manual/creature.texi | 4 +-
> nptl/tst-context1.c | 15 ++-
> stdlib/test-atexit-race-common.c | 11 +-
> support/support_path_support_time64.c | 1 +
> sysdeps/posix/sysconf-pthread_stack_min.h | 29 +++++
> sysdeps/posix/sysconf.c | 7 +-
> sysdeps/unix/sysv/linux/Makefile | 3 +-
> .../unix/sysv/linux/aarch64/bits/local_lim.h | 101 ------------------
> .../linux/aarch64/bits/pthread_stack_min.h | 22 ++++
> .../unix/sysv/linux/alpha/bits/local_lim.h | 99 -----------------
> .../sysv/linux/alpha/bits/pthread_stack_min.h | 20 ++++
> sysdeps/unix/sysv/linux/bits/local_lim.h | 8 +-
> .../unix/sysv/linux/bits/pthread_stack_min.h | 20 ++++
> sysdeps/unix/sysv/linux/bits/sigstksz.h | 2 +-
> sysdeps/unix/sysv/linux/ia64/bits/local_lim.h | 99 -----------------
> .../sysv/linux/ia64/bits/pthread_stack_min.h | 20 ++++
> sysdeps/unix/sysv/linux/mips/bits/local_lim.h | 99 -----------------
> .../sysv/linux/mips/bits/pthread_stack_min.h | 20 ++++
> .../unix/sysv/linux/powerpc/bits/local_lim.h | 100 -----------------
> .../linux/powerpc/bits/pthread_stack_min.h | 21 ++++
> .../unix/sysv/linux/sparc/bits/local_lim.h | 99 -----------------
> .../sysv/linux/sparc/bits/pthread_stack_min.h | 20 ++++
> .../sysv/linux/sysconf-pthread_stack_min.h | 39 +++++++
> 26 files changed, 266 insertions(+), 626 deletions(-)
> create mode 100644 include/bits/local_lim.h
> create mode 100644 sysdeps/posix/sysconf-pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> create mode 100644 sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> delete mode 100644 sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> create mode 100644 sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> create mode 100644 sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
>
> diff --git a/NEWS b/NEWS
> index 91d5f17598..13ffe627da 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -9,8 +9,12 @@ Version 2.34
>
> Major new features:
>
> -* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _SC_SIGSTKSZ_SOURCE or
> - _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
> +* When _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined,
> + PTHREAD_STACK_MIN is no longer constant and is redefined to
> + sysconf(_SC_THREAD_STACK_MIN).
> +
> +* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _DYNAMIC_STACK_SIZE_SOURCE
> + or _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
> constant on Linux. MINSIGSTKSZ is redefined to sysconf(_SC_MINSIGSTKSZ)
> and SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ).
>
> diff --git a/include/bits/local_lim.h b/include/bits/local_lim.h
> new file mode 100644
> index 0000000000..46d82dc729
> --- /dev/null
> +++ b/include/bits/local_lim.h
> @@ -0,0 +1,7 @@
> +/* Don't define PTHREAD_STACK_MIN to sysconf (_SC_THREAD_STACK_MIN) for
> + glibc build. */
> +#if !defined _ISOMAC
> +# undef __USE_DYNAMIC_STACK_SIZE
> +#endif
> +
> +#include_next <bits/local_lim.h>
> diff --git a/include/features.h b/include/features.h
> index 039bcb112b..51c8a98fb0 100644
> --- a/include/features.h
> +++ b/include/features.h
> @@ -50,8 +50,8 @@
> _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
> _FILE_OFFSET_BITS=N Select default filesystem interface.
> _ATFILE_SOURCE Additional *at interfaces.
> - _SC_SIGSTKSZ_SOURCE Select correct (but non compile-time constant)
> - MINSIGSTKSZ and SIGSTKSZ.
> + _DYNAMIC_STACK_SIZE_SOURCE Select correct (but non compile-time constant)
> + MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
> _GNU_SOURCE All of the above, plus GNU extensions.
> _DEFAULT_SOURCE The default set of features (taking precedence over
> __STRICT_ANSI__).
> @@ -98,8 +98,8 @@
> __USE_FILE_OFFSET64 Define 64bit interface as default.
> __USE_MISC Define things from 4.3BSD or System V Unix.
> __USE_ATFILE Define *at interfaces and AT_* constants for them.
> - __USE_SC_SIGSTKSZ Define correct (but non compile-time constant)
> - MINSIGSTKSZ and SIGSTKSZ.
> + __USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant)
> + MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
> __USE_GNU Define GNU extensions.
> __USE_FORTIFY_LEVEL Additional security measures used, according to level.
>
> @@ -143,7 +143,7 @@
> #undef __USE_FILE_OFFSET64
> #undef __USE_MISC
> #undef __USE_ATFILE
> -#undef __USE_SC_SIGSTKSZ
> +#undef __USE_DYNAMIC_STACK_SIZE
> #undef __USE_GNU
> #undef __USE_FORTIFY_LEVEL
> #undef __KERNEL_STRICT_NAMES
> @@ -220,8 +220,8 @@
> # define _DEFAULT_SOURCE 1
> # undef _ATFILE_SOURCE
> # define _ATFILE_SOURCE 1
> -# undef _SC_SIGSTKSZ_SOURCE
> -# define _SC_SIGSTKSZ_SOURCE 1
> +# undef _DYNAMIC_STACK_SIZE_SOURCE
> +# define _DYNAMIC_STACK_SIZE_SOURCE 1
> #endif
>
> /* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,
> @@ -399,8 +399,8 @@
> # define __USE_ATFILE 1
> #endif
>
> -#ifdef _SC_SIGSTKSZ_SOURCE
> -# define __USE_SC_SIGSTKSZ 1
> +#ifdef _DYNAMIC_STACK_SIZE_SOURCE
> +# define __USE_DYNAMIC_STACK_SIZE 1
> #endif
>
> #ifdef _GNU_SOURCE
> diff --git a/manual/creature.texi b/manual/creature.texi
> index d3c4fa4702..c13de52f1f 100644
> --- a/manual/creature.texi
> +++ b/manual/creature.texi
> @@ -308,10 +308,10 @@ checks are applied. If defined to @math{3}, @theglibc{} may also use
> checks that may have an additional performance overhead.
> @end defvr
>
> -@defvr Macro _SC_SIGSTKSZ_SOURCE
> +@defvr Macro _DYNAMIC_STACK_SIZE_SOURCE
> @standards{GNU, (none)}
> If this macro is defined, correct (but non compile-time constant)
> -MINSIGSTKSZ and SIGSTKSZ are defined.
> +MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN are defined.
> @end defvr
>
> @defvr Macro _REENTRANT
> diff --git a/nptl/tst-context1.c b/nptl/tst-context1.c
> index 821f3c2133..00e39aff9f 100644
> --- a/nptl/tst-context1.c
> +++ b/nptl/tst-context1.c
> @@ -23,6 +23,7 @@
> #include <stdio.h>
> #include <stdlib.h>
> #include <ucontext.h>
> +#include <support/support.h>
>
> #define N 4
> #if __WORDSIZE == 64
> @@ -36,7 +37,8 @@ typedef struct {
> unsigned long guard[3];
> } tst_context_t;
>
> -static char stacks[N][2 * PTHREAD_STACK_MIN];
> +static char *stacks[N];
> +static size_t stack_size;
> static tst_context_t ctx[N][2];
> static volatile int failures;
>
> @@ -79,7 +81,7 @@ fct (long int n)
> exit (1);
> }
>
> - if (on_stack < stacks[n] || on_stack >= stacks[n] + sizeof (stacks[0]))
> + if (on_stack < stacks[n] || on_stack >= stacks[n] + stack_size)
> {
> printf ("%ld: on_stack not on appropriate stack\n", n);
> exit (1);
> @@ -109,7 +111,7 @@ tf (void *arg)
> printf ("%d: %s: before makecontext\n", n, __FUNCTION__);
>
> ctx[n][1].uctx.uc_stack.ss_sp = stacks[n];
> - ctx[n][1].uctx.uc_stack.ss_size = sizeof (stacks[n]);
> + ctx[n][1].uctx.uc_stack.ss_size = stack_size;
> ctx[n][1].uctx.uc_link = &ctx[n][0].uctx;
> makecontext (&ctx[n][1].uctx, (void (*) (void)) fct, 1, (long int) n);
>
> @@ -137,6 +139,10 @@ do_test (void)
> pthread_t th[N];
> ucontext_t mctx;
>
> + stack_size = 2 * PTHREAD_STACK_MIN;
> + for (int i = 0; i < N; i++)
> + stacks[i] = xmalloc (stack_size);
> +
> puts ("making contexts");
> if (getcontext (&mctx) != 0)
> {
> @@ -198,6 +204,9 @@ do_test (void)
> exit (1);
> }
>
> + for (int i = 0; i < N; i++)
> + free (stacks[i]);
> +
> return failures;
> }
>
> diff --git a/stdlib/test-atexit-race-common.c b/stdlib/test-atexit-race-common.c
> index a2b5468580..b48bb16285 100644
> --- a/stdlib/test-atexit-race-common.c
> +++ b/stdlib/test-atexit-race-common.c
> @@ -38,11 +38,6 @@
>
> const size_t kNumThreads = 1024;
> const size_t kNumHandlers = 1024;
> -const size_t kStacksize =
> -#ifdef PTHREAD_STACK_MIN
> - 0x20000 < PTHREAD_STACK_MIN ? PTHREAD_STACK_MIN :
> -#endif
> - 0x20000;
>
> static void *
> threadfunc (void *unused)
> @@ -66,6 +61,12 @@ do_test (void)
> /* With default 8MiB Linux stack size, creating 1024 threads can cause
> VM exhausiton on 32-bit machines. Reduce stack size of each thread to
> 128KiB for a maximum required VM size of 128MiB. */
> + size_t kStacksize =
> +#ifdef PTHREAD_STACK_MIN
> + 0x20000 < PTHREAD_STACK_MIN ? PTHREAD_STACK_MIN :
> +#endif
> + 0x20000;
> +
> xpthread_attr_setstacksize (&attr, kStacksize);
>
> for (i = 0; i < kNumThreads; ++i) {
> diff --git a/support/support_path_support_time64.c b/support/support_path_support_time64.c
> index 33b2bdff66..619a4eab00 100644
> --- a/support/support_path_support_time64.c
> +++ b/support/support_path_support_time64.c
> @@ -17,6 +17,7 @@
> <https://www.gnu.org/licenses/>. */
>
> #include <fcntl.h>
> +#include <unistd.h>
> #include <support/check.h>
> #include <support/support.h>
> #include <sys/stat.h>
> diff --git a/sysdeps/posix/sysconf-pthread_stack_min.h b/sysdeps/posix/sysconf-pthread_stack_min.h
> new file mode 100644
> index 0000000000..f5be2e6f9f
> --- /dev/null
> +++ b/sysdeps/posix/sysconf-pthread_stack_min.h
> @@ -0,0 +1,29 @@
> +/* __get_pthread_stack_min (). POSIX version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Return sysconf (_SC_THREAD_STACK_MIN). */
> +
> +static inline long int
> +__get_pthread_stack_min (void)
> +{
> +#ifdef PTHREAD_STACK_MIN
> + return PTHREAD_STACK_MIN;
> +#else
> + return -1;
> +#endif
> +}
> diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
> index 3e8ec5cd51..5fb3fb6c1c 100644
> --- a/sysdeps/posix/sysconf.c
> +++ b/sysdeps/posix/sysconf.c
> @@ -31,6 +31,7 @@
> #include <sys/types.h>
> #include <sys/uio.h>
> #include <regex.h>
> +#include <sysconf-pthread_stack_min.h>
>
> #define NEED_SPEC_ARRAY 0
> #include <posix-conf-vars.h>
> @@ -569,11 +570,7 @@ __sysconf (int name)
> #endif
>
> case _SC_THREAD_STACK_MIN:
> -#ifdef PTHREAD_STACK_MIN
> - return PTHREAD_STACK_MIN;
> -#else
> - return -1;
> -#endif
> + return __get_pthread_stack_min ();
>
> case _SC_THREAD_THREADS_MAX:
> #ifdef PTHREAD_THREADS_MAX
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index d45a16af8b..7d43dc95f2 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -108,7 +108,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
> bits/types/struct_semid64_ds.h \
> bits/types/struct_semid64_ds_helper.h \
> bits/types/struct_shmid64_ds.h \
> - bits/types/struct_shmid64_ds_helper.h
> + bits/types/struct_shmid64_ds_helper.h \
> + bits/pthread_stack_min.h
>
> tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
> tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
> diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h b/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> deleted file mode 100644
> index 0652bf4a06..0000000000
> --- a/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> +++ /dev/null
> @@ -1,101 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> -
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public License as
> - published by the Free Software Foundation; either version 2.1 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library. If not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. At least two pages for systems with 64k
> - pages. */
> -#define PTHREAD_STACK_MIN 131072
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..97215687ad
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> @@ -0,0 +1,22 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/aarch64 version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> +
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public License as
> + published by the Free Software Foundation; either version 2.1 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. At least two pages for systems with 64k
> + pages. */
> +#define PTHREAD_STACK_MIN 131072
> diff --git a/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h b/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> deleted file mode 100644
> index 523407dc48..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> +++ /dev/null
> @@ -1,99 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux/Alpha version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Library General Public License as
> - published by the Free Software Foundation; either version 2 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Library General Public License for more details.
> -
> - You should have received a copy of the GNU Library General Public
> - License along with the GNU C Library. If not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. We are free to choose a reasonable value. */
> -#define PTHREAD_STACK_MIN 24576
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..5bfb0e10dd
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/Alpha version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Library General Public License as
> + published by the Free Software Foundation; either version 2 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Library General Public License for more details.
> +
> + You should have received a copy of the GNU Library General Public
> + License along with the GNU C Library. If not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. We are free to choose a reasonable value. */
> +#define PTHREAD_STACK_MIN 24576
> diff --git a/sysdeps/unix/sysv/linux/bits/local_lim.h b/sysdeps/unix/sysv/linux/bits/local_lim.h
> index b88ca3d4d2..0b1c7f40be 100644
> --- a/sysdeps/unix/sysv/linux/bits/local_lim.h
> +++ b/sysdeps/unix/sysv/linux/bits/local_lim.h
> @@ -78,7 +78,13 @@
> #define AIO_PRIO_DELTA_MAX 20
>
> /* Minimum size for a thread. We are free to choose a reasonable value. */
> -#define PTHREAD_STACK_MIN 16384
> +#undef PTHREAD_STACK_MIN
> +#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
> +# include <unistd.h>
> +# define PTHREAD_STACK_MIN sysconf (_SC_THREAD_STACK_MIN)
> +#else
> +# include <bits/pthread_stack_min.h>
> +#endif
>
> /* Maximum number of timer expiration overruns. */
> #define DELAYTIMER_MAX 2147483647
> diff --git a/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..7bd6fa1242
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. We are free to choose a reasonable value. */
> +#define PTHREAD_STACK_MIN 16384
> diff --git a/sysdeps/unix/sysv/linux/bits/sigstksz.h b/sysdeps/unix/sysv/linux/bits/sigstksz.h
> index 926508f2b4..cd45d122e0 100644
> --- a/sysdeps/unix/sysv/linux/bits/sigstksz.h
> +++ b/sysdeps/unix/sysv/linux/bits/sigstksz.h
> @@ -20,7 +20,7 @@
> # error "Never include <bits/sigstksz.h> directly; use <signal.h> instead."
> #endif
>
> -#if defined __USE_SC_SIGSTKSZ && __USE_SC_SIGSTKSZ
> +#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
> # include <unistd.h>
>
> /* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ). */
> diff --git a/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h b/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> deleted file mode 100644
> index 7a9f677ec8..0000000000
> --- a/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> +++ /dev/null
> @@ -1,99 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux/IA-64 version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public
> - License as published by the Free Software Foundation; either
> - version 2.1 of the License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library; if not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. We are free to choose a reasonable value. */
> -#define PTHREAD_STACK_MIN 196608
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..73581506b2
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/IA-64 version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. We are free to choose a reasonable value. */
> +#define PTHREAD_STACK_MIN 196608
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/local_lim.h b/sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> deleted file mode 100644
> index a6a0d8a980..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> +++ /dev/null
> @@ -1,99 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. MIPS Linux version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public License as
> - published by the Free Software Foundation; either version 2.1 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library. If not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. At least two pages with 64k pages. */
> -#define PTHREAD_STACK_MIN 131072
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..132f1704a5
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. MIPS Linux version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public License as
> + published by the Free Software Foundation; either version 2.1 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. At least two pages with 64k pages. */
> +#define PTHREAD_STACK_MIN 131072
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h b/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> deleted file mode 100644
> index 6caa627506..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> +++ /dev/null
> @@ -1,100 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux/PPC version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public License as
> - published by the Free Software Foundation; either version 2.1 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library; see the file COPYING.LIB. If
> - not, see <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. At least two pages for systems with 64k
> - pages. */
> -#define PTHREAD_STACK_MIN 131072
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..d7017e7b24
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> @@ -0,0 +1,21 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/PPC version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public License as
> + published by the Free Software Foundation; either version 2.1 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; see the file COPYING.LIB. If
> + not, see <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. At least two pages for systems with 64k
> + pages. */
> +#define PTHREAD_STACK_MIN 131072
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h b/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> deleted file mode 100644
> index 4a9a8c1325..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> +++ /dev/null
> @@ -1,99 +0,0 @@
> -/* Minimum guaranteed maximum values for system limits. Linux/SPARC version.
> - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Library General Public License as
> - published by the Free Software Foundation; either version 2 of the
> - License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Library General Public License for more details.
> -
> - You should have received a copy of the GNU Library General Public
> - License along with the GNU C Library; see the file COPYING.LIB. If
> - not, see <https://www.gnu.org/licenses/>. */
> -
> -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> - and defines LINK_MAX although filesystems have different maxima. A
> - similar thing is true for OPEN_MAX: the limit can be changed at
> - runtime and therefore the macro must not be defined. Remove this
> - after including the header if necessary. */
> -#ifndef NR_OPEN
> -# define __undef_NR_OPEN
> -#endif
> -#ifndef LINK_MAX
> -# define __undef_LINK_MAX
> -#endif
> -#ifndef OPEN_MAX
> -# define __undef_OPEN_MAX
> -#endif
> -#ifndef ARG_MAX
> -# define __undef_ARG_MAX
> -#endif
> -
> -/* The kernel sources contain a file with all the needed information. */
> -#include <linux/limits.h>
> -
> -/* Have to remove NR_OPEN? */
> -#ifdef __undef_NR_OPEN
> -# undef NR_OPEN
> -# undef __undef_NR_OPEN
> -#endif
> -/* Have to remove LINK_MAX? */
> -#ifdef __undef_LINK_MAX
> -# undef LINK_MAX
> -# undef __undef_LINK_MAX
> -#endif
> -/* Have to remove OPEN_MAX? */
> -#ifdef __undef_OPEN_MAX
> -# undef OPEN_MAX
> -# undef __undef_OPEN_MAX
> -#endif
> -/* Have to remove ARG_MAX? */
> -#ifdef __undef_ARG_MAX
> -# undef ARG_MAX
> -# undef __undef_ARG_MAX
> -#endif
> -
> -/* The number of data keys per process. */
> -#define _POSIX_THREAD_KEYS_MAX 128
> -/* This is the value this implementation supports. */
> -#define PTHREAD_KEYS_MAX 1024
> -
> -/* Controlling the iterations of destructors for thread-specific data. */
> -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> -/* Number of iterations this implementation does. */
> -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> -
> -/* The number of threads per process. */
> -#define _POSIX_THREAD_THREADS_MAX 64
> -/* We have no predefined limit on the number of threads. */
> -#undef PTHREAD_THREADS_MAX
> -
> -/* Maximum amount by which a process can descrease its asynchronous I/O
> - priority level. */
> -#define AIO_PRIO_DELTA_MAX 20
> -
> -/* Minimum size for a thread. We are free to choose a reasonable value. */
> -#define PTHREAD_STACK_MIN 24576
> -
> -/* Maximum number of timer expiration overruns. */
> -#define DELAYTIMER_MAX 2147483647
> -
> -/* Maximum tty name length. */
> -#define TTY_NAME_MAX 32
> -
> -/* Maximum login name length. This is arbitrary. */
> -#define LOGIN_NAME_MAX 256
> -
> -/* Maximum host name length. */
> -#define HOST_NAME_MAX 64
> -
> -/* Maximum message queue priority level. */
> -#define MQ_PRIO_MAX 32768
> -
> -/* Maximum value the semaphore can have. */
> -#define SEM_VALUE_MAX (2147483647)
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> new file mode 100644
> index 0000000000..bcacedb73b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> @@ -0,0 +1,20 @@
> +/* Definition of PTHREAD_STACK_MIN. Linux/SPARC version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Library General Public License as
> + published by the Free Software Foundation; either version 2 of the
> + License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Library General Public License for more details.
> +
> + You should have received a copy of the GNU Library General Public
> + License along with the GNU C Library; see the file COPYING.LIB. If
> + not, see <https://www.gnu.org/licenses/>. */
> +
> +/* Minimum size for a thread. We are free to choose a reasonable value. */
> +#define PTHREAD_STACK_MIN 24576
> diff --git a/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
> new file mode 100644
> index 0000000000..9e0eb0f7fc
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
> @@ -0,0 +1,39 @@
> +/* __get_pthread_stack_min (). Linux version.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +/* Return sysconf (_SC_THREAD_STACK_MIN). */
> +
> +static inline long int
> +__get_pthread_stack_min (void)
> +{
> + /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */
> + long int pthread_stack_min = GLRO(dl_minsigstacksize);
> + assert (pthread_stack_min != 0);
> + _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
> + "PTHREAD_STACK_MIN is constant");
> + /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */
> + if (pthread_stack_min < PTHREAD_STACK_MIN)
> + pthread_stack_min = PTHREAD_STACK_MIN;
> + /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
> + which returns a larger size that includes the required TLS variable
> + space which has been determined at startup. For sysconf here we are
> + conservative and don't include the space required for TLS access.
> + Eventually the TLS variable space will not be part of the stack
> + (Bug 11787). */
> + return pthread_stack_min;
> +}
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
2021-07-12 19:07 ` Maxim Kuvyrkov
@ 2021-07-12 19:45 ` H.J. Lu
2021-07-12 19:50 ` Florian Weimer
1 sibling, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2021-07-12 19:45 UTC (permalink / raw)
To: Maxim Kuvyrkov; +Cc: GNU C Library
On Mon, Jul 12, 2021 at 12:05 PM Maxim Kuvyrkov
<maxim.kuvyrkov@linaro.org> wrote:
>
> Hi H.J.,
>
> This breaks GCC’s libgomp build on at least aarch64-linux-gnu:
>
> /builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/env.o: in function `initialize_env':
> /snapshots/gcc.git~master/libgomp/env.c:1536: undefined reference to `sysconf'
> /snapshots/gcc.git~master/libgomp/env.c:1538: undefined reference to `sysconf'
> /snapshots/gcc.git~master/libgomp/env.c:1539: undefined reference to `sysconf'
> /builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/proc.o: in function `gomp_init_num_threads':
> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:85: undefined reference to `sysconf'
> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:143: undefined reference to `sysconf'
> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:174: more undefined references to `sysconf' follow
> collect2: error: ld returned 1 exit status
> make[4]: *** [Makefile:728: libgomp.la] Error 1
>
> Both GCC and Glibc are tip of trunk.
>
> Would you please take a look? Please let me know if it doesn’t easily reproduce and I’ll take a look.
Known issue. Several patches, glibc and GCC, have been proposed, including:
commit aaacde11f2e814814fdd19dfb683e76f1dede4d5
Author: Florian Weimer <fweimer@redhat.com>
Date: Mon Jul 12 18:43:32 2021 +0200
Reduce <limits.h> pollution due to dynamic PTHREAD_STACK_MIN
> Thanks,
>
> --
> Maxim Kuvyrkov
> https://www.linaro.org
>
> > On 10 Jul 2021, at 00:09, H.J. Lu via Libc-alpha <libc-alpha@sourceware.org> wrote:
> >
> > The constant PTHREAD_STACK_MIN may be too small for some processors.
> > Rename _SC_SIGSTKSZ_SOURCE to _DYNAMIC_STACK_SIZE_SOURCE. When
> > _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined, define
> > PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) which is changed
> > to MIN (PTHREAD_STACK_MIN, sysconf(_SC_MINSIGSTKSZ)).
> >
> > Consolidate <bits/local_lim.h> with <bits/pthread_stack_min.h> to
> > provide a constant target specific PTHREAD_STACK_MIN value.
> > ---
> > NEWS | 8 +-
> > include/bits/local_lim.h | 7 ++
> > include/features.h | 18 ++--
> > manual/creature.texi | 4 +-
> > nptl/tst-context1.c | 15 ++-
> > stdlib/test-atexit-race-common.c | 11 +-
> > support/support_path_support_time64.c | 1 +
> > sysdeps/posix/sysconf-pthread_stack_min.h | 29 +++++
> > sysdeps/posix/sysconf.c | 7 +-
> > sysdeps/unix/sysv/linux/Makefile | 3 +-
> > .../unix/sysv/linux/aarch64/bits/local_lim.h | 101 ------------------
> > .../linux/aarch64/bits/pthread_stack_min.h | 22 ++++
> > .../unix/sysv/linux/alpha/bits/local_lim.h | 99 -----------------
> > .../sysv/linux/alpha/bits/pthread_stack_min.h | 20 ++++
> > sysdeps/unix/sysv/linux/bits/local_lim.h | 8 +-
> > .../unix/sysv/linux/bits/pthread_stack_min.h | 20 ++++
> > sysdeps/unix/sysv/linux/bits/sigstksz.h | 2 +-
> > sysdeps/unix/sysv/linux/ia64/bits/local_lim.h | 99 -----------------
> > .../sysv/linux/ia64/bits/pthread_stack_min.h | 20 ++++
> > sysdeps/unix/sysv/linux/mips/bits/local_lim.h | 99 -----------------
> > .../sysv/linux/mips/bits/pthread_stack_min.h | 20 ++++
> > .../unix/sysv/linux/powerpc/bits/local_lim.h | 100 -----------------
> > .../linux/powerpc/bits/pthread_stack_min.h | 21 ++++
> > .../unix/sysv/linux/sparc/bits/local_lim.h | 99 -----------------
> > .../sysv/linux/sparc/bits/pthread_stack_min.h | 20 ++++
> > .../sysv/linux/sysconf-pthread_stack_min.h | 39 +++++++
> > 26 files changed, 266 insertions(+), 626 deletions(-)
> > create mode 100644 include/bits/local_lim.h
> > create mode 100644 sysdeps/posix/sysconf-pthread_stack_min.h
> > delete mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> > create mode 100644 sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> > delete mode 100644 sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> > create mode 100644 sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> > create mode 100644 sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> > delete mode 100644 sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> > create mode 100644 sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> > delete mode 100644 sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> > create mode 100644 sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> > delete mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> > create mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> > delete mode 100644 sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> > create mode 100644 sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> > create mode 100644 sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
> >
> > diff --git a/NEWS b/NEWS
> > index 91d5f17598..13ffe627da 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -9,8 +9,12 @@ Version 2.34
> >
> > Major new features:
> >
> > -* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _SC_SIGSTKSZ_SOURCE or
> > - _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
> > +* When _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined,
> > + PTHREAD_STACK_MIN is no longer constant and is redefined to
> > + sysconf(_SC_THREAD_STACK_MIN).
> > +
> > +* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _DYNAMIC_STACK_SIZE_SOURCE
> > + or _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer
> > constant on Linux. MINSIGSTKSZ is redefined to sysconf(_SC_MINSIGSTKSZ)
> > and SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ).
> >
> > diff --git a/include/bits/local_lim.h b/include/bits/local_lim.h
> > new file mode 100644
> > index 0000000000..46d82dc729
> > --- /dev/null
> > +++ b/include/bits/local_lim.h
> > @@ -0,0 +1,7 @@
> > +/* Don't define PTHREAD_STACK_MIN to sysconf (_SC_THREAD_STACK_MIN) for
> > + glibc build. */
> > +#if !defined _ISOMAC
> > +# undef __USE_DYNAMIC_STACK_SIZE
> > +#endif
> > +
> > +#include_next <bits/local_lim.h>
> > diff --git a/include/features.h b/include/features.h
> > index 039bcb112b..51c8a98fb0 100644
> > --- a/include/features.h
> > +++ b/include/features.h
> > @@ -50,8 +50,8 @@
> > _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
> > _FILE_OFFSET_BITS=N Select default filesystem interface.
> > _ATFILE_SOURCE Additional *at interfaces.
> > - _SC_SIGSTKSZ_SOURCE Select correct (but non compile-time constant)
> > - MINSIGSTKSZ and SIGSTKSZ.
> > + _DYNAMIC_STACK_SIZE_SOURCE Select correct (but non compile-time constant)
> > + MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
> > _GNU_SOURCE All of the above, plus GNU extensions.
> > _DEFAULT_SOURCE The default set of features (taking precedence over
> > __STRICT_ANSI__).
> > @@ -98,8 +98,8 @@
> > __USE_FILE_OFFSET64 Define 64bit interface as default.
> > __USE_MISC Define things from 4.3BSD or System V Unix.
> > __USE_ATFILE Define *at interfaces and AT_* constants for them.
> > - __USE_SC_SIGSTKSZ Define correct (but non compile-time constant)
> > - MINSIGSTKSZ and SIGSTKSZ.
> > + __USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant)
> > + MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
> > __USE_GNU Define GNU extensions.
> > __USE_FORTIFY_LEVEL Additional security measures used, according to level.
> >
> > @@ -143,7 +143,7 @@
> > #undef __USE_FILE_OFFSET64
> > #undef __USE_MISC
> > #undef __USE_ATFILE
> > -#undef __USE_SC_SIGSTKSZ
> > +#undef __USE_DYNAMIC_STACK_SIZE
> > #undef __USE_GNU
> > #undef __USE_FORTIFY_LEVEL
> > #undef __KERNEL_STRICT_NAMES
> > @@ -220,8 +220,8 @@
> > # define _DEFAULT_SOURCE 1
> > # undef _ATFILE_SOURCE
> > # define _ATFILE_SOURCE 1
> > -# undef _SC_SIGSTKSZ_SOURCE
> > -# define _SC_SIGSTKSZ_SOURCE 1
> > +# undef _DYNAMIC_STACK_SIZE_SOURCE
> > +# define _DYNAMIC_STACK_SIZE_SOURCE 1
> > #endif
> >
> > /* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,
> > @@ -399,8 +399,8 @@
> > # define __USE_ATFILE 1
> > #endif
> >
> > -#ifdef _SC_SIGSTKSZ_SOURCE
> > -# define __USE_SC_SIGSTKSZ 1
> > +#ifdef _DYNAMIC_STACK_SIZE_SOURCE
> > +# define __USE_DYNAMIC_STACK_SIZE 1
> > #endif
> >
> > #ifdef _GNU_SOURCE
> > diff --git a/manual/creature.texi b/manual/creature.texi
> > index d3c4fa4702..c13de52f1f 100644
> > --- a/manual/creature.texi
> > +++ b/manual/creature.texi
> > @@ -308,10 +308,10 @@ checks are applied. If defined to @math{3}, @theglibc{} may also use
> > checks that may have an additional performance overhead.
> > @end defvr
> >
> > -@defvr Macro _SC_SIGSTKSZ_SOURCE
> > +@defvr Macro _DYNAMIC_STACK_SIZE_SOURCE
> > @standards{GNU, (none)}
> > If this macro is defined, correct (but non compile-time constant)
> > -MINSIGSTKSZ and SIGSTKSZ are defined.
> > +MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN are defined.
> > @end defvr
> >
> > @defvr Macro _REENTRANT
> > diff --git a/nptl/tst-context1.c b/nptl/tst-context1.c
> > index 821f3c2133..00e39aff9f 100644
> > --- a/nptl/tst-context1.c
> > +++ b/nptl/tst-context1.c
> > @@ -23,6 +23,7 @@
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <ucontext.h>
> > +#include <support/support.h>
> >
> > #define N 4
> > #if __WORDSIZE == 64
> > @@ -36,7 +37,8 @@ typedef struct {
> > unsigned long guard[3];
> > } tst_context_t;
> >
> > -static char stacks[N][2 * PTHREAD_STACK_MIN];
> > +static char *stacks[N];
> > +static size_t stack_size;
> > static tst_context_t ctx[N][2];
> > static volatile int failures;
> >
> > @@ -79,7 +81,7 @@ fct (long int n)
> > exit (1);
> > }
> >
> > - if (on_stack < stacks[n] || on_stack >= stacks[n] + sizeof (stacks[0]))
> > + if (on_stack < stacks[n] || on_stack >= stacks[n] + stack_size)
> > {
> > printf ("%ld: on_stack not on appropriate stack\n", n);
> > exit (1);
> > @@ -109,7 +111,7 @@ tf (void *arg)
> > printf ("%d: %s: before makecontext\n", n, __FUNCTION__);
> >
> > ctx[n][1].uctx.uc_stack.ss_sp = stacks[n];
> > - ctx[n][1].uctx.uc_stack.ss_size = sizeof (stacks[n]);
> > + ctx[n][1].uctx.uc_stack.ss_size = stack_size;
> > ctx[n][1].uctx.uc_link = &ctx[n][0].uctx;
> > makecontext (&ctx[n][1].uctx, (void (*) (void)) fct, 1, (long int) n);
> >
> > @@ -137,6 +139,10 @@ do_test (void)
> > pthread_t th[N];
> > ucontext_t mctx;
> >
> > + stack_size = 2 * PTHREAD_STACK_MIN;
> > + for (int i = 0; i < N; i++)
> > + stacks[i] = xmalloc (stack_size);
> > +
> > puts ("making contexts");
> > if (getcontext (&mctx) != 0)
> > {
> > @@ -198,6 +204,9 @@ do_test (void)
> > exit (1);
> > }
> >
> > + for (int i = 0; i < N; i++)
> > + free (stacks[i]);
> > +
> > return failures;
> > }
> >
> > diff --git a/stdlib/test-atexit-race-common.c b/stdlib/test-atexit-race-common.c
> > index a2b5468580..b48bb16285 100644
> > --- a/stdlib/test-atexit-race-common.c
> > +++ b/stdlib/test-atexit-race-common.c
> > @@ -38,11 +38,6 @@
> >
> > const size_t kNumThreads = 1024;
> > const size_t kNumHandlers = 1024;
> > -const size_t kStacksize =
> > -#ifdef PTHREAD_STACK_MIN
> > - 0x20000 < PTHREAD_STACK_MIN ? PTHREAD_STACK_MIN :
> > -#endif
> > - 0x20000;
> >
> > static void *
> > threadfunc (void *unused)
> > @@ -66,6 +61,12 @@ do_test (void)
> > /* With default 8MiB Linux stack size, creating 1024 threads can cause
> > VM exhausiton on 32-bit machines. Reduce stack size of each thread to
> > 128KiB for a maximum required VM size of 128MiB. */
> > + size_t kStacksize =
> > +#ifdef PTHREAD_STACK_MIN
> > + 0x20000 < PTHREAD_STACK_MIN ? PTHREAD_STACK_MIN :
> > +#endif
> > + 0x20000;
> > +
> > xpthread_attr_setstacksize (&attr, kStacksize);
> >
> > for (i = 0; i < kNumThreads; ++i) {
> > diff --git a/support/support_path_support_time64.c b/support/support_path_support_time64.c
> > index 33b2bdff66..619a4eab00 100644
> > --- a/support/support_path_support_time64.c
> > +++ b/support/support_path_support_time64.c
> > @@ -17,6 +17,7 @@
> > <https://www.gnu.org/licenses/>. */
> >
> > #include <fcntl.h>
> > +#include <unistd.h>
> > #include <support/check.h>
> > #include <support/support.h>
> > #include <sys/stat.h>
> > diff --git a/sysdeps/posix/sysconf-pthread_stack_min.h b/sysdeps/posix/sysconf-pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..f5be2e6f9f
> > --- /dev/null
> > +++ b/sysdeps/posix/sysconf-pthread_stack_min.h
> > @@ -0,0 +1,29 @@
> > +/* __get_pthread_stack_min (). POSIX version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Lesser General Public
> > + License as published by the Free Software Foundation; either
> > + version 2.1 of the License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Lesser General Public License for more details.
> > +
> > + You should have received a copy of the GNU Lesser General Public
> > + License along with the GNU C Library; if not, see
> > + <https://www.gnu.org/licenses/>. */
> > +
> > +/* Return sysconf (_SC_THREAD_STACK_MIN). */
> > +
> > +static inline long int
> > +__get_pthread_stack_min (void)
> > +{
> > +#ifdef PTHREAD_STACK_MIN
> > + return PTHREAD_STACK_MIN;
> > +#else
> > + return -1;
> > +#endif
> > +}
> > diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
> > index 3e8ec5cd51..5fb3fb6c1c 100644
> > --- a/sysdeps/posix/sysconf.c
> > +++ b/sysdeps/posix/sysconf.c
> > @@ -31,6 +31,7 @@
> > #include <sys/types.h>
> > #include <sys/uio.h>
> > #include <regex.h>
> > +#include <sysconf-pthread_stack_min.h>
> >
> > #define NEED_SPEC_ARRAY 0
> > #include <posix-conf-vars.h>
> > @@ -569,11 +570,7 @@ __sysconf (int name)
> > #endif
> >
> > case _SC_THREAD_STACK_MIN:
> > -#ifdef PTHREAD_STACK_MIN
> > - return PTHREAD_STACK_MIN;
> > -#else
> > - return -1;
> > -#endif
> > + return __get_pthread_stack_min ();
> >
> > case _SC_THREAD_THREADS_MAX:
> > #ifdef PTHREAD_THREADS_MAX
> > diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> > index d45a16af8b..7d43dc95f2 100644
> > --- a/sysdeps/unix/sysv/linux/Makefile
> > +++ b/sysdeps/unix/sysv/linux/Makefile
> > @@ -108,7 +108,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
> > bits/types/struct_semid64_ds.h \
> > bits/types/struct_semid64_ds_helper.h \
> > bits/types/struct_shmid64_ds.h \
> > - bits/types/struct_shmid64_ds_helper.h
> > + bits/types/struct_shmid64_ds_helper.h \
> > + bits/pthread_stack_min.h
> >
> > tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
> > tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
> > diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h b/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> > deleted file mode 100644
> > index 0652bf4a06..0000000000
> > --- a/sysdeps/unix/sysv/linux/aarch64/bits/local_lim.h
> > +++ /dev/null
> > @@ -1,101 +0,0 @@
> > -/* Minimum guaranteed maximum values for system limits. Linux version.
> > - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> > -
> > - This file is part of the GNU C Library.
> > -
> > - The GNU C Library is free software; you can redistribute it and/or
> > - modify it under the terms of the GNU Lesser General Public License as
> > - published by the Free Software Foundation; either version 2.1 of the
> > - License, or (at your option) any later version.
> > -
> > - The GNU C Library is distributed in the hope that it will be useful,
> > - but WITHOUT ANY WARRANTY; without even the implied warranty of
> > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > - Lesser General Public License for more details.
> > -
> > - You should have received a copy of the GNU Lesser General Public
> > - License along with the GNU C Library. If not, see
> > - <https://www.gnu.org/licenses/>. */
> > -
> > -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> > - and defines LINK_MAX although filesystems have different maxima. A
> > - similar thing is true for OPEN_MAX: the limit can be changed at
> > - runtime and therefore the macro must not be defined. Remove this
> > - after including the header if necessary. */
> > -#ifndef NR_OPEN
> > -# define __undef_NR_OPEN
> > -#endif
> > -#ifndef LINK_MAX
> > -# define __undef_LINK_MAX
> > -#endif
> > -#ifndef OPEN_MAX
> > -# define __undef_OPEN_MAX
> > -#endif
> > -#ifndef ARG_MAX
> > -# define __undef_ARG_MAX
> > -#endif
> > -
> > -/* The kernel sources contain a file with all the needed information. */
> > -#include <linux/limits.h>
> > -
> > -/* Have to remove NR_OPEN? */
> > -#ifdef __undef_NR_OPEN
> > -# undef NR_OPEN
> > -# undef __undef_NR_OPEN
> > -#endif
> > -/* Have to remove LINK_MAX? */
> > -#ifdef __undef_LINK_MAX
> > -# undef LINK_MAX
> > -# undef __undef_LINK_MAX
> > -#endif
> > -/* Have to remove OPEN_MAX? */
> > -#ifdef __undef_OPEN_MAX
> > -# undef OPEN_MAX
> > -# undef __undef_OPEN_MAX
> > -#endif
> > -/* Have to remove ARG_MAX? */
> > -#ifdef __undef_ARG_MAX
> > -# undef ARG_MAX
> > -# undef __undef_ARG_MAX
> > -#endif
> > -
> > -/* The number of data keys per process. */
> > -#define _POSIX_THREAD_KEYS_MAX 128
> > -/* This is the value this implementation supports. */
> > -#define PTHREAD_KEYS_MAX 1024
> > -
> > -/* Controlling the iterations of destructors for thread-specific data. */
> > -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> > -/* Number of iterations this implementation does. */
> > -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> > -
> > -/* The number of threads per process. */
> > -#define _POSIX_THREAD_THREADS_MAX 64
> > -/* We have no predefined limit on the number of threads. */
> > -#undef PTHREAD_THREADS_MAX
> > -
> > -/* Maximum amount by which a process can descrease its asynchronous I/O
> > - priority level. */
> > -#define AIO_PRIO_DELTA_MAX 20
> > -
> > -/* Minimum size for a thread. At least two pages for systems with 64k
> > - pages. */
> > -#define PTHREAD_STACK_MIN 131072
> > -
> > -/* Maximum number of timer expiration overruns. */
> > -#define DELAYTIMER_MAX 2147483647
> > -
> > -/* Maximum tty name length. */
> > -#define TTY_NAME_MAX 32
> > -
> > -/* Maximum login name length. This is arbitrary. */
> > -#define LOGIN_NAME_MAX 256
> > -
> > -/* Maximum host name length. */
> > -#define HOST_NAME_MAX 64
> > -
> > -/* Maximum message queue priority level. */
> > -#define MQ_PRIO_MAX 32768
> > -
> > -/* Maximum value the semaphore can have. */
> > -#define SEM_VALUE_MAX (2147483647)
> > diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..97215687ad
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/aarch64/bits/pthread_stack_min.h
> > @@ -0,0 +1,22 @@
> > +/* Definition of PTHREAD_STACK_MIN. Linux/aarch64 version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > +
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Lesser General Public License as
> > + published by the Free Software Foundation; either version 2.1 of the
> > + License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Lesser General Public License for more details.
> > +
> > + You should have received a copy of the GNU Lesser General Public
> > + License along with the GNU C Library. If not, see
> > + <https://www.gnu.org/licenses/>. */
> > +
> > +/* Minimum size for a thread. At least two pages for systems with 64k
> > + pages. */
> > +#define PTHREAD_STACK_MIN 131072
> > diff --git a/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h b/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> > deleted file mode 100644
> > index 523407dc48..0000000000
> > --- a/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
> > +++ /dev/null
> > @@ -1,99 +0,0 @@
> > -/* Minimum guaranteed maximum values for system limits. Linux/Alpha version.
> > - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> > - This file is part of the GNU C Library.
> > -
> > - The GNU C Library is free software; you can redistribute it and/or
> > - modify it under the terms of the GNU Library General Public License as
> > - published by the Free Software Foundation; either version 2 of the
> > - License, or (at your option) any later version.
> > -
> > - The GNU C Library is distributed in the hope that it will be useful,
> > - but WITHOUT ANY WARRANTY; without even the implied warranty of
> > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > - Library General Public License for more details.
> > -
> > - You should have received a copy of the GNU Library General Public
> > - License along with the GNU C Library. If not, see
> > - <https://www.gnu.org/licenses/>. */
> > -
> > -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> > - and defines LINK_MAX although filesystems have different maxima. A
> > - similar thing is true for OPEN_MAX: the limit can be changed at
> > - runtime and therefore the macro must not be defined. Remove this
> > - after including the header if necessary. */
> > -#ifndef NR_OPEN
> > -# define __undef_NR_OPEN
> > -#endif
> > -#ifndef LINK_MAX
> > -# define __undef_LINK_MAX
> > -#endif
> > -#ifndef OPEN_MAX
> > -# define __undef_OPEN_MAX
> > -#endif
> > -#ifndef ARG_MAX
> > -# define __undef_ARG_MAX
> > -#endif
> > -
> > -/* The kernel sources contain a file with all the needed information. */
> > -#include <linux/limits.h>
> > -
> > -/* Have to remove NR_OPEN? */
> > -#ifdef __undef_NR_OPEN
> > -# undef NR_OPEN
> > -# undef __undef_NR_OPEN
> > -#endif
> > -/* Have to remove LINK_MAX? */
> > -#ifdef __undef_LINK_MAX
> > -# undef LINK_MAX
> > -# undef __undef_LINK_MAX
> > -#endif
> > -/* Have to remove OPEN_MAX? */
> > -#ifdef __undef_OPEN_MAX
> > -# undef OPEN_MAX
> > -# undef __undef_OPEN_MAX
> > -#endif
> > -/* Have to remove ARG_MAX? */
> > -#ifdef __undef_ARG_MAX
> > -# undef ARG_MAX
> > -# undef __undef_ARG_MAX
> > -#endif
> > -
> > -/* The number of data keys per process. */
> > -#define _POSIX_THREAD_KEYS_MAX 128
> > -/* This is the value this implementation supports. */
> > -#define PTHREAD_KEYS_MAX 1024
> > -
> > -/* Controlling the iterations of destructors for thread-specific data. */
> > -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> > -/* Number of iterations this implementation does. */
> > -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> > -
> > -/* The number of threads per process. */
> > -#define _POSIX_THREAD_THREADS_MAX 64
> > -/* We have no predefined limit on the number of threads. */
> > -#undef PTHREAD_THREADS_MAX
> > -
> > -/* Maximum amount by which a process can descrease its asynchronous I/O
> > - priority level. */
> > -#define AIO_PRIO_DELTA_MAX 20
> > -
> > -/* Minimum size for a thread. We are free to choose a reasonable value. */
> > -#define PTHREAD_STACK_MIN 24576
> > -
> > -/* Maximum number of timer expiration overruns. */
> > -#define DELAYTIMER_MAX 2147483647
> > -
> > -/* Maximum tty name length. */
> > -#define TTY_NAME_MAX 32
> > -
> > -/* Maximum login name length. This is arbitrary. */
> > -#define LOGIN_NAME_MAX 256
> > -
> > -/* Maximum host name length. */
> > -#define HOST_NAME_MAX 64
> > -
> > -/* Maximum message queue priority level. */
> > -#define MQ_PRIO_MAX 32768
> > -
> > -/* Maximum value the semaphore can have. */
> > -#define SEM_VALUE_MAX (2147483647)
> > diff --git a/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..5bfb0e10dd
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/alpha/bits/pthread_stack_min.h
> > @@ -0,0 +1,20 @@
> > +/* Definition of PTHREAD_STACK_MIN. Linux/Alpha version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Library General Public License as
> > + published by the Free Software Foundation; either version 2 of the
> > + License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Library General Public License for more details.
> > +
> > + You should have received a copy of the GNU Library General Public
> > + License along with the GNU C Library. If not, see
> > + <https://www.gnu.org/licenses/>. */
> > +
> > +/* Minimum size for a thread. We are free to choose a reasonable value. */
> > +#define PTHREAD_STACK_MIN 24576
> > diff --git a/sysdeps/unix/sysv/linux/bits/local_lim.h b/sysdeps/unix/sysv/linux/bits/local_lim.h
> > index b88ca3d4d2..0b1c7f40be 100644
> > --- a/sysdeps/unix/sysv/linux/bits/local_lim.h
> > +++ b/sysdeps/unix/sysv/linux/bits/local_lim.h
> > @@ -78,7 +78,13 @@
> > #define AIO_PRIO_DELTA_MAX 20
> >
> > /* Minimum size for a thread. We are free to choose a reasonable value. */
> > -#define PTHREAD_STACK_MIN 16384
> > +#undef PTHREAD_STACK_MIN
> > +#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
> > +# include <unistd.h>
> > +# define PTHREAD_STACK_MIN sysconf (_SC_THREAD_STACK_MIN)
> > +#else
> > +# include <bits/pthread_stack_min.h>
> > +#endif
> >
> > /* Maximum number of timer expiration overruns. */
> > #define DELAYTIMER_MAX 2147483647
> > diff --git a/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..7bd6fa1242
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/bits/pthread_stack_min.h
> > @@ -0,0 +1,20 @@
> > +/* Definition of PTHREAD_STACK_MIN. Linux version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Lesser General Public
> > + License as published by the Free Software Foundation; either
> > + version 2.1 of the License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Lesser General Public License for more details.
> > +
> > + You should have received a copy of the GNU Lesser General Public
> > + License along with the GNU C Library; if not, see
> > + <https://www.gnu.org/licenses/>. */
> > +
> > +/* Minimum size for a thread. We are free to choose a reasonable value. */
> > +#define PTHREAD_STACK_MIN 16384
> > diff --git a/sysdeps/unix/sysv/linux/bits/sigstksz.h b/sysdeps/unix/sysv/linux/bits/sigstksz.h
> > index 926508f2b4..cd45d122e0 100644
> > --- a/sysdeps/unix/sysv/linux/bits/sigstksz.h
> > +++ b/sysdeps/unix/sysv/linux/bits/sigstksz.h
> > @@ -20,7 +20,7 @@
> > # error "Never include <bits/sigstksz.h> directly; use <signal.h> instead."
> > #endif
> >
> > -#if defined __USE_SC_SIGSTKSZ && __USE_SC_SIGSTKSZ
> > +#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
> > # include <unistd.h>
> >
> > /* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ). */
> > diff --git a/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h b/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> > deleted file mode 100644
> > index 7a9f677ec8..0000000000
> > --- a/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
> > +++ /dev/null
> > @@ -1,99 +0,0 @@
> > -/* Minimum guaranteed maximum values for system limits. Linux/IA-64 version.
> > - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> > - This file is part of the GNU C Library.
> > -
> > - The GNU C Library is free software; you can redistribute it and/or
> > - modify it under the terms of the GNU Lesser General Public
> > - License as published by the Free Software Foundation; either
> > - version 2.1 of the License, or (at your option) any later version.
> > -
> > - The GNU C Library is distributed in the hope that it will be useful,
> > - but WITHOUT ANY WARRANTY; without even the implied warranty of
> > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > - Lesser General Public License for more details.
> > -
> > - You should have received a copy of the GNU Lesser General Public
> > - License along with the GNU C Library; if not, see
> > - <https://www.gnu.org/licenses/>. */
> > -
> > -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> > - and defines LINK_MAX although filesystems have different maxima. A
> > - similar thing is true for OPEN_MAX: the limit can be changed at
> > - runtime and therefore the macro must not be defined. Remove this
> > - after including the header if necessary. */
> > -#ifndef NR_OPEN
> > -# define __undef_NR_OPEN
> > -#endif
> > -#ifndef LINK_MAX
> > -# define __undef_LINK_MAX
> > -#endif
> > -#ifndef OPEN_MAX
> > -# define __undef_OPEN_MAX
> > -#endif
> > -#ifndef ARG_MAX
> > -# define __undef_ARG_MAX
> > -#endif
> > -
> > -/* The kernel sources contain a file with all the needed information. */
> > -#include <linux/limits.h>
> > -
> > -/* Have to remove NR_OPEN? */
> > -#ifdef __undef_NR_OPEN
> > -# undef NR_OPEN
> > -# undef __undef_NR_OPEN
> > -#endif
> > -/* Have to remove LINK_MAX? */
> > -#ifdef __undef_LINK_MAX
> > -# undef LINK_MAX
> > -# undef __undef_LINK_MAX
> > -#endif
> > -/* Have to remove OPEN_MAX? */
> > -#ifdef __undef_OPEN_MAX
> > -# undef OPEN_MAX
> > -# undef __undef_OPEN_MAX
> > -#endif
> > -/* Have to remove ARG_MAX? */
> > -#ifdef __undef_ARG_MAX
> > -# undef ARG_MAX
> > -# undef __undef_ARG_MAX
> > -#endif
> > -
> > -/* The number of data keys per process. */
> > -#define _POSIX_THREAD_KEYS_MAX 128
> > -/* This is the value this implementation supports. */
> > -#define PTHREAD_KEYS_MAX 1024
> > -
> > -/* Controlling the iterations of destructors for thread-specific data. */
> > -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> > -/* Number of iterations this implementation does. */
> > -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> > -
> > -/* The number of threads per process. */
> > -#define _POSIX_THREAD_THREADS_MAX 64
> > -/* We have no predefined limit on the number of threads. */
> > -#undef PTHREAD_THREADS_MAX
> > -
> > -/* Maximum amount by which a process can descrease its asynchronous I/O
> > - priority level. */
> > -#define AIO_PRIO_DELTA_MAX 20
> > -
> > -/* Minimum size for a thread. We are free to choose a reasonable value. */
> > -#define PTHREAD_STACK_MIN 196608
> > -
> > -/* Maximum number of timer expiration overruns. */
> > -#define DELAYTIMER_MAX 2147483647
> > -
> > -/* Maximum tty name length. */
> > -#define TTY_NAME_MAX 32
> > -
> > -/* Maximum login name length. This is arbitrary. */
> > -#define LOGIN_NAME_MAX 256
> > -
> > -/* Maximum host name length. */
> > -#define HOST_NAME_MAX 64
> > -
> > -/* Maximum message queue priority level. */
> > -#define MQ_PRIO_MAX 32768
> > -
> > -/* Maximum value the semaphore can have. */
> > -#define SEM_VALUE_MAX (2147483647)
> > diff --git a/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..73581506b2
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/ia64/bits/pthread_stack_min.h
> > @@ -0,0 +1,20 @@
> > +/* Definition of PTHREAD_STACK_MIN. Linux/IA-64 version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Lesser General Public
> > + License as published by the Free Software Foundation; either
> > + version 2.1 of the License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Lesser General Public License for more details.
> > +
> > + You should have received a copy of the GNU Lesser General Public
> > + License along with the GNU C Library; if not, see
> > + <https://www.gnu.org/licenses/>. */
> > +
> > +/* Minimum size for a thread. We are free to choose a reasonable value. */
> > +#define PTHREAD_STACK_MIN 196608
> > diff --git a/sysdeps/unix/sysv/linux/mips/bits/local_lim.h b/sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> > deleted file mode 100644
> > index a6a0d8a980..0000000000
> > --- a/sysdeps/unix/sysv/linux/mips/bits/local_lim.h
> > +++ /dev/null
> > @@ -1,99 +0,0 @@
> > -/* Minimum guaranteed maximum values for system limits. MIPS Linux version.
> > - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> > - This file is part of the GNU C Library.
> > -
> > - The GNU C Library is free software; you can redistribute it and/or
> > - modify it under the terms of the GNU Lesser General Public License as
> > - published by the Free Software Foundation; either version 2.1 of the
> > - License, or (at your option) any later version.
> > -
> > - The GNU C Library is distributed in the hope that it will be useful,
> > - but WITHOUT ANY WARRANTY; without even the implied warranty of
> > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > - Lesser General Public License for more details.
> > -
> > - You should have received a copy of the GNU Lesser General Public
> > - License along with the GNU C Library. If not, see
> > - <https://www.gnu.org/licenses/>. */
> > -
> > -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> > - and defines LINK_MAX although filesystems have different maxima. A
> > - similar thing is true for OPEN_MAX: the limit can be changed at
> > - runtime and therefore the macro must not be defined. Remove this
> > - after including the header if necessary. */
> > -#ifndef NR_OPEN
> > -# define __undef_NR_OPEN
> > -#endif
> > -#ifndef LINK_MAX
> > -# define __undef_LINK_MAX
> > -#endif
> > -#ifndef OPEN_MAX
> > -# define __undef_OPEN_MAX
> > -#endif
> > -#ifndef ARG_MAX
> > -# define __undef_ARG_MAX
> > -#endif
> > -
> > -/* The kernel sources contain a file with all the needed information. */
> > -#include <linux/limits.h>
> > -
> > -/* Have to remove NR_OPEN? */
> > -#ifdef __undef_NR_OPEN
> > -# undef NR_OPEN
> > -# undef __undef_NR_OPEN
> > -#endif
> > -/* Have to remove LINK_MAX? */
> > -#ifdef __undef_LINK_MAX
> > -# undef LINK_MAX
> > -# undef __undef_LINK_MAX
> > -#endif
> > -/* Have to remove OPEN_MAX? */
> > -#ifdef __undef_OPEN_MAX
> > -# undef OPEN_MAX
> > -# undef __undef_OPEN_MAX
> > -#endif
> > -/* Have to remove ARG_MAX? */
> > -#ifdef __undef_ARG_MAX
> > -# undef ARG_MAX
> > -# undef __undef_ARG_MAX
> > -#endif
> > -
> > -/* The number of data keys per process. */
> > -#define _POSIX_THREAD_KEYS_MAX 128
> > -/* This is the value this implementation supports. */
> > -#define PTHREAD_KEYS_MAX 1024
> > -
> > -/* Controlling the iterations of destructors for thread-specific data. */
> > -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> > -/* Number of iterations this implementation does. */
> > -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> > -
> > -/* The number of threads per process. */
> > -#define _POSIX_THREAD_THREADS_MAX 64
> > -/* We have no predefined limit on the number of threads. */
> > -#undef PTHREAD_THREADS_MAX
> > -
> > -/* Maximum amount by which a process can descrease its asynchronous I/O
> > - priority level. */
> > -#define AIO_PRIO_DELTA_MAX 20
> > -
> > -/* Minimum size for a thread. At least two pages with 64k pages. */
> > -#define PTHREAD_STACK_MIN 131072
> > -
> > -/* Maximum number of timer expiration overruns. */
> > -#define DELAYTIMER_MAX 2147483647
> > -
> > -/* Maximum tty name length. */
> > -#define TTY_NAME_MAX 32
> > -
> > -/* Maximum login name length. This is arbitrary. */
> > -#define LOGIN_NAME_MAX 256
> > -
> > -/* Maximum host name length. */
> > -#define HOST_NAME_MAX 64
> > -
> > -/* Maximum message queue priority level. */
> > -#define MQ_PRIO_MAX 32768
> > -
> > -/* Maximum value the semaphore can have. */
> > -#define SEM_VALUE_MAX (2147483647)
> > diff --git a/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..132f1704a5
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/mips/bits/pthread_stack_min.h
> > @@ -0,0 +1,20 @@
> > +/* Definition of PTHREAD_STACK_MIN. MIPS Linux version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Lesser General Public License as
> > + published by the Free Software Foundation; either version 2.1 of the
> > + License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Lesser General Public License for more details.
> > +
> > + You should have received a copy of the GNU Lesser General Public
> > + License along with the GNU C Library. If not, see
> > + <https://www.gnu.org/licenses/>. */
> > +
> > +/* Minimum size for a thread. At least two pages with 64k pages. */
> > +#define PTHREAD_STACK_MIN 131072
> > diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h b/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> > deleted file mode 100644
> > index 6caa627506..0000000000
> > --- a/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
> > +++ /dev/null
> > @@ -1,100 +0,0 @@
> > -/* Minimum guaranteed maximum values for system limits. Linux/PPC version.
> > - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> > - This file is part of the GNU C Library.
> > -
> > - The GNU C Library is free software; you can redistribute it and/or
> > - modify it under the terms of the GNU Lesser General Public License as
> > - published by the Free Software Foundation; either version 2.1 of the
> > - License, or (at your option) any later version.
> > -
> > - The GNU C Library is distributed in the hope that it will be useful,
> > - but WITHOUT ANY WARRANTY; without even the implied warranty of
> > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > - Lesser General Public License for more details.
> > -
> > - You should have received a copy of the GNU Lesser General Public
> > - License along with the GNU C Library; see the file COPYING.LIB. If
> > - not, see <https://www.gnu.org/licenses/>. */
> > -
> > -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> > - and defines LINK_MAX although filesystems have different maxima. A
> > - similar thing is true for OPEN_MAX: the limit can be changed at
> > - runtime and therefore the macro must not be defined. Remove this
> > - after including the header if necessary. */
> > -#ifndef NR_OPEN
> > -# define __undef_NR_OPEN
> > -#endif
> > -#ifndef LINK_MAX
> > -# define __undef_LINK_MAX
> > -#endif
> > -#ifndef OPEN_MAX
> > -# define __undef_OPEN_MAX
> > -#endif
> > -#ifndef ARG_MAX
> > -# define __undef_ARG_MAX
> > -#endif
> > -
> > -/* The kernel sources contain a file with all the needed information. */
> > -#include <linux/limits.h>
> > -
> > -/* Have to remove NR_OPEN? */
> > -#ifdef __undef_NR_OPEN
> > -# undef NR_OPEN
> > -# undef __undef_NR_OPEN
> > -#endif
> > -/* Have to remove LINK_MAX? */
> > -#ifdef __undef_LINK_MAX
> > -# undef LINK_MAX
> > -# undef __undef_LINK_MAX
> > -#endif
> > -/* Have to remove OPEN_MAX? */
> > -#ifdef __undef_OPEN_MAX
> > -# undef OPEN_MAX
> > -# undef __undef_OPEN_MAX
> > -#endif
> > -/* Have to remove ARG_MAX? */
> > -#ifdef __undef_ARG_MAX
> > -# undef ARG_MAX
> > -# undef __undef_ARG_MAX
> > -#endif
> > -
> > -/* The number of data keys per process. */
> > -#define _POSIX_THREAD_KEYS_MAX 128
> > -/* This is the value this implementation supports. */
> > -#define PTHREAD_KEYS_MAX 1024
> > -
> > -/* Controlling the iterations of destructors for thread-specific data. */
> > -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> > -/* Number of iterations this implementation does. */
> > -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> > -
> > -/* The number of threads per process. */
> > -#define _POSIX_THREAD_THREADS_MAX 64
> > -/* We have no predefined limit on the number of threads. */
> > -#undef PTHREAD_THREADS_MAX
> > -
> > -/* Maximum amount by which a process can descrease its asynchronous I/O
> > - priority level. */
> > -#define AIO_PRIO_DELTA_MAX 20
> > -
> > -/* Minimum size for a thread. At least two pages for systems with 64k
> > - pages. */
> > -#define PTHREAD_STACK_MIN 131072
> > -
> > -/* Maximum number of timer expiration overruns. */
> > -#define DELAYTIMER_MAX 2147483647
> > -
> > -/* Maximum tty name length. */
> > -#define TTY_NAME_MAX 32
> > -
> > -/* Maximum login name length. This is arbitrary. */
> > -#define LOGIN_NAME_MAX 256
> > -
> > -/* Maximum host name length. */
> > -#define HOST_NAME_MAX 64
> > -
> > -/* Maximum message queue priority level. */
> > -#define MQ_PRIO_MAX 32768
> > -
> > -/* Maximum value the semaphore can have. */
> > -#define SEM_VALUE_MAX (2147483647)
> > diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..d7017e7b24
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/powerpc/bits/pthread_stack_min.h
> > @@ -0,0 +1,21 @@
> > +/* Definition of PTHREAD_STACK_MIN. Linux/PPC version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Lesser General Public License as
> > + published by the Free Software Foundation; either version 2.1 of the
> > + License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Lesser General Public License for more details.
> > +
> > + You should have received a copy of the GNU Lesser General Public
> > + License along with the GNU C Library; see the file COPYING.LIB. If
> > + not, see <https://www.gnu.org/licenses/>. */
> > +
> > +/* Minimum size for a thread. At least two pages for systems with 64k
> > + pages. */
> > +#define PTHREAD_STACK_MIN 131072
> > diff --git a/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h b/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> > deleted file mode 100644
> > index 4a9a8c1325..0000000000
> > --- a/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
> > +++ /dev/null
> > @@ -1,99 +0,0 @@
> > -/* Minimum guaranteed maximum values for system limits. Linux/SPARC version.
> > - Copyright (C) 1993-2021 Free Software Foundation, Inc.
> > - This file is part of the GNU C Library.
> > -
> > - The GNU C Library is free software; you can redistribute it and/or
> > - modify it under the terms of the GNU Library General Public License as
> > - published by the Free Software Foundation; either version 2 of the
> > - License, or (at your option) any later version.
> > -
> > - The GNU C Library is distributed in the hope that it will be useful,
> > - but WITHOUT ANY WARRANTY; without even the implied warranty of
> > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > - Library General Public License for more details.
> > -
> > - You should have received a copy of the GNU Library General Public
> > - License along with the GNU C Library; see the file COPYING.LIB. If
> > - not, see <https://www.gnu.org/licenses/>. */
> > -
> > -/* The kernel header pollutes the namespace with the NR_OPEN symbol
> > - and defines LINK_MAX although filesystems have different maxima. A
> > - similar thing is true for OPEN_MAX: the limit can be changed at
> > - runtime and therefore the macro must not be defined. Remove this
> > - after including the header if necessary. */
> > -#ifndef NR_OPEN
> > -# define __undef_NR_OPEN
> > -#endif
> > -#ifndef LINK_MAX
> > -# define __undef_LINK_MAX
> > -#endif
> > -#ifndef OPEN_MAX
> > -# define __undef_OPEN_MAX
> > -#endif
> > -#ifndef ARG_MAX
> > -# define __undef_ARG_MAX
> > -#endif
> > -
> > -/* The kernel sources contain a file with all the needed information. */
> > -#include <linux/limits.h>
> > -
> > -/* Have to remove NR_OPEN? */
> > -#ifdef __undef_NR_OPEN
> > -# undef NR_OPEN
> > -# undef __undef_NR_OPEN
> > -#endif
> > -/* Have to remove LINK_MAX? */
> > -#ifdef __undef_LINK_MAX
> > -# undef LINK_MAX
> > -# undef __undef_LINK_MAX
> > -#endif
> > -/* Have to remove OPEN_MAX? */
> > -#ifdef __undef_OPEN_MAX
> > -# undef OPEN_MAX
> > -# undef __undef_OPEN_MAX
> > -#endif
> > -/* Have to remove ARG_MAX? */
> > -#ifdef __undef_ARG_MAX
> > -# undef ARG_MAX
> > -# undef __undef_ARG_MAX
> > -#endif
> > -
> > -/* The number of data keys per process. */
> > -#define _POSIX_THREAD_KEYS_MAX 128
> > -/* This is the value this implementation supports. */
> > -#define PTHREAD_KEYS_MAX 1024
> > -
> > -/* Controlling the iterations of destructors for thread-specific data. */
> > -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
> > -/* Number of iterations this implementation does. */
> > -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
> > -
> > -/* The number of threads per process. */
> > -#define _POSIX_THREAD_THREADS_MAX 64
> > -/* We have no predefined limit on the number of threads. */
> > -#undef PTHREAD_THREADS_MAX
> > -
> > -/* Maximum amount by which a process can descrease its asynchronous I/O
> > - priority level. */
> > -#define AIO_PRIO_DELTA_MAX 20
> > -
> > -/* Minimum size for a thread. We are free to choose a reasonable value. */
> > -#define PTHREAD_STACK_MIN 24576
> > -
> > -/* Maximum number of timer expiration overruns. */
> > -#define DELAYTIMER_MAX 2147483647
> > -
> > -/* Maximum tty name length. */
> > -#define TTY_NAME_MAX 32
> > -
> > -/* Maximum login name length. This is arbitrary. */
> > -#define LOGIN_NAME_MAX 256
> > -
> > -/* Maximum host name length. */
> > -#define HOST_NAME_MAX 64
> > -
> > -/* Maximum message queue priority level. */
> > -#define MQ_PRIO_MAX 32768
> > -
> > -/* Maximum value the semaphore can have. */
> > -#define SEM_VALUE_MAX (2147483647)
> > diff --git a/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..bcacedb73b
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/sparc/bits/pthread_stack_min.h
> > @@ -0,0 +1,20 @@
> > +/* Definition of PTHREAD_STACK_MIN. Linux/SPARC version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Library General Public License as
> > + published by the Free Software Foundation; either version 2 of the
> > + License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Library General Public License for more details.
> > +
> > + You should have received a copy of the GNU Library General Public
> > + License along with the GNU C Library; see the file COPYING.LIB. If
> > + not, see <https://www.gnu.org/licenses/>. */
> > +
> > +/* Minimum size for a thread. We are free to choose a reasonable value. */
> > +#define PTHREAD_STACK_MIN 24576
> > diff --git a/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
> > new file mode 100644
> > index 0000000000..9e0eb0f7fc
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h
> > @@ -0,0 +1,39 @@
> > +/* __get_pthread_stack_min (). Linux version.
> > + Copyright (C) 2021 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Lesser General Public
> > + License as published by the Free Software Foundation; either
> > + version 2.1 of the License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Lesser General Public License for more details.
> > +
> > + You should have received a copy of the GNU Lesser General Public
> > + License along with the GNU C Library; if not, see
> > + <https://www.gnu.org/licenses/>. */
> > +
> > +/* Return sysconf (_SC_THREAD_STACK_MIN). */
> > +
> > +static inline long int
> > +__get_pthread_stack_min (void)
> > +{
> > + /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */
> > + long int pthread_stack_min = GLRO(dl_minsigstacksize);
> > + assert (pthread_stack_min != 0);
> > + _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
> > + "PTHREAD_STACK_MIN is constant");
> > + /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */
> > + if (pthread_stack_min < PTHREAD_STACK_MIN)
> > + pthread_stack_min = PTHREAD_STACK_MIN;
> > + /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
> > + which returns a larger size that includes the required TLS variable
> > + space which has been determined at startup. For sysconf here we are
> > + conservative and don't include the space required for TLS access.
> > + Eventually the TLS variable space will not be part of the stack
> > + (Bug 11787). */
> > + return pthread_stack_min;
> > +}
> > --
> > 2.31.1
> >
>
--
H.J.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
2021-07-12 19:07 ` Maxim Kuvyrkov
2021-07-12 19:45 ` H.J. Lu
@ 2021-07-12 19:50 ` Florian Weimer
2021-07-16 22:17 ` Khem Raj
1 sibling, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2021-07-12 19:50 UTC (permalink / raw)
To: Maxim Kuvyrkov via Libc-alpha; +Cc: H.J. Lu, Maxim Kuvyrkov
* Maxim Kuvyrkov via Libc-alpha:
> Hi H.J.,
>
> This breaks GCC’s libgomp build on at least aarch64-linux-gnu:
>
> /builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/env.o: in function `initialize_env':
> /snapshots/gcc.git~master/libgomp/env.c:1536: undefined reference to `sysconf'
> /snapshots/gcc.git~master/libgomp/env.c:1538: undefined reference to `sysconf'
> /snapshots/gcc.git~master/libgomp/env.c:1539: undefined reference to `sysconf'
> /builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/proc.o: in function `gomp_init_num_threads':
> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:85: undefined reference to `sysconf'
> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:143: undefined reference to `sysconf'
> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:174: more undefined references to `sysconf' follow
> collect2: error: ld returned 1 exit status
> make[4]: *** [Makefile:728: libgomp.la] Error 1
>
> Both GCC and Glibc are tip of trunk.
>
> Would you please take a look? Please let me know if it doesn’t easily
> reproduce and I’ll take a look.
I pushed a patch today that should fix this on the glibc side:
Reduce <limits.h> pollution due to dynamic PTHREAD_STACK_MIN
<https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=aaacde11f2e814814f>
It contains some magic that happens to fix GCC for now. Jakub is
working on a patch that fixes the libgomp issue as well (the standard
header #include within the hidden-visibility area is invalid):
<https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574960.html>
Thanks,
Florian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
2021-07-12 19:50 ` Florian Weimer
@ 2021-07-16 22:17 ` Khem Raj
2021-07-17 21:59 ` Carlos O'Donell
0 siblings, 1 reply; 7+ messages in thread
From: Khem Raj @ 2021-07-16 22:17 UTC (permalink / raw)
To: Florian Weimer; +Cc: Maxim Kuvyrkov via Libc-alpha, Maxim Kuvyrkov
On Mon, Jul 12, 2021 at 12:51 PM Florian Weimer via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> * Maxim Kuvyrkov via Libc-alpha:
>
> > Hi H.J.,
> >
> > This breaks GCC’s libgomp build on at least aarch64-linux-gnu:
> >
> > /builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/env.o: in function `initialize_env':
> > /snapshots/gcc.git~master/libgomp/env.c:1536: undefined reference to `sysconf'
> > /snapshots/gcc.git~master/libgomp/env.c:1538: undefined reference to `sysconf'
> > /snapshots/gcc.git~master/libgomp/env.c:1539: undefined reference to `sysconf'
> > /builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/proc.o: in function `gomp_init_num_threads':
> > /snapshots/gcc.git~master/libgomp/config/linux/proc.c:85: undefined reference to `sysconf'
> > /snapshots/gcc.git~master/libgomp/config/linux/proc.c:143: undefined reference to `sysconf'
> > /snapshots/gcc.git~master/libgomp/config/linux/proc.c:174: more undefined references to `sysconf' follow
> > collect2: error: ld returned 1 exit status
> > make[4]: *** [Makefile:728: libgomp.la] Error 1
> >
> > Both GCC and Glibc are tip of trunk.
> >
> > Would you please take a look? Please let me know if it doesn’t easily
> > reproduce and I’ll take a look.
>
> I pushed a patch today that should fix this on the glibc side:
>
> Reduce <limits.h> pollution due to dynamic PTHREAD_STACK_MIN
> <https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=aaacde11f2e814814f>
>
> It contains some magic that happens to fix GCC for now. Jakub is
> working on a patch that fixes the libgomp issue as well (the standard
> header #include within the hidden-visibility area is invalid):
>
> <https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574960.html>
>
I am seeing few packages failing since they use PTHREAD_STACK_MIN as constant
see https://errors.yoctoproject.org/Errors/Build/124520/
> Thanks,
> Florian
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
2021-07-16 22:17 ` Khem Raj
@ 2021-07-17 21:59 ` Carlos O'Donell
0 siblings, 0 replies; 7+ messages in thread
From: Carlos O'Donell @ 2021-07-17 21:59 UTC (permalink / raw)
To: Khem Raj, Florian Weimer; +Cc: Maxim Kuvyrkov via Libc-alpha, Maxim Kuvyrkov
On 7/16/21 6:17 PM, Khem Raj via Libc-alpha wrote:
> On Mon, Jul 12, 2021 at 12:51 PM Florian Weimer via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>> * Maxim Kuvyrkov via Libc-alpha:
>>
>>> Hi H.J.,
>>>
>>> This breaks GCC’s libgomp build on at least aarch64-linux-gnu:
>>>
>>> /builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/env.o: in function `initialize_env':
>>> /snapshots/gcc.git~master/libgomp/env.c:1536: undefined reference to `sysconf'
>>> /snapshots/gcc.git~master/libgomp/env.c:1538: undefined reference to `sysconf'
>>> /snapshots/gcc.git~master/libgomp/env.c:1539: undefined reference to `sysconf'
>>> /builds/destdir/x86_64-pc-linux-gnu/aarch64-linux-gnu/bin/ld: .libs/proc.o: in function `gomp_init_num_threads':
>>> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:85: undefined reference to `sysconf'
>>> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:143: undefined reference to `sysconf'
>>> /snapshots/gcc.git~master/libgomp/config/linux/proc.c:174: more undefined references to `sysconf' follow
>>> collect2: error: ld returned 1 exit status
>>> make[4]: *** [Makefile:728: libgomp.la] Error 1
>>>
>>> Both GCC and Glibc are tip of trunk.
>>>
>>> Would you please take a look? Please let me know if it doesn’t easily
>>> reproduce and I’ll take a look.
>>
>> I pushed a patch today that should fix this on the glibc side:
>>
>> Reduce <limits.h> pollution due to dynamic PTHREAD_STACK_MIN
>> <https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=aaacde11f2e814814f>
>>
>> It contains some magic that happens to fix GCC for now. Jakub is
>> working on a patch that fixes the libgomp issue as well (the standard
>> header #include within the hidden-visibility area is invalid):
>>
>> <https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574960.html>
>>
>
> I am seeing few packages failing since they use PTHREAD_STACK_MIN as constant
> see https://errors.yoctoproject.org/Errors/Build/124520/
Thanks for those reports, we'll need to keep an eye on these, but they will
all need to be fixed for non-constant pthread stack size. Finding and fixing
these issues will allow Intel and Arm to move forward with dynamic stack
sizes for new hardware features.
--
Cheers,
Carlos.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-07-17 21:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09 21:09 [PATCH v5] Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) H.J. Lu
2021-07-09 22:07 ` Carlos O'Donell
2021-07-12 19:07 ` Maxim Kuvyrkov
2021-07-12 19:45 ` H.J. Lu
2021-07-12 19:50 ` Florian Weimer
2021-07-16 22:17 ` Khem Raj
2021-07-17 21:59 ` Carlos O'Donell
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).