summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-06-21 12:42:56 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-07-09 15:10:35 -0700
commit5d98a7dae955bafa6740c26eaba9c86060ae0344 (patch)
tree51ab0a095a5406ec5f1b65eafb1f5808a98e9f63 /stdlib
parent7c241325d67af9e24ff03d4c6f6280c17ea181f8 (diff)
downloadglibc-5d98a7dae955bafa6740c26eaba9c86060ae0344.tar.gz
glibc-5d98a7dae955bafa6740c26eaba9c86060ae0344.tar.xz
glibc-5d98a7dae955bafa6740c26eaba9c86060ae0344.zip
Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)
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.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/test-atexit-race-common.c11
1 files changed, 6 insertions, 5 deletions
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) {