Debian Codegraph @

libc-top-half/musl/src/env/__reset_tls.c

raw
1 #include <string.h>
2 #include "pthread_impl.h"
3 #include "libc.h"
4
5 void __reset_tls()
6 {
7 pthread_t self = __pthread_self();
8 struct tls_module *p;
9 size_t i, n = self->dtv[0];
10 if (n) for (p=libc.tls_head, i=1; i<=n; i++, p=p->next) {
11 char *mem = (char *)(self->dtv[i] - DTP_OFFSET);
12 memcpy(mem, p->image, p->len);
13 memset(mem+p->len, 0, p->size - p->len);
14 }
15 }