libc-tls.c 859 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Thread-local storage handling in statically linked binaries. SH version.
  3. * Copyright (C) 2009 Free Software Foundation, Inc.
  4. *
  5. * Based on GNU C Library (file: libc/sysdeps/sh/libc-tls.c)
  6. *
  7. * Copyright (C) 2010 STMicroelectronics Ltd.
  8. * Author: Filippo Arcidiacono <filippo.arcidiacono@st.com>
  9. *
  10. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  11. *
  12. */
  13. #include <sysdeps/generic/libc-tls.c>
  14. #include <dl-tls.h>
  15. #if defined (USE_TLS) && (USE_TLS)
  16. /* On SH, linker optimizations are not required, so __tls_get_addr
  17. can be called even in statically linked binaries. In this case module
  18. must be always 1 and PT_TLS segment exist in the binary, otherwise it
  19. would not link. */
  20. void *
  21. __tls_get_addr (tls_index *ti)
  22. {
  23. dtv_t *dtv = THREAD_DTV ();
  24. return (char *) dtv[1].pointer.val + ti->ti_offset;
  25. }
  26. #endif