diff options
-rw-r--r-- | pthread/pt-create.c | 18 | ||||
-rw-r--r-- | pthread/pt-detach.c | 8 | ||||
-rw-r--r-- | pthread/pt-join.c | 8 |
3 files changed, 22 insertions, 12 deletions
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. */ diff --git a/pthread/pt-detach.c b/pthread/pt-detach.c index 1e42c45..4ed8d2c 100644 --- a/pthread/pt-detach.c +++ b/pthread/pt-detach.c @@ -66,9 +66,11 @@ pthread_detach (pthread_t thread) /* Destroy the stack, the kernel resources and the control block. */ - assert (pthread->stack); - __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize); - pthread->stack = 0; + if (pthread->stack) + { + __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize); + pthread->stack = 0; + } __pthread_thread_dealloc (pthread); diff --git a/pthread/pt-join.c b/pthread/pt-join.c index 8bd2c6c..417f433 100644 --- a/pthread/pt-join.c +++ b/pthread/pt-join.c @@ -64,9 +64,11 @@ pthread_join (pthread_t thread, void **status) /* Destroy the stack, the kernel resources and the control block. */ - assert (pthread->stack); - __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize); - pthread->stack = 0; + if (pthread->stack) + { + __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize); + pthread->stack = 0; + } __pthread_thread_dealloc (pthread); |