1 #include "pthread_impl.h"
3 static struct pthread main_thread;
5 /* pthread_key_create.c overrides this */
6 static const void *dummy[1] = { 0 };
7 weak_alias(dummy, __pthread_tsd_main);
10 static int *errno_location()
12 return __pthread_self()->errno_ptr;
15 static int init_main_thread()
17 main_thread.canceldisable = libc.canceldisable;
18 main_thread.tsd = (void **)__pthread_tsd_main;
19 main_thread.self = &main_thread;
20 if (__set_thread_area(&main_thread) < 0)
22 main_thread.errno_ptr = __errno_location();
23 libc.errno_location = errno_location;
24 main_thread.tid = main_thread.pid =
25 __syscall(SYS_set_tid_address, &main_thread.tid);
29 pthread_t pthread_self()
31 static int init, failed;
34 if (init_main_thread() < 0) failed = 1;
38 return __pthread_self();