tls-macros-sparc.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #define TLS_LE(x) \
  2. ({ int *__l; \
  3. __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
  4. __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
  5. __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
  6. __l; })
  7. #ifdef __PIC__
  8. # define TLS_LOAD_PIC \
  9. ({ register long pc __asm__ ("%o7"); \
  10. long got; \
  11. __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
  12. "call .+8\n\t" \
  13. "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
  14. "add %1, %0, %1\n\t" \
  15. : "=r" (pc), "=r" (got)); \
  16. got; })
  17. #else
  18. # define TLS_LOAD_PIC \
  19. ({ long got; \
  20. __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
  21. "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
  22. "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
  23. : "=r" (got)); \
  24. got; })
  25. #endif
  26. #define TLS_IE(x) \
  27. ({ int *__l; \
  28. __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
  29. __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
  30. __asm__ ("ld [%1 + %2], %0, %%tie_ld(" #x ")" \
  31. : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
  32. __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
  33. __l; })
  34. #define TLS_LD(x) \
  35. ({ int *__l; register void *__o0 __asm__ ("%o0"); \
  36. long __o; \
  37. __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
  38. __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
  39. __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
  40. : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
  41. __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
  42. " nop" \
  43. : "=r" (__o0) : "0" (__o0) \
  44. : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
  45. "o5", "o7", "cc"); \
  46. __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
  47. __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
  48. __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
  49. : "r" (__o0), "r" (__o)); \
  50. __l; })
  51. #define TLS_GD(x) \
  52. ({ int *__l; register void *__o0 __asm__ ("%o0"); \
  53. __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
  54. __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
  55. __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
  56. : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
  57. __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
  58. " nop" \
  59. : "=r" (__o0) : "0" (__o0) \
  60. : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
  61. "o5", "o7", "cc"); \
  62. __o0; })