__reset_tls.c 365 B

123456789101112131415
  1. #include <string.h>
  2. #include "pthread_impl.h"
  3. #include "libc.h"
  4. void __reset_tls()
  5. {
  6. pthread_t self = __pthread_self();
  7. struct tls_module *p;
  8. size_t i, n = self->dtv[0];
  9. if (n) for (p=libc.tls_head, i=1; i<=n; i++, p=p->next) {
  10. char *mem = (char *)(self->dtv[i] - DTP_OFFSET);
  11. memcpy(mem, p->image, p->len);
  12. memset(mem+p->len, 0, p->size - p->len);
  13. }
  14. }