libc-tls.c 621 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright (C) 2017 Hangzhou C-SKY Microsystems co.,ltd.
  3. *
  4. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB
  5. * in this tarball.
  6. */
  7. #include <sysdeps/generic/libc-tls.c>
  8. #include <dl-tls.h>
  9. #if defined(USE_TLS) && USE_TLS
  10. /* On CSKY, linker optimizations are not required, so __tls_get_addr
  11. can be called even in statically linked binaries. In this case module
  12. must be always 1 and PT_TLS segment exist in the binary, otherwise it
  13. would not link. */
  14. void *
  15. __tls_get_addr (tls_index *ti)
  16. {
  17. dtv_t *dtv = THREAD_DTV ();
  18. return (char *) dtv[1].pointer.val + ti->ti_offset;
  19. }
  20. #endif