about summary refs log tree commit diff
path: root/linuxthreads
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog9
-rw-r--r--linuxthreads/attr.c11
-rw-r--r--linuxthreads/internals.h1
-rw-r--r--linuxthreads/pthread.c34
4 files changed, 31 insertions, 24 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 3eb7bcbdeb..8d680babb3 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,12 @@
+2001-02-23  Jakub Jelinek  <jakub@redhat.com>
+
+	* internals.h (__pthread_init_max_stacksize): New prototype.
+	* attr.c (__pthread_attr_setstacksize): Call
+	__pthread_init_max_stacksize if not yet initialized.
+	* pthread.c (__pthread_init_max_stacksize): New function.
+	(__pthread_initialize_manager): Call it.
+	Patch by <dtc@cmucl.cons.org>.
+
 2001-03-16  Ulrich Drepper  <drepper@redhat.com>
 
 	* attr.c (pthread_getattr_np): Fix __stacksize computation for IA-64.
diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c
index 3553069c2e..623b9ba64d 100644
--- a/linuxthreads/attr.c
+++ b/linuxthreads/attr.c
@@ -193,16 +193,7 @@ int __pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
      problem if the manager is already started and we determined it.  If
      this hasn't happened, we have to find the limit outself.  */
   if (__pthread_max_stacksize == 0)
-    {
-      struct rlimit limit;
-
-      getrlimit(RLIMIT_STACK, &limit);
-# ifdef NEED_SEPARATE_REGISTER_STACK
-      __pthread_max_stacksize = limit.rlim_max / 2;
-# else
-      __pthread_max_stacksize = limit.rlim_max;
-# endif
-    }
+    __pthread_init_max_stacksize ();
 
   if (stacksize > __pthread_max_stacksize)
     return EINVAL;
diff --git a/linuxthreads/internals.h b/linuxthreads/internals.h
index f3f8af2c8e..ba0c14d29d 100644
--- a/linuxthreads/internals.h
+++ b/linuxthreads/internals.h
@@ -430,6 +430,7 @@ static inline pthread_descr thread_self (void)
 
 extern void __pthread_destroy_specifics (void);
 extern void __pthread_perform_cleanup (void);
+extern void __pthread_init_max_stacksize (void);
 extern int __pthread_initialize_manager (void);
 extern void __pthread_message (char * fmt, ...);
 extern int __pthread_manager (void *reqfd);
diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c
index 5a2ade7446..b1c6186683 100644
--- a/linuxthreads/pthread.c
+++ b/linuxthreads/pthread.c
@@ -456,19 +456,10 @@ void __pthread_initialize(void)
   pthread_initialize();
 }
 
-int __pthread_initialize_manager(void)
+void __pthread_init_max_stacksize(void)
 {
-  int manager_pipe[2];
-  int pid;
-  struct pthread_request request;
   struct rlimit limit;
-  int max_stack;
-
-#ifndef HAVE_Z_NODELETE
-  if (__builtin_expect (&__dso_handle != NULL, 1))
-    __cxa_atexit ((void (*) (void *)) pthread_atexit_retcode, NULL,
-		  __dso_handle);
-#endif
+  size_t max_stack;
 
   getrlimit(RLIMIT_STACK, &limit);
 #ifdef FLOATING_STACKS
@@ -478,9 +469,7 @@ int __pthread_initialize_manager(void)
   max_stack = limit.rlim_cur / 2;
 # else
   max_stack = limit.rlim_cur;
-#endif
-
-  __pthread_max_stacksize = max_stack;
+# endif
 #else
   /* Play with the stack size limit to make sure that no stack ever grows
      beyond STACK_SIZE minus one page (to act as a guard page). */
@@ -496,6 +485,23 @@ int __pthread_initialize_manager(void)
     setrlimit(RLIMIT_STACK, &limit);
   }
 #endif
+  __pthread_max_stacksize = max_stack;
+}
+
+int __pthread_initialize_manager(void)
+{
+  int manager_pipe[2];
+  int pid;
+  struct pthread_request request;
+
+#ifndef HAVE_Z_NODELETE
+  if (__builtin_expect (&amp;__dso_handle != NULL, 1))
+    __cxa_atexit ((void (*) (void *)) pthread_atexit_retcode, NULL,
+		  __dso_handle);
+#endif
+
+  if (__pthread_max_stacksize == 0)
+    __pthread_init_max_stacksize ();
   /* If basic initialization not done yet (e.g. we're called from a
      constructor run before our constructor), do it now */
   if (__pthread_initial_thread_bos == NULL) pthread_initialize();