tls-macros-arm.h 1.4 KB

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