lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* TLS Access Macros for HP PARISC Linux */ |
| 2 | |
| 3 | /* HPPA Local Exec TLS access. */ |
| 4 | #define TLS_LE(x) \ |
| 5 | ({ int * __result; \ |
| 6 | unsigned long __tmp; \ |
| 7 | asm ( \ |
| 8 | " mfctl %%cr27, %1\n" \ |
| 9 | " addil LR'" #x "-$tls_leoff$, %1\n" \ |
| 10 | " ldo RR'" #x "-$tls_leoff$(%%r1), %0\n" \ |
| 11 | : "=r" (__result), "=r" (__tmp) \ |
| 12 | : \ |
| 13 | : "r1" ); \ |
| 14 | __result; \ |
| 15 | }) |
| 16 | |
| 17 | /* HPPA Initial Exec TLS access. */ |
| 18 | #ifdef PIC |
| 19 | # define TLS_IE(x) \ |
| 20 | ({ int * __result; \ |
| 21 | unsigned long __tmp, __tmp2; \ |
| 22 | asm ( \ |
| 23 | " mfctl %%cr27, %1\n" \ |
| 24 | " addil LT'" #x "-$tls_ieoff$, %%r19\n" \ |
| 25 | " ldw RT'" #x "-$tls_ieoff$(%%r1), %2\n" \ |
| 26 | " add %1, %2, %0\n" \ |
| 27 | : "=r" (__result), "=r" (__tmp), "=r" (__tmp2) \ |
| 28 | : \ |
| 29 | : "r1" ); \ |
| 30 | __result; \ |
| 31 | }) |
| 32 | #else |
| 33 | # define TLS_IE(x) \ |
| 34 | ({ int * __result; \ |
| 35 | unsigned long __tmp, __tmp2; \ |
| 36 | asm ( \ |
| 37 | " mfctl %%cr27, %1\n" \ |
| 38 | " addil LR'" #x "-$tls_ieoff$, %%r27\n" \ |
| 39 | " ldw RR'" #x "-$tls_ieoff$(%%r1), %2\n" \ |
| 40 | " add %1, %2, %0\n" \ |
| 41 | : "=r" (__result), "=r" (__tmp), "=r" (__tmp2) \ |
| 42 | : \ |
| 43 | : "r1" ); \ |
| 44 | __result; \ |
| 45 | }) |
| 46 | #endif |
| 47 | |
| 48 | #ifdef PIC |
| 49 | /* HPPA Local Dynamic TLS access. */ |
| 50 | # define TLS_LD(x) \ |
| 51 | ({ int * __result; \ |
| 52 | asm ( \ |
| 53 | " copy %%r19, %%r4\n" \ |
| 54 | " addil LT'" #x "-$tls_ldidx$, %%r19\n" \ |
| 55 | " bl __tls_get_addr, %%r2\n" \ |
| 56 | " ldo RT'" #x "-$tls_ldidx$(%%r1), %%r26\n" \ |
| 57 | " addil LR'" #x "-$tls_dtpoff$, %%r28\n" \ |
| 58 | " ldo RR'" #x "-$tls_dtpoff$(%%r1), %0\n" \ |
| 59 | " copy %%r4, %%r19\n" \ |
| 60 | : "=r" (__result) \ |
| 61 | : \ |
| 62 | : "r1", "r2", "r4", "r20", "r21", "r22", "r23", "r24", \ |
| 63 | "r25", "r26", "r28", "r29", "r31" ); \ |
| 64 | __result; \ |
| 65 | }) |
| 66 | #else |
| 67 | # define TLS_LD(x) \ |
| 68 | ({ int * __result; \ |
| 69 | asm ( \ |
| 70 | " addil LR'" #x "-$tls_ldidx$, %%r27\n" \ |
| 71 | " bl __tls_get_addr, %%r2\n" \ |
| 72 | " ldo RR'" #x "-$tls_ldidx$(%%r1), %%r26\n" \ |
| 73 | " addil LR'" #x "-$tls_dtpoff$, %%r28\n" \ |
| 74 | " ldo RR'" #x "-$tls_dtpoff$(%%r1), %0\n" \ |
| 75 | : "=r" (__result) \ |
| 76 | : \ |
| 77 | : "r1", "r2", "r20", "r21", "r22", "r23", "r24", \ |
| 78 | "r25", "r26", "r28", "r29", "r31" ); \ |
| 79 | __result; \ |
| 80 | }) |
| 81 | #endif |
| 82 | |
| 83 | /* HPPA General Dynamic TLS access. */ |
| 84 | #ifdef PIC |
| 85 | # define TLS_GD(x) \ |
| 86 | ({ int * __result; \ |
| 87 | asm ( \ |
| 88 | " copy %%r19, %%r4\n" \ |
| 89 | " addil LT'" #x "-$tls_gdidx$, %%r19\n" \ |
| 90 | " bl __tls_get_addr, %%r2\n" \ |
| 91 | " ldo RT'" #x "-$tls_gdidx$(%%r1), %%r26\n" \ |
| 92 | " copy %%r28, %0\n" \ |
| 93 | " copy %%r4, %%r19\n" \ |
| 94 | : "=r" (__result) \ |
| 95 | : \ |
| 96 | : "r1", "r2", "r4", "r20", "r21", "r22", "r23", "r24", \ |
| 97 | "r25", "r26", "r28", "r29", "r31" ); \ |
| 98 | __result; \ |
| 99 | }) |
| 100 | #else |
| 101 | # define TLS_GD(x) \ |
| 102 | ({ int * __result; \ |
| 103 | asm ( \ |
| 104 | " addil LR'" #x "-$tls_gdidx$, %%r27\n" \ |
| 105 | " bl __tls_get_addr, %%r2\n" \ |
| 106 | " ldo RR'" #x "-$tls_gdidx$(%%r1), %%r26\n" \ |
| 107 | " copy %%r28, %0\n" \ |
| 108 | : "=r" (__result) \ |
| 109 | : \ |
| 110 | : "r1", "r2", "r20", "r21", "r22", "r23", "r24", \ |
| 111 | "r25", "r26", "r28", "r29", "r31" ); \ |
| 112 | __result; \ |
| 113 | }) |
| 114 | #endif |