From 714413a7694ff534855e9e5904899695eac6c9bb Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 24 Oct 2013 11:44:52 +0200 Subject: Really use user-provided stack * pthread/pt-create.c (__pthread_create_internal): When the user provides a `stackaddr`, use it instead of allocating a stack. * pthread/pt-detach.c (pthread_detach): Only deallocate the stack when it was allocated by libpthread. * pthread/pt-join.c (pthread_join): Likewise. --- pthread/pt-create.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'pthread/pt-create.c') diff --git a/pthread/pt-create.c b/pthread/pt-create.c index 723aa81..fd6800f 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -129,13 +129,19 @@ __pthread_create_internal (struct __pthread **thread, } else { - err = __pthread_stack_alloc (&pthread->stackaddr, - setup->stacksize); - if (err) - goto failed_stack_alloc; - pthread->stacksize = setup->stacksize; - pthread->stack = 1; + + if (setup->stackaddr) + pthread->stackaddr = setup->stackaddr; + else + { + err = __pthread_stack_alloc (&pthread->stackaddr, + setup->stacksize); + if (err) + goto failed_stack_alloc; + + pthread->stack = 1; + } } /* Allocate the kernel thread and other required resources. */ -- cgit v1.2.3