aboutsummaryrefslogtreecommitdiff
path: root/nptl/nptl-init.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/nptl-init.c')
-rw-r--r--nptl/nptl-init.c46
1 files changed, 3 insertions, 43 deletions
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index bc4831a..732e580 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -36,10 +36,7 @@
#include <kernel-features.h>
#include <libc-pointer-arith.h>
#include <pthread_mutex_conf.h>
-
-/* Size and alignment of static TLS block. */
-size_t __static_tls_size;
-size_t __static_tls_align_m1;
+#include <nptl-stack.h>
/* Version of the library, used in libthread_db to detect mismatches. */
static const char nptl_version[] __attribute_used__ = VERSION;
@@ -47,44 +44,6 @@ static const char nptl_version[] __attribute_used__ = VERSION;
void
__pthread_initialize_minimal_internal (void)
{
- /* Get the size of the static and alignment requirements for the TLS
- block. */
- size_t static_tls_align;
- _dl_get_tls_static_info (&__static_tls_size, &static_tls_align);
-
- /* Make sure the size takes all the alignments into account. */
- if (STACK_ALIGN > static_tls_align)
- static_tls_align = STACK_ALIGN;
- __static_tls_align_m1 = static_tls_align - 1;
-
- __static_tls_size = roundup (__static_tls_size, static_tls_align);
-
- /* Determine the default allowed stack size. This is the size used
- in case the user does not specify one. */
- struct rlimit limit;
- if (__getrlimit (RLIMIT_STACK, &limit) != 0
- || limit.rlim_cur == RLIM_INFINITY)
- /* The system limit is not usable. Use an architecture-specific
- default. */
- limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
- else if (limit.rlim_cur < PTHREAD_STACK_MIN)
- /* The system limit is unusably small.
- Use the minimal size acceptable. */
- limit.rlim_cur = PTHREAD_STACK_MIN;
-
- /* Make sure it meets the minimum size that allocate_stack
- (allocatestack.c) will demand, which depends on the page size. */
- const uintptr_t pagesz = GLRO(dl_pagesize);
- const size_t minstack = pagesz + __static_tls_size + MINIMAL_REST_STACK;
- if (limit.rlim_cur < minstack)
- limit.rlim_cur = minstack;
-
- /* Round the resource limit up to page size. */
- limit.rlim_cur = ALIGN_UP (limit.rlim_cur, pagesz);
- lll_lock (__default_pthread_attr_lock, LLL_PRIVATE);
- __default_pthread_attr.internal.stacksize = limit.rlim_cur;
- __default_pthread_attr.internal.guardsize = GLRO (dl_pagesize);
- lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE);
}
strong_alias (__pthread_initialize_minimal_internal,
__pthread_initialize_minimal)
@@ -101,5 +60,6 @@ strong_alias (__pthread_initialize_minimal_internal,
size_t
__pthread_get_minstack (const pthread_attr_t *attr)
{
- return GLRO(dl_pagesize) + __static_tls_size + PTHREAD_STACK_MIN;
+ return (GLRO(dl_pagesize) + __nptl_tls_static_size_for_stack ()
+ + PTHREAD_STACK_MIN);
}