fix fallback checks for kernels without private futex support
[musl] / src / thread / __tls_get_addr.c
1 #include <stddef.h>
2 #include "pthread_impl.h"
3 #include "libc.h"
4
5 void *__tls_get_new(size_t *) ATTR_LIBC_VISIBILITY;
6
7 void *__tls_get_addr(size_t *v)
8 {
9         pthread_t self = __pthread_self();
10 #ifdef SHARED
11         if (v[0]<=(size_t)self->dtv[0])
12                 return (char *)self->dtv[v[0]]+v[1];
13         return __tls_get_new(v);
14 #else
15         return (char *)self->dtv[1]+v[1];
16 #endif
17 }