lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 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 | |
| 13 | #define TLS_IE(x) \ |
| 14 | ({ int *__result; \ |
| 15 | int tmp; \ |
| 16 | void *tp = __builtin_thread_pointer (); \ |
| 17 | __asm__ ("ldr %0, 1f; " \ |
| 18 | "adr %1, 1f; " \ |
| 19 | "ldr %0, [%1, %0]; " \ |
| 20 | "add %0, %2, %0; " \ |
| 21 | "b 2f; " \ |
| 22 | ".align 2; " \ |
| 23 | "1: .word " #x "(gottpoff); " \ |
| 24 | "2: " \ |
| 25 | : "=&r" (__result), "=&r"(tmp) : "r" (tp)); \ |
| 26 | __result; }) |
| 27 | |
| 28 | #define TLS_LD(x) \ |
| 29 | ({ char *__result; \ |
| 30 | int __offset; \ |
| 31 | extern void *__tls_get_addr (void *); \ |
| 32 | __asm__ ("ldr %0, 2f; " \ |
| 33 | ".align 2; " \ |
| 34 | "1: add %0, pc, %0; " \ |
| 35 | "b 3f; " \ |
| 36 | "2: .word " #x "(tlsldm) + (. - 1b - 4); " \ |
| 37 | "3: " \ |
| 38 | : "=r" (__result)); \ |
| 39 | __result = (char *)__tls_get_addr (__result); \ |
| 40 | __asm__ ("ldr %0, 1f; " \ |
| 41 | "b 2f; " \ |
| 42 | "1: .word " #x "(tlsldo); " \ |
| 43 | "2: " \ |
| 44 | : "=r" (__offset)); \ |
| 45 | (int *) (__result + __offset); }) |
| 46 | |
| 47 | #define TLS_GD(x) \ |
| 48 | ({ int *__result; \ |
| 49 | extern void *__tls_get_addr (void *); \ |
| 50 | __asm__ ("ldr %0, 2f; " \ |
| 51 | ".align 2; " \ |
| 52 | "1: add %0, pc, %0; " \ |
| 53 | "b 3f; " \ |
| 54 | "2: .word " #x "(tlsgd) + (. - 1b - 4); " \ |
| 55 | "3: " \ |
| 56 | : "=r" (__result)); \ |
| 57 | (int *)__tls_get_addr (__result); }) |