summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/uthread/uthread_stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc_r/uthread/uthread_stack.c')
-rw-r--r--lib/libc_r/uthread/uthread_stack.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc_r/uthread/uthread_stack.c b/lib/libc_r/uthread/uthread_stack.c
index 055af07..86f0a2d 100644
--- a/lib/libc_r/uthread/uthread_stack.c
+++ b/lib/libc_r/uthread/uthread_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;
/*
OpenPOWER on IntegriCloud