about summary refs log tree commit diff
path: root/nptl/nptl-init.c
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@redhat.com>2013-03-01 16:18:08 -0500
committerCarlos O'Donell <carlos@redhat.com>2013-03-01 16:18:08 -0500
commit4e9b5995775c99e029ed4003aaddb88bfbf8e2cd (patch)
tree971f5f28317f29e5c3547bffff8c8bde28ba71e8 /nptl/nptl-init.c
parentace4acc8ace692f64051594afe47efb1135b3c29 (diff)
downloadglibc-4e9b5995775c99e029ed4003aaddb88bfbf8e2cd.tar.gz
glibc-4e9b5995775c99e029ed4003aaddb88bfbf8e2cd.tar.xz
glibc-4e9b5995775c99e029ed4003aaddb88bfbf8e2cd.zip
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.
Diffstat (limited to 'nptl/nptl-init.c')
-rw-r--r--nptl/nptl-init.c74
1 files changed, 22 insertions, 52 deletions
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 50148224e8..19e6616420 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -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;
-
-#ifndef SHARED
-    __libc_init_secure ();
-#endif
-
-  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);
+  /* 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;
 
-      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;
-    }
+  /* 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;
 
-  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.  */