remove no-longer-needed unblocking of signals in pthread_create
[musl] / src / thread / pthread_self.c
1 #include "pthread_impl.h"
2
3 static struct pthread main_thread;
4
5 /* pthread_key_create.c overrides this */
6 static const void *dummy[1] = { 0 };
7 weak_alias(dummy, __pthread_tsd_main);
8
9 static int init_main_thread()
10 {
11         __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, 8);
12         if (__set_thread_area(&main_thread) < 0) return -1;
13         main_thread.canceldisable = libc.canceldisable;
14         main_thread.tsd = (void **)__pthread_tsd_main;
15         main_thread.errno_ptr = __errno_location();
16         main_thread.self = &main_thread;
17         main_thread.tid = main_thread.pid =
18                 __syscall(SYS_set_tid_address, &main_thread.tid);
19         libc.main_thread = &main_thread;
20         return 0;
21 }
22
23 pthread_t __pthread_self_def()
24 {
25         static int init, failed;
26         if (!init) {
27                 if (failed) return 0;
28                 if (init_main_thread() < 0) failed = 1;
29                 if (failed) return 0;
30                 init = 1;
31         }
32         return __pthread_self();
33 }
34
35 weak_alias(__pthread_self_def, pthread_self);
36 weak_alias(__pthread_self_def, __pthread_self_init);