Update.
[glibc.git] / elf / tls-macros.h
blob26745e9e21f3edcb6e65bb07463b5860e2f79075
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" \
11 ".globl " #x "\n" \
12 #x ":\t.long 0\n\t" \
13 ".size " #x ",4\n\t" \
14 ".previous")
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. */
20 #ifdef __i386__
21 # define TLS_LE(x) \
22 ({ int *__l; \
23 asm ("movl %%gs:0,%0\n\t" \
24 "subl $" #x "@tpoff,%0" \
25 : "=r" (__l)); \
26 __l; })
28 # ifdef PIC
29 # define TLS_IE(x) \
30 ({ int *__l; \
31 asm ("movl %%gs:0,%0\n\t" \
32 "subl " #x "@gottpoff(%%ebx),%0" \
33 : "=r" (__l)); \
34 __l; })
35 # else
36 # define TLS_IE(x) \
37 ({ int *__l, __b; \
38 asm ("call 1f\n\t" \
39 ".subsection 1\n" \
40 "1:\tmovl (%%esp), %%ebx\n\t" \
41 "ret\n\t" \
42 ".previous\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)); \
47 __l; })
48 # endif
50 # ifdef PIC
51 # define TLS_LD(x) \
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)); \
57 __l; })
58 # else
59 # define TLS_LD(x) \
60 ({ int *__l, __b, __c, __d; \
61 asm ("call 1f\n\t" \
62 ".subsection 1\n" \
63 "1:\tmovl (%%esp), %%ebx\n\t" \
64 "ret\n\t" \
65 ".previous\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)); \
71 __l; })
72 # endif
74 # ifdef PIC
75 # define TLS_GD(x) \
76 ({ int *__l, __c, __d; \
77 asm ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
78 "call ___tls_get_addr@plt\n\t" \
79 "nop" \
80 : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
81 __l; })
82 # else
83 # define TLS_GD(x) \
84 ({ int *__l, __b, __c, __d; \
85 asm ("call 1f\n\t" \
86 ".subsection 1\n" \
87 "1:\tmovl (%%esp), %%ebx\n\t" \
88 "ret\n\t" \
89 ".previous\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" \
93 "nop" \
94 : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
95 __l; })
96 # endif
98 #else
99 # error "No support for this architecture so far."
100 #endif