From eb9053b12f317bc99d9e7733d0d18541d7d09e03 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Fri, 26 Oct 2001 21:19:22 +0000 Subject: Make libc_r check the kern.usrstack sysctl instead of using internal kernel #defines to figure out where the stack is located. This stops libc_r from exploding when the kernel is compiled with a different KVM size. IMHO this is all kinda bogus, it would be better to just check %esp and work from that. --- lib/libpthread/thread/thr_stack.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/libpthread/thread/thr_stack.c') diff --git a/lib/libpthread/thread/thr_stack.c b/lib/libpthread/thread/thr_stack.c index 055af076c94f..86f0a2dff193 100644 --- a/lib/libpthread/thread/thr_stack.c +++ b/lib/libpthread/thread/thr_stack.c @@ -112,8 +112,7 @@ static LIST_HEAD(, stack) _mstackq = LIST_HEAD_INITIALIZER(_mstackq); * high memory * */ -static void * last_stack = (void *) USRSTACK - PTHREAD_STACK_INITIAL - - PTHREAD_GUARD_DEFAULT; +static void * last_stack; void * _thread_stack_alloc(size_t stacksize, size_t guardsize) @@ -186,8 +185,11 @@ _thread_stack_alloc(size_t stacksize, size_t guardsize) /* Check if a stack was not allocated from a stack cache: */ if (stack == NULL) { - /* Allocate a new stack. */ + if (last_stack == NULL) + last_stack = _usrstack - PTHREAD_STACK_INITIAL - + PTHREAD_GUARD_DEFAULT; + /* Allocate a new stack. */ stack = last_stack - stack_size; /* -- cgit v1.2.3