tls-macros-aarch64.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (C) 2009-2020 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public License as
  5. published by the Free Software Foundation; either version 2.1 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #define TLS_LD(x) TLS_GD(x)
  15. #define TLS_GD(x) \
  16. ({ register unsigned long __result asm ("x0"); \
  17. asm ("adrp %0, :tlsgd:" #x "; " \
  18. "add %0, %0, #:tlsgd_lo12:" #x "; " \
  19. "bl __tls_get_addr;" \
  20. "nop" \
  21. : "=r" (__result) \
  22. : \
  23. : "x1", "x2", "x3", "x4", "x5", "x6", \
  24. "x7", "x8", "x9", "x10", "x11", "x12", \
  25. "x13", "x14", "x15", "x16", "x17", "x18", \
  26. "x30", "memory", "cc"); \
  27. (int *) (__result); })
  28. #define TLS_IE(x) \
  29. ({ register unsigned long __result asm ("x0"); \
  30. register unsigned long __t; \
  31. asm ("mrs %1, tpidr_el0; " \
  32. "adrp %0, :gottprel:" #x "; " \
  33. "ldr %0, [%0, #:gottprel_lo12:" #x "]; " \
  34. "add %0, %0, %1" \
  35. : "=r" (__result), "=r" (__t)); \
  36. (int *) (__result); })
  37. #define TLS_LE(x) \
  38. ({ register unsigned long __result asm ("x0"); \
  39. asm ("mrs %0, tpidr_el0; " \
  40. "add %0, %0, :tprel_hi12:" #x "; " \
  41. "add %0, %0, :tprel_lo12_nc:" #x \
  42. : "=r" (__result)); \
  43. (int *) (__result); })