diff options
Diffstat (limited to 'src/env/__reset_tls.c')
-rw-r--r-- | src/env/__reset_tls.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/env/__reset_tls.c b/src/env/__reset_tls.c new file mode 100644 index 00000000..28c4405e --- /dev/null +++ b/src/env/__reset_tls.c @@ -0,0 +1,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 |