1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00

Revert GLIBC_PTHREAD_DEFAULT_STACKSIZE changes.

This reverts the change that allows the POSIX Thread default stack size
to be changed by the environment variable
GLIBC_PTHREAD_DEFAULT_STACKSIZE. It has been requested that more
discussion happen before this change goes into 2.18.
This commit is contained in:
Carlos O'Donell
2013-03-01 16:18:08 -05:00
parent ace4acc8ac
commit 4e9b599577
8 changed files with 39 additions and 140 deletions

View File

@ -276,26 +276,8 @@ extern void **__libc_dl_error_tsd (void) __attribute__ ((const));
/* This can be set by the debugger before initialization is complete. */
static bool __nptl_initial_report_events __attribute_used__;
static void
set_default_stacksize (size_t stacksize)
{
if (stacksize < PTHREAD_STACK_MIN)
stacksize = 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 (stacksize < minstack)
stacksize = minstack;
/* Round the resource limit up to page size. */
stacksize = (stacksize + pagesz - 1) & -pagesz;
__default_stacksize = stacksize;
}
void
__pthread_initialize_minimal_internal (int argc, char **argv, char **envp)
__pthread_initialize_minimal_internal (void)
{
#ifndef SHARED
/* Unlike in the dynamically linked case the dynamic linker has not
@ -419,41 +401,29 @@ __pthread_initialize_minimal_internal (int argc, char **argv, char **envp)
__static_tls_size = roundup (__static_tls_size, static_tls_align);
/* Initialize the environment. libc.so gets initialized after us due to a
circular dependency and hence __environ is not available otherwise. */
__environ = envp;
/* 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;
#ifndef SHARED
__libc_init_secure ();
#endif
/* 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;
size_t stacksize = 0;
char *envval = __libc_secure_getenv ("GLIBC_PTHREAD_DEFAULT_STACKSIZE");
if (__glibc_unlikely (envval != NULL && envval[0] != '\0'))
{
char *env_conv = envval;
size_t ret = strtoul (envval, &env_conv, 0);
if (*env_conv == '\0' && env_conv != envval)
stacksize = ret;
}
if (stacksize == 0)
{
/* 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. */
stacksize = ARCH_STACK_DEFAULT_SIZE;
else
stacksize = limit.rlim_cur;
}
set_default_stacksize (stacksize);
/* Round the resource limit up to page size. */
limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz;
__default_stacksize = limit.rlim_cur;
#ifdef SHARED
/* Transfer the old value from the dynamic linker's internal location. */