Rich Felker | 7c6c290 | 2013-08-03 16:27:30 -0400 | [diff] [blame] | 1 | #include <string.h> |
| 2 | #include "pthread_impl.h" |
Rich Felker | d56460c | 2015-11-12 15:50:26 -0500 | [diff] [blame] | 3 | #include "libc.h" |
Rich Felker | 7c6c290 | 2013-08-03 16:27:30 -0400 | [diff] [blame] | 4 | |
| 5 | void __reset_tls() |
| 6 | { |
Rich Felker | 7c6c290 | 2013-08-03 16:27:30 -0400 | [diff] [blame] | 7 | pthread_t self = __pthread_self(); |
Rich Felker | d56460c | 2015-11-12 15:50:26 -0500 | [diff] [blame] | 8 | 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 Felker | 7c6c290 | 2013-08-03 16:27:30 -0400 | [diff] [blame] | 16 | } |