blob: 677e57f58b45c6db27c9d1f0ceda3f1b72b08c95 [file] [log] [blame]
Rich Felker7c6c2902013-08-03 16:27:30 -04001#include <string.h>
2#include "pthread_impl.h"
Rich Felkerd56460c2015-11-12 15:50:26 -05003#include "libc.h"
Rich Felker7c6c2902013-08-03 16:27:30 -04004
5void __reset_tls()
6{
Rich Felker7c6c2902013-08-03 16:27:30 -04007 pthread_t self = __pthread_self();
Rich Felkerd56460c2015-11-12 15:50:26 -05008 struct tls_module *p;
9 size_t i, n = (size_t)self->dtv[0];
10 if (n) for (p=libc.tls_head, i=1; i<=n; i++, p=p->next) {
11 if (!self->dtv[i]) continue;
12 memcpy(self->dtv[i], p->image, p->len);
13 memset((char *)self->dtv[i]+p->len, 0,
14 p->size - p->len);
15 }
Rich Felker7c6c2902013-08-03 16:27:30 -040016}