X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fthread%2Fpthread_create.c;h=48290d35b38afbd9ee3de844c84040be121870e1;hb=2121b8a44f086f6fb8aed98102379e7de9a4a5f1;hp=c3b65ae955ab2b3757a32cf4f1597b87fb669361;hpb=58aa5f45ed3282751ae118c107ff008d4df765dc;p=musl diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index c3b65ae9..48290d35 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -43,14 +43,14 @@ void pthread_exit(void *result) __syscall(SYS_exit, 0); } -void __do_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x) +void __do_cleanup_push(struct __ptcb *cb) { struct pthread *self = pthread_self(); cb->__next = self->cancelbuf; self->cancelbuf = cb; } -void __do_cleanup_pop(struct __ptcb *cb, int run) +void __do_cleanup_pop(struct __ptcb *cb) { __pthread_self()->cancelbuf = cb->__next; } @@ -95,20 +95,23 @@ int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(vo init_file_lock(__stdin_used); init_file_lock(__stdout_used); init_file_lock(__stderr_used); - __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, 8); libc.threaded = 1; } - if (attr) { - guard = ROUND(attr->_a_guardsize + DEFAULT_GUARD_SIZE); - size = guard + ROUND(attr->_a_stacksize + DEFAULT_STACK_SIZE); + if (attr && attr->_a_stackaddr) { + map = 0; + tsd = (void *)(attr->_a_stackaddr-__pthread_tsd_size & -16); + } else { + if (attr) { + guard = ROUND(attr->_a_guardsize + DEFAULT_GUARD_SIZE); + size = guard + ROUND(attr->_a_stacksize + DEFAULT_STACK_SIZE); + } + size += __pthread_tsd_size; + map = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0); + if (map == MAP_FAILED) return EAGAIN; + if (guard) mprotect(map, guard, PROT_NONE); + tsd = map + size - __pthread_tsd_size; } - size += __pthread_tsd_size; - map = mmap(0, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0); - if (map == MAP_FAILED) return EAGAIN; - if (guard) mprotect(map, guard, PROT_NONE); - - tsd = map + size - __pthread_tsd_size; new = (void *)(tsd - sizeof *new - PAGE_SIZE%sizeof *new); new->map_base = map; new->map_size = size;