aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog7
-rw-r--r--linuxthreads/pthread.c78
2 files changed, 51 insertions, 34 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index efc0143549..b4bab43888 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,10 @@
+2001-07-16 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread.c (pthread_initialize): For FLOATING_STACKS do't bother
+ to find the right value for __pthread_initial_thread_bos, it's not
+ used. If not FLOATING_STACKS first run
+ __pthread_init_max_stacksize.
+
2001-06-16 H.J. Lu <hjl@gnu.org>
* internals.h: Include <stackinfo.h>.
diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c
index 88fbf0ce0f..1321bd488b 100644
--- a/linuxthreads/pthread.c
+++ b/linuxthreads/pthread.c
@@ -401,6 +401,40 @@ __pthread_initialize_minimal(void)
}
+void
+__pthread_init_max_stacksize(void)
+{
+ struct rlimit limit;
+ size_t max_stack;
+
+ getrlimit(RLIMIT_STACK, &limit);
+#ifdef FLOATING_STACKS
+ if (limit.rlim_cur == RLIM_INFINITY)
+ limit.rlim_cur = ARCH_STACK_MAX_SIZE;
+# ifdef NEED_SEPARATE_REGISTER_STACK
+ max_stack = limit.rlim_cur / 2;
+# else
+ max_stack = limit.rlim_cur;
+# 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). */
+# ifdef NEED_SEPARATE_REGISTER_STACK
+ /* STACK_SIZE bytes hold both the main stack and register backing
+ store. The rlimit value applies to each individually. */
+ max_stack = STACK_SIZE/2 - __getpagesize ();
+# else
+ max_stack = STACK_SIZE - __getpagesize();
+# endif
+ if (limit.rlim_cur > max_stack) {
+ limit.rlim_cur = max_stack;
+ setrlimit(RLIMIT_STACK, &limit);
+ }
+#endif
+ __pthread_max_stacksize = max_stack;
+}
+
+
static void pthread_initialize(void)
{
struct sigaction sa;
@@ -412,16 +446,24 @@ static void pthread_initialize(void)
/* Test if compare-and-swap is available */
__pthread_has_cas = compare_and_swap_is_available();
#endif
-#ifdef _STACK_GROWS_UP
+#ifdef FLOATING_STACKS
+ /* We don't need to know the bottom of the stack. Give the pointer some
+ value to signal that initialization happened. */
+ __pthread_initial_thread_bos = (void *) -1l;
+#else
+ /* Determine stack size limits . */
+ __pthread_init_max_stacksize ();
+# ifdef _STACK_GROWS_UP
/* The initial thread already has all the stack it needs */
__pthread_initial_thread_bos = (char *)
((long)CURRENT_STACK_FRAME &~ (STACK_SIZE - 1));
-#else
+# else
/* For the initial stack, reserve at least STACK_SIZE bytes of stack
below the current stack address, and align that on a
STACK_SIZE boundary. */
__pthread_initial_thread_bos =
(char *)(((long)CURRENT_STACK_FRAME - 2 * STACK_SIZE) & ~(STACK_SIZE - 1));
+# endif
#endif
/* Update the descriptor for the initial thread. */
__pthread_initial_thread.p_pid = __getpid();
@@ -470,38 +512,6 @@ void __pthread_initialize(void)
pthread_initialize();
}
-void __pthread_init_max_stacksize(void)
-{
- struct rlimit limit;
- size_t max_stack;
-
- getrlimit(RLIMIT_STACK, &limit);
-#ifdef FLOATING_STACKS
- if (limit.rlim_cur == RLIM_INFINITY)
- limit.rlim_cur = ARCH_STACK_MAX_SIZE;
-# ifdef NEED_SEPARATE_REGISTER_STACK
- max_stack = limit.rlim_cur / 2;
-# else
- max_stack = limit.rlim_cur;
-# 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). */
-# ifdef NEED_SEPARATE_REGISTER_STACK
- /* STACK_SIZE bytes hold both the main stack and register backing
- store. The rlimit value applies to each individually. */
- max_stack = STACK_SIZE/2 - __getpagesize ();
-# else
- max_stack = STACK_SIZE - __getpagesize();
-# endif
- if (limit.rlim_cur > max_stack) {
- limit.rlim_cur = max_stack;
- setrlimit(RLIMIT_STACK, &limit);
- }
-#endif
- __pthread_max_stacksize = max_stack;
-}
-
int __pthread_initialize_manager(void)
{
int manager_pipe[2];