summaryrefslogtreecommitdiff
path: root/src/env/__reset_tls.c
blob: 28c4405efe4c2e36ef9fa472802a983ea5251abe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef SHARED

#include <string.h>
#include "pthread_impl.h"
#include "libc.h"

extern struct tls_image {
	void *image;
	size_t len, size, align;
} __static_tls ATTR_LIBC_VISIBILITY;

#define T __static_tls

void __reset_tls()
{
	if (!T.size) return;
	pthread_t self = __pthread_self();
	memcpy(self->dtv[1], T.image, T.len);
	memset((char *)self->dtv[1]+T.len, 0, T.size-T.len);
}

#endif