summaryrefslogtreecommitdiffstats
path: root/libpthread/nptl/init.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2007-11-19 15:35:12 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2007-11-19 15:35:12 +0000
commit414d8e5f2a73aff8e9404684571a65f85b27bf89 (patch)
tree879ac217d477f76cf965b244d98b383b663ff47b /libpthread/nptl/init.c
parent381fb7688d356f03e35b9254796adb29c941532b (diff)
downloaduClibc-alpine-414d8e5f2a73aff8e9404684571a65f85b27bf89.tar.bz2
uClibc-alpine-414d8e5f2a73aff8e9404684571a65f85b27bf89.tar.xz
Synch nptl branch with SH port: as requested by sjhill for mips-ash4 merge
Diffstat (limited to 'libpthread/nptl/init.c')
-rw-r--r--libpthread/nptl/init.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c
index ead1a3fba..cd5d39314 100644
--- a/libpthread/nptl/init.c
+++ b/libpthread/nptl/init.c
@@ -271,6 +271,17 @@ __pthread_initialize_minimal_internal (void)
(void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_UNBLOCK, &sa.sa_mask,
NULL, _NSIG / 8);
+ /* 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. */
@@ -279,29 +290,28 @@ __pthread_initialize_minimal_internal (void)
|| limit.rlim_cur == RLIM_INFINITY)
/* The system limit is not usable. Use an architecture-specific
default. */
- __default_stacksize = ARCH_STACK_DEFAULT_SIZE;
+ 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. */
- __default_stacksize = PTHREAD_STACK_MIN;
- else
- {
- /* Round the resource limit up to page size. */
- const uintptr_t pagesz = sysconf (_SC_PAGESIZE);
- __default_stacksize = (limit.rlim_cur + pagesz - 1) & -pagesz;
- }
+ limit.rlim_cur = PTHREAD_STACK_MIN;
- /* 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 it meets the minimum size that allocate_stack
+ (allocatestack.c) will demand, which depends on the page size. */
+ const uintptr_t pagesz = sysconf (_SC_PAGESIZE);
+ const size_t minstack = pagesz + __static_tls_size + MINIMAL_REST_STACK;
+ if (limit.rlim_cur < minstack)
+ limit.rlim_cur = minstack;
- /* 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;
+ /* Round the resource limit up to page size. */
+ limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz;
+ __default_stacksize = limit.rlim_cur;
- __static_tls_size = roundup (__static_tls_size, static_tls_align);
+#ifdef SHARED
+ /* Transfer the old value from the dynamic linker's internal location. */
+ *__libc_dl_error_tsd () = *(*GL(dl_error_catch_tsd)) ();
+ GL(dl_error_catch_tsd) = &__libc_dl_error_tsd;
+#endif
GL(dl_init_static_tls) = &__pthread_init_static_tls;