Free errstring if _dl_addr doesn't returns 0
[glibc.git] / sysdeps / sh / tls-macros.h
blobaa56b0a01f2928ae9f699d162fe43b5fbdb4c5ea
1 #define TLS_LE(x) \
2 ({ int *__l; void *__tp; \
3 asm ("stc gbr,%1\n\t" \
4 "mov.l 1f,%0\n\t" \
5 "bra 2f\n\t" \
6 " add %1,%0\n\t" \
7 ".align 2\n\t" \
8 "1: .long " #x "@tpoff\n\t" \
9 "2:" \
10 : "=r" (__l), "=r" (__tp)); \
11 __l; })
13 #ifdef PIC
14 # define TLS_IE(x) \
15 ({ int *__l; void *__tp; \
16 register void *__gp __asm__("r12"); \
17 asm ("mov.l 1f,r0\n\t" \
18 "stc gbr,%1\n\t" \
19 "mov.l @(r0,r12),%0\n\t" \
20 "bra 2f\n\t" \
21 " add %1,%0\n\t" \
22 ".align 2\n\t" \
23 "1: .long " #x "@gottpoff\n\t" \
24 "2:" \
25 : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
26 __l; })
27 #else
28 # define TLS_IE(x) \
29 ({ int *__l; void *__tp; \
30 asm ("mov.l r12,@-r15\n\t" \
31 "mova 0f,r0\n\t" \
32 "mov.l 0f,r12\n\t" \
33 "add r0,r12\n\t" \
34 "mov.l 1f,r0\n\t" \
35 "stc gbr,%1\n\t" \
36 "mov.l @(r0,r12),%0\n\t" \
37 "bra 2f\n\t" \
38 " add %1,%0\n\t" \
39 ".align 2\n\t" \
40 "1: .long " #x "@gottpoff\n\t" \
41 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
42 "2: mov.l @r15+,r12" \
43 : "=r" (__l), "=r" (__tp) : : "r0"); \
44 __l; })
45 #endif
47 #ifdef PIC
48 # define TLS_LD(x) \
49 ({ int *__l; \
50 register void *__gp __asm__("r12"); \
51 asm ("mov.l 1f,r4\n\t" \
52 "mova 2f,r0\n\t" \
53 "mov.l 2f,r1\n\t" \
54 "add r0,r1\n\t" \
55 "jsr @r1\n\t" \
56 " add r12,r4\n\t" \
57 "bra 4f\n\t" \
58 " nop\n\t" \
59 ".align 2\n\t" \
60 "1: .long " #x "@tlsldm\n\t" \
61 "2: .long __tls_get_addr@plt\n\t" \
62 "4: mov.l 3f,%0\n\t" \
63 "bra 5f\n\t" \
64 " add r0,%0\n\t" \
65 ".align 2\n\t" \
66 "3: .long " #x "@dtpoff\n\t" \
67 "5:" \
68 : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
69 "r6", "r7", "pr", "t"); \
70 __l; })
71 #else
72 # define TLS_LD(x) \
73 ({ int *__l; \
74 asm ("mov.l r12,@-r15\n\t" \
75 "mova 0f,r0\n\t" \
76 "mov.l 0f,r12\n\t" \
77 "add r0,r12\n\t" \
78 "mov.l 1f,r4\n\t" \
79 "mova 2f,r0\n\t" \
80 "mov.l 2f,r1\n\t" \
81 "add r0,r1\n\t" \
82 "jsr @r1\n\t" \
83 " add r12,r4\n\t" \
84 "bra 4f\n\t" \
85 " nop\n\t" \
86 ".align 2\n\t" \
87 "1: .long " #x "@tlsldm\n\t" \
88 "2: .long __tls_get_addr@plt\n\t" \
89 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
90 "4: mov.l 3f,%0\n\t" \
91 "bra 5f\n\t" \
92 " add r0,%0\n\t" \
93 ".align 2\n\t" \
94 "3: .long " #x "@dtpoff\n\t" \
95 "5: mov.l @r15+,r12" \
96 : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
97 "pr", "t"); \
98 __l; })
99 #endif
101 #ifdef PIC
102 # define TLS_GD(x) \
103 ({ int *__l; \
104 register void *__gp __asm__("r12"); \
105 asm ("mov.l 1f,r4\n\t" \
106 "mova 2f,r0\n\t" \
107 "mov.l 2f,r1\n\t" \
108 "add r0,r1\n\t" \
109 "jsr @r1\n\t" \
110 " add r12,r4\n\t" \
111 "bra 3f\n\t" \
112 " mov r0,%0\n\t" \
113 ".align 2\n\t" \
114 "1: .long " #x "@tlsgd\n\t" \
115 "2: .long __tls_get_addr@plt\n\t" \
116 "3:" \
117 : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
118 "r6", "r7", "pr", "t"); \
119 __l; })
120 #else
121 # define TLS_GD(x) \
122 ({ int *__l; \
123 asm ("mov.l r12,@-r15\n\t" \
124 "mova 0f,r0\n\t" \
125 "mov.l 0f,r12\n\t" \
126 "add r0,r12\n\t" \
127 "mov.l 1f,r4\n\t" \
128 "mova 2f,r0\n\t" \
129 "mov.l 2f,r1\n\t" \
130 "add r0,r1\n\t" \
131 "jsr @r1\n\t" \
132 " add r12,r4\n\t" \
133 "bra 3f\n\t" \
134 " mov r0,%0\n\t" \
135 ".align 2\n\t" \
136 "1: .long " #x "@tlsgd\n\t" \
137 "2: .long __tls_get_addr@plt\n\t" \
138 "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
139 "3: mov.l @r15+,r12" \
140 : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
141 "pr", "t"); \
142 __l; })
143 #endif