lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* Macros to support TLS testing in times of missing compiler support. */ |
| 2 | |
| 3 | extern void *__tls_get_addr (void *); |
| 4 | |
| 5 | # define TLS_GD(x) \ |
| 6 | ({ register void *__gp asm ("$29"); void *__result; \ |
| 7 | asm ("lda %0, " #x "($gp) !tlsgd" : "=r" (__result) : "r"(__gp)); \ |
| 8 | __tls_get_addr (__result); }) |
| 9 | |
| 10 | # define TLS_LD(x) \ |
| 11 | ({ register void *__gp asm ("$29"); void *__result; \ |
| 12 | asm ("lda %0, " #x "($gp) !tlsldm" : "=r" (__result) : "r"(__gp)); \ |
| 13 | __result = __tls_get_addr (__result); \ |
| 14 | asm ("lda %0, " #x "(%0) !dtprel" : "+r" (__result)); \ |
| 15 | __result; }) |
| 16 | |
| 17 | # define TLS_IE(x) \ |
| 18 | ({ register void *__gp asm ("$29"); long ofs; \ |
| 19 | asm ("ldq %0, " #x "($gp) !gottprel" : "=r"(ofs) : "r"(__gp)); \ |
| 20 | __builtin_thread_pointer () + ofs; }) |
| 21 | |
| 22 | # define TLS_LE(x) \ |
| 23 | ({ void *__result = __builtin_thread_pointer (); \ |
| 24 | asm ("lda %0, " #x "(%0) !tprel" : "+r" (__result)); \ |
| 25 | __result; }) |