diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-06-21 12:42:56 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-07-09 15:10:35 -0700 |
commit | 5d98a7dae955bafa6740c26eaba9c86060ae0344 (patch) | |
tree | 51ab0a095a5406ec5f1b65eafb1f5808a98e9f63 /nptl | |
parent | 7c241325d67af9e24ff03d4c6f6280c17ea181f8 (diff) | |
download | glibc-5d98a7dae955bafa6740c26eaba9c86060ae0344.zip glibc-5d98a7dae955bafa6740c26eaba9c86060ae0344.tar.gz glibc-5d98a7dae955bafa6740c26eaba9c86060ae0344.tar.bz2 |
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 'nptl')
-rw-r--r-- | nptl/tst-context1.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/nptl/tst-context1.c b/nptl/tst-context1.c index 821f3c2..00e39af 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; } |