summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/env/__reset_tls.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/env/__reset_tls.c')
-rw-r--r--libc-top-half/musl/src/env/__reset_tls.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/env/__reset_tls.c b/libc-top-half/musl/src/env/__reset_tls.c
new file mode 100644
index 0000000..15685bc
--- /dev/null
+++ b/libc-top-half/musl/src/env/__reset_tls.c
@@ -0,0 +1,15 @@
+#include <string.h>
+#include "pthread_impl.h"
+#include "libc.h"
+
+void __reset_tls()
+{
+ pthread_t self = __pthread_self();
+ struct tls_module *p;
+ size_t i, n = self->dtv[0];
+ if (n) for (p=libc.tls_head, i=1; i<=n; i++, p=p->next) {
+ char *mem = (char *)(self->dtv[i] - DTP_OFFSET);
+ memcpy(mem, p->image, p->len);
+ memset(mem+p->len, 0, p->size - p->len);
+ }
+}