From 75f928ffd9b3455a6ddb0737d60bb6e4bd3f8726 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 5 May 1994 16:00:09 +0000 Subject: entered into RCS --- libthreads/stack.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libthreads/stack.c') diff --git a/libthreads/stack.c b/libthreads/stack.c index 2cb50d91..322934a1 100644 --- a/libthreads/stack.c +++ b/libthreads/stack.c @@ -279,6 +279,7 @@ probe_stack(stack_bottom, stack_top) /* For GNU: */ unsigned long int __hurd_threadvar_stack_mask; unsigned long int __hurd_threadvar_stack_offset; +unsigned int __hurd_threadvar_max; vm_offset_t stack_init(p) @@ -310,7 +311,16 @@ stack_init(p) #endif STACK_GROWTH_UP /* Set up the variables so GNU can find its per-thread variables. */ - __hurd_threadvar_stack_mask = cthread_stack_mask; + __hurd_threadvar_stack_mask = ~(cthread_stack_size - 1); + /* The GNU per-thread variables will be stored just after the + cthread-self pointer at the base of the stack. */ +#ifdef STACK_GROWTH_UP + __hurd_threadvar_stack_offset = sizeof (ur_cthread_t *); +#else + __hurd_threadvar_stack_offset = (cthread_stack_size - + sizeof (ur_cthread_t *) - + __hurd_threadvar_max * sizeof (long)); +#endif /* * Guess at first available region for stack. @@ -336,10 +346,6 @@ stack_init(p) #endif STACK_GROWTH_UP MACH_CALL(vm_deallocate(mach_task_self(),start,size),r); - /* The GNU per-thread variables will be stored just after the - cthread-self pointer at the base of the stack. */ - __hurd_threadvar_stack_offset = sizeof (ur_cthread_t *); - /* * Return new stack; it gets passed back to the caller * of cthread_init who must switch to it. -- cgit v1.2.3