lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #define TLS_LE(x) \ |
| 2 | ({ int *__result; \ |
| 3 | asm ("addi %0, r23, %%tls_le(" #x ")" \ |
| 4 | : "=r" (__result)); \ |
| 5 | __result; }) |
| 6 | |
| 7 | #define TLS_IE(x) \ |
| 8 | ({ int *__result; \ |
| 9 | int __tmp; \ |
| 10 | asm ("nextpc %0 ; " \ |
| 11 | "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \ |
| 12 | "addi %1, %1, %%lo(_gp_got - 1b) ; " \ |
| 13 | "add %0, %0, %1 ; " \ |
| 14 | "ldw %1, %%tls_ie(" #x ")(%0) ; " \ |
| 15 | "add %1, r23, %1" \ |
| 16 | : "=&r" (__tmp), "=&r" (__result)); \ |
| 17 | __result; }) |
| 18 | |
| 19 | #define TLS_LD(x) \ |
| 20 | ({ char *__result; \ |
| 21 | char *__result2; \ |
| 22 | int *__result3; \ |
| 23 | int __tmp; \ |
| 24 | extern void *__tls_get_addr (void *); \ |
| 25 | asm ("nextpc %0 ; " \ |
| 26 | "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \ |
| 27 | "addi %1, %1, %%lo(_gp_got - 1b) ; " \ |
| 28 | "add %0, %0, %1 ; " \ |
| 29 | "addi %0, %0, %%tls_ldm(" #x ")" \ |
| 30 | : "=r" (__result), "=r" (__tmp)); \ |
| 31 | __result2 = (char *)__tls_get_addr (__result); \ |
| 32 | asm ("addi %0, %1, %%tls_ldo(" #x ")" \ |
| 33 | : "=r" (__result3) : "r" (__result2)); \ |
| 34 | __result3; }) |
| 35 | |
| 36 | #define TLS_GD(x) \ |
| 37 | ({ int *__result; \ |
| 38 | int __tmp; \ |
| 39 | extern void *__tls_get_addr (void *); \ |
| 40 | asm ("nextpc %0 ; " \ |
| 41 | "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \ |
| 42 | "addi %1, %1, %%lo(_gp_got - 1b) ; " \ |
| 43 | "add %0, %0, %1 ; " \ |
| 44 | "addi %0, %0, %%tls_gd(" #x ")" \ |
| 45 | : "=r" (__result), "=r" (__tmp)); \ |
| 46 | (int *)__tls_get_addr (__result); }) |