From 97e5da418f556182ba46220ed10c08d51dd2b798 Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 6 Dec 2018 05:17:10 +0000 Subject: [PATCH] libpthread-330.220.2.tar.gz --- src/pthread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pthread.c b/src/pthread.c index c9c1b9b..f9aa0dc 100644 --- a/src/pthread.c +++ b/src/pthread.c @@ -587,7 +587,7 @@ static pthread_t _pthread_allocate(const pthread_attr_t *attrs, void **stack) { mach_vm_address_t allocaddr = __pthread_stack_hint; - size_t allocsize, guardsize, stacksize; + size_t allocsize, guardsize, stacksize, pthreadoff; kern_return_t kr; pthread_t t; @@ -600,6 +600,7 @@ _pthread_allocate(const pthread_attr_t *attrs, void **stack) PTHREAD_ASSERT(((uintptr_t)attrs->stackaddr % vm_page_size) == 0); allocsize = PTHREAD_SIZE; guardsize = 0; + pthreadoff = 0; // if the attrs struct specifies a custom // stack address but not a custom size, using ->stacksize here instead // of _pthread_attr_stacksize stores stacksize as zero, indicating @@ -608,7 +609,8 @@ _pthread_allocate(const pthread_attr_t *attrs, void **stack) } else { guardsize = _pthread_attr_guardsize(attrs); stacksize = _pthread_attr_stacksize(attrs) + PTHREAD_T_OFFSET; - allocsize = stacksize + guardsize + PTHREAD_SIZE; + pthreadoff = stacksize + guardsize; + allocsize = pthreadoff + PTHREAD_SIZE; allocsize = mach_vm_round_page(allocsize); } @@ -637,7 +639,7 @@ _pthread_allocate(const pthread_attr_t *attrs, void **stack) // Thread structure resides at the top of the stack (when using a // custom stack, allocsize == PTHREAD_SIZE, so places the pthread_t // at allocaddr). - t = (pthread_t)(allocaddr + allocsize - PTHREAD_SIZE); + t = (pthread_t)(allocaddr + pthreadoff); if (attrs->stackaddr) { *stack = attrs->stackaddr; } else { -- 2.47.2