2006-02-20 Roland McGrath <roland@redhat.com>
[glibc-ports.git] / sysdeps / arm / tls-macros.h
blob94aa3a83b133ab0f825a28399ce056f90aafe193
1 #define TLS_LE(x) \
2 ({ int *__result; \
3 void *tp = __builtin_thread_pointer (); \
4 asm ("ldr %0, 1f; " \
5 "add %0, %1, %0; " \
6 "b 2f; " \
7 "1: .word " #x "(tpoff); " \
8 "2: " \
9 : "=&r" (__result) : "r" (tp)); \
10 __result; })
12 #define TLS_IE(x) \
13 ({ int *__result; \
14 void *tp = __builtin_thread_pointer (); \
15 asm ("ldr %0, 1f; " \
16 "3: ldr %0, [pc, %0];" \
17 "add %0, %1, %0; " \
18 "b 2f; " \
19 "1: .word " #x "(gottpoff) + (. - 3b - 8); " \
20 "2: " \
21 : "=&r" (__result) : "r" (tp)); \
22 __result; })
24 #define TLS_LD(x) \
25 ({ char *__result; \
26 int __offset; \
27 extern void *__tls_get_addr (void *); \
28 asm ("ldr %0, 2f; " \
29 "1: add %0, pc, %0; " \
30 "b 3f; " \
31 "2: .word " #x "(tlsldm) + (. - 1b - 8); " \
32 "3: " \
33 : "=r" (__result)); \
34 __result = (char *)__tls_get_addr (__result); \
35 asm ("ldr %0, 1f; " \
36 "b 2f; " \
37 "1: .word " #x "(tlsldo); " \
38 "2: " \
39 : "=r" (__offset)); \
40 (int *) (__result + __offset); })
42 #define TLS_GD(x) \
43 ({ int *__result; \
44 extern void *__tls_get_addr (void *); \
45 asm ("ldr %0, 2f; " \
46 "1: add %0, pc, %0; " \
47 "b 3f; " \
48 "2: .word " #x "(tlsgd) + (. - 1b - 8); " \
49 "3: " \
50 : "=r" (__result)); \
51 (int *)__tls_get_addr (__result); })