1 /* Macros to support TLS testing in times of missing compiler support. */
3 #define COMMON_INT_DEF(x) \
4 asm (".tls_common " #x ",4,4")
5 /* XXX Until we get compiler support we don't need declarations. */
6 #define COMMON_INT_DECL(x)
8 /* XXX This definition will probably be machine specific, too. */
9 #define VAR_INT_DEF(x) \
10 asm (".section .tdata\n\t" \
13 ".size " #x ",4\n\t" \
15 /* XXX Until we get compiler support we don't need declarations. */
16 #define VAR_INT_DECL(x)
19 /* XXX Each architecture must have its own asm for now. */
23 asm ("movl %%gs:0,%0\n\t" \
24 "subl $" #x "@tpoff,%0" \
31 asm ("movl %%gs:0,%0\n\t" \
32 "subl " #x "@gottpoff(%%ebx),%0" \
40 "1:\tmovl (%%esp), %%ebx\n\t" \
43 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
44 "movl %%gs:0,%0\n\t" \
45 "subl " #x "@gottpoff(%%ebx),%0" \
46 : "=r" (__l), "=&b" (__b)); \
52 ({ int *__l, __c, __d; \
53 asm ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
54 "call ___tls_get_addr@plt\n\t" \
55 "leal " #x "@dtpoff(%%eax), %%eax" \
56 : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
60 ({ int *__l, __b, __c, __d; \
63 "1:\tmovl (%%esp), %%ebx\n\t" \
66 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
67 "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
68 "call ___tls_get_addr@plt\n\t" \
69 "leal " #x "@dtpoff(%%eax), %%eax" \
70 : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
76 ({ int *__l, __c, __d; \
77 asm ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
78 "call ___tls_get_addr@plt\n\t" \
80 : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
84 ({ int *__l, __b, __c, __d; \
87 "1:\tmovl (%%esp), %%ebx\n\t" \
90 "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
91 "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
92 "call ___tls_get_addr@plt\n\t" \
94 : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
98 #elif defined __x86_64__
102 asm ("movq %%fs:0,%0\n\t" \
103 "leaq " #x "@tpoff(%0), %0" \
109 asm ("movq %%fs:0,%0\n\t" \
110 "addq " #x "@gottpoff(%%rip),%0" \
115 ({ int *__l, __c, __d; \
116 asm ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
117 "call __tls_get_addr@plt\n\t" \
118 "leaq " #x "@dtpoff(%%rax), %%rax" \
119 : "=a" (__l), "=&c" (__c), "=&d" (__d) \
120 : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
124 ({ int *__l, __c, __d; \
125 asm (".byte 0x66\n\t" \
126 "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
129 "call __tls_get_addr@plt" \
130 : "=a" (__l), "=&c" (__c), "=&d" (__d) \
131 : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
137 ({ int *__l; void *__tp; \
138 asm ("stc gbr,%1\n\t" \
143 "1: .long " #x "@tpoff\n\t" \
145 : "=r" (__l), "=r" (__tp)); \
149 ({ int *__l; void *__tp; \
150 asm ("mova 0f,r0\n\t" \
155 "mov.l @(r0,r12),%0\n\t" \
159 "1: .long " #x "@gottpoff\n\t" \
160 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
162 : "=r" (__l), "=r" (__tp) : : "r0", "r12"); \
167 asm ("mova 0f,r0\n\t" \
179 "1: .long " #x "@tlsldm\n\t" \
180 "2: .long __tls_get_addr@plt\n\t" \
181 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
182 "4: mov.l 3f,%0\n\t" \
186 "3: .long " #x "@dtpoff\n\t" \
188 : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
194 asm ("mova 0f,r0\n\t" \
206 "1: .long " #x "@tlsgd\n\t" \
207 "2: .long __tls_get_addr@plt\n\t" \
208 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
210 : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
214 #elif defined __alpha__
216 register void *__gp __asm__("$29");
220 asm ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l)); \
224 ({ char *__tp; unsigned long __o; \
225 asm ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel" \
226 : "=v"(__tp), "=r"(__o) : "r"(__gp)); \
227 (int *)(__tp + __o); })
230 ({ extern void *__tls_get_addr(void *); int *__l; void *__i; \
231 asm ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp)); \
232 __i = __tls_get_addr(__i); \
233 asm ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i)); \
237 ({ extern void *__tls_get_addr(void *); void *__i; \
238 asm ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp)); \
239 (int *) __tls_get_addr(__i); })
242 # error "No support for this architecture so far."