tls-macros-m68k.h 2.3 KB

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