1 #include "pthread_impl.h"
3 static struct pthread main_thread;
6 static int *errno_location()
8 return __pthread_self()->errno_ptr;
11 static int init_main_thread()
13 main_thread.self = &main_thread;
14 if (__set_thread_area(&main_thread) < 0)
16 syscall1(__NR_set_tid_address, (long)&main_thread.tid);
17 main_thread.errno_ptr = __errno_location();
18 libc.errno_location = errno_location;
19 main_thread.tid = main_thread.pid = getpid();
23 pthread_t pthread_self()
25 static int init, failed;
28 if (init_main_thread() < 0) failed = 1;
32 return __pthread_self();