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.tlsdesc[0] = -1;
14 main_thread.tlsdesc[1] = (long)&main_thread;
15 main_thread.tlsdesc[2] = SIZE_MAX/PAGE_SIZE;
16 main_thread.tlsdesc[3] = 0x51;
17 main_thread.self = &main_thread;
18 main_thread.errno_ptr = __errno_location();
19 if (__set_thread_area(main_thread.tlsdesc) < 0)
21 syscall1(__NR_set_tid_address, (long)&main_thread.tid);
22 libc.errno_location = errno_location;
23 main_thread.tid = main_thread.pid = getpid();
29 pthread_t pthread_self()
31 static int init, failed;
34 if (init_main_thread() < 0) failed = 1;
38 return __pthread_self();