__reset_tls.c 391 B

12345678910111213141516171819202122
  1. #ifndef SHARED
  2. #include <string.h>
  3. #include "pthread_impl.h"
  4. #include "libc.h"
  5. extern struct tls_image {
  6. void *image;
  7. size_t len, size, align;
  8. } __static_tls ATTR_LIBC_VISIBILITY;
  9. #define T __static_tls
  10. void __reset_tls()
  11. {
  12. if (!T.size) return;
  13. pthread_t self = __pthread_self();
  14. memcpy(self->dtv[1], T.image, T.len);
  15. memset((char *)self->dtv[1]+T.len, 0, T.size-T.len);
  16. }
  17. #endif