tls-macros.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Macros for accessing thread-local storage. m68k version.
  2. Copyright (C) 2010-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library. If not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #define TLS_GD(x) \
  17. ({ \
  18. void *__result; \
  19. extern void *__tls_get_addr (void *); \
  20. \
  21. asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t" \
  22. "lea (-6, %%pc, %0), %0\n\t" \
  23. "lea " #x "@TLSGD(%0), %0" \
  24. : "=&a" (__result)); \
  25. (int *) __tls_get_addr (__result); })
  26. #define TLS_LD(x) \
  27. ({ \
  28. char *__tp; \
  29. int __offset; \
  30. extern void *__tls_get_addr (void *); \
  31. \
  32. asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t" \
  33. "lea (-6, %%pc, %0), %0\n\t" \
  34. "lea " #x "@TLSLDM(%0), %0" \
  35. : "=&a" (__tp)); \
  36. __tp = (char *) __tls_get_addr (__tp); \
  37. asm ("movel #" #x "@TLSLDO, %0" \
  38. : "=a" (__offset)); \
  39. (int *) (__tp + __offset); })
  40. #define TLS_IE(x) \
  41. ({ \
  42. char *__tp; \
  43. int __offset; \
  44. extern void * __m68k_read_tp (void); \
  45. \
  46. __tp = (char *) __m68k_read_tp (); \
  47. asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t" \
  48. "lea (-6, %%pc, %0), %0\n\t" \
  49. "movel " #x "@TLSIE(%0), %0" \
  50. : "=&a" (__offset)); \
  51. (int *) (__tp + __offset); })
  52. #define TLS_LE(x) \
  53. ({ \
  54. char *__tp; \
  55. int __offset; \
  56. extern void * __m68k_read_tp (void); \
  57. \
  58. __tp = (char *) __m68k_read_tp (); \
  59. asm ("movel #" #x "@TLSLE, %0" \
  60. : "=a" (__offset)); \
  61. (int *) (__tp + __offset); })