{
pthread_t td = p;
td->self = td;
- if (__set_thread_area(TP_ADJ(p)) < 0)
- return -1;
- td->tid = td->pid = __syscall(SYS_set_tid_address, &td->tid);
- td->errno_ptr = &td->errno_val;
- /* Currently, both of these predicates depend in the same thing:
- * successful initialization of the thread pointer. However, in
- * the future, we may support setups where setting the thread
- * pointer is possible but threads other than the main thread
- * cannot work, so it's best to keep the predicates separate. */
+ int r = __set_thread_area(TP_ADJ(p));
+ if (r < 0) return -1;
+ if (!r) libc.can_do_threads = 1;
libc.has_thread_pointer = 1;
- libc.can_do_threads = 1;
+ td->tid = __syscall(SYS_set_tid_address, &td->tid);
+ td->locale = &libc.global_locale;
return 0;
}
return td;
}
-void *__tls_get_addr(size_t *v)
-{
- return (char *)__pthread_self()->dtv[1]+v[1];
-}
-
-void *__mmap(void *, size_t, int, int, int, off_t);
-
#if ULONG_MAX == 0xffffffff
typedef Elf32_Phdr Phdr;
#else
libc.tls_size = 2*sizeof(void *)+T.size+T.align+sizeof(struct pthread);
if (libc.tls_size > sizeof builtin_tls) {
+#ifndef SYS_mmap2
+#define SYS_mmap2 SYS_mmap
+#endif
mem = (void *)__syscall(
-#ifdef SYS_mmap2
SYS_mmap2,
-#else
- SYS_mmap,
-#endif
0, libc.tls_size, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
/* -4095...-1 cast to void * will crash on dereference anyway,