tls-macros-thumb.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #define TLS_LE(x) \
  2. ({ int *__result; \
  3. void *tp = __builtin_thread_pointer (); \
  4. __asm__ ("ldr %0, 1f; " \
  5. "add %0, %1, %0; " \
  6. "b 2f; " \
  7. ".align 2; " \
  8. "1: .word " #x "(tpoff); " \
  9. "2: " \
  10. : "=&r" (__result) : "r" (tp)); \
  11. __result; })
  12. #define TLS_IE(x) \
  13. ({ int *__result; \
  14. int tmp; \
  15. void *tp = __builtin_thread_pointer (); \
  16. __asm__ ("ldr %0, 1f; " \
  17. "adr %1, 1f; " \
  18. "ldr %0, [%1, %0]; " \
  19. "add %0, %2, %0; " \
  20. "b 2f; " \
  21. ".align 2; " \
  22. "1: .word " #x "(gottpoff); " \
  23. "2: " \
  24. : "=&r" (__result), "=&r"(tmp) : "r" (tp)); \
  25. __result; })
  26. #define TLS_LD(x) \
  27. ({ char *__result; \
  28. int __offset; \
  29. extern void *__tls_get_addr (void *); \
  30. __asm__ ("ldr %0, 2f; " \
  31. ".align 2; " \
  32. "1: add %0, pc, %0; " \
  33. "b 3f; " \
  34. "2: .word " #x "(tlsldm) + (. - 1b - 4); " \
  35. "3: " \
  36. : "=r" (__result)); \
  37. __result = (char *)__tls_get_addr (__result); \
  38. __asm__ ("ldr %0, 1f; " \
  39. "b 2f; " \
  40. "1: .word " #x "(tlsldo); " \
  41. "2: " \
  42. : "=r" (__offset)); \
  43. (int *) (__result + __offset); })
  44. #define TLS_GD(x) \
  45. ({ int *__result; \
  46. extern void *__tls_get_addr (void *); \
  47. __asm__ ("ldr %0, 2f; " \
  48. ".align 2; " \
  49. "1: add %0, pc, %0; " \
  50. "b 3f; " \
  51. "2: .word " #x "(tlsgd) + (. - 1b - 4); " \
  52. "3: " \
  53. : "=r" (__result)); \
  54. (int *)__tls_get_addr (__result); })