X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fthread%2Fpthread_create.c;h=6e2e48161753e03f0296e97383b7e081b711fb32;hb=3366a99b17847b58f2d8cc52cbb5d65deb824f8a;hp=33808ce5989af851e8c30da5528188e47f0e716d;hpb=a2d3053354432f3e3b5a787c1527d4b414e9acb0;p=musl diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index 33808ce5..6e2e4816 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -17,6 +17,7 @@ weak_alias(dummy_0, __acquire_ptc); weak_alias(dummy_0, __release_ptc); weak_alias(dummy_0, __pthread_tsd_run_dtors); weak_alias(dummy_0, __do_orphaned_stdio_locks); +weak_alias(dummy_0, __dl_thread_cleanup); _Noreturn void __pthread_exit(void *result) { @@ -66,12 +67,6 @@ _Noreturn void __pthread_exit(void *result) exit(0); } - if (self->locale != &libc.global_locale) { - a_dec(&libc.uselocale_cnt); - if (self->locale->ctype_utf8) - a_dec(&libc.bytelocale_cnt_minus_1); - } - /* Process robust list in userspace to handle non-pshared mutexes * and the detached thread case where the robust list head will * be invalid when the kernel would process it. */ @@ -92,6 +87,7 @@ _Noreturn void __pthread_exit(void *result) __vm_unlock(); __do_orphaned_stdio_locks(); + __dl_thread_cleanup(); if (self->detached && self->map_base) { /* Detached threads must avoid the kernel clear_child_tid @@ -122,7 +118,6 @@ _Noreturn void __pthread_exit(void *result) void __do_cleanup_push(struct __ptcb *cb) { - if (!libc.has_thread_pointer) return; struct pthread *self = __pthread_self(); cb->__next = self->cancelbuf; self->cancelbuf = cb; @@ -130,7 +125,6 @@ void __do_cleanup_push(struct __ptcb *cb) void __do_cleanup_pop(struct __ptcb *cb) { - if (!libc.has_thread_pointer) return; __pthread_self()->cancelbuf = cb->__next; } @@ -197,8 +191,9 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att if (!libc.can_do_threads) return ENOSYS; self = __pthread_self(); if (!libc.threaded) { - for (FILE *f=libc.ofl_head; f; f=f->next) + for (FILE *f=*__ofl_lock(); f; f=f->next) init_file_lock(f); + __ofl_unlock(); init_file_lock(__stdin_used); init_file_lock(__stdout_used); init_file_lock(__stderr_used); @@ -272,7 +267,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att } new->robust_list.head = &new->robust_list.head; new->unblock_cancel = self->cancel; - new->canary = self->canary; + new->CANARY = self->CANARY; a_inc(&libc.threads_minus_1); ret = __clone((c11 ? start_c11 : start), stack, flags, new, &new->tid, TP_ADJ(new), &new->tid);