Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / powerpc / powerpc32 / tls-macros.h
blob0df0814247d3f758d3c15dfbb5f4c773145eb7e9
1 /* Include sysdeps/powerpc/tls-macros.h for __TLS_CALL_CLOBBERS */
2 #include_next "tls-macros.h"
3 #include "config.h"
5 /* PowerPC32 Local Exec TLS access. */
6 #define TLS_LE(x) \
7 ({ int *__result; \
8 asm ("addi %0,2," #x "@tprel" \
9 : "=r" (__result)); \
10 __result; })
12 /* PowerPC32 Initial Exec TLS access. */
13 #ifdef HAVE_ASM_PPC_REL16
14 # define TLS_IE(x) \
15 ({ int *__result; \
16 asm ("bcl 20,31,1f\n1:\t" \
17 "mflr %0\n\t" \
18 "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
19 "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
20 "lwz %0," #x "@got@tprel(%0)\n\t" \
21 "add %0,%0," #x "@tls" \
22 : "=b" (__result) : \
23 : "lr"); \
24 __result; })
25 #else
26 # define TLS_IE(x) \
27 ({ int *__result; \
28 asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
29 "mflr %0\n\t" \
30 "lwz %0," #x "@got@tprel(%0)\n\t" \
31 "add %0,%0," #x "@tls" \
32 : "=b" (__result) : \
33 : "lr"); \
34 __result; })
35 #endif
37 /* PowerPC32 Local Dynamic TLS access. */
38 #ifdef HAVE_ASM_PPC_REL16
39 # define TLS_LD(x) \
40 ({ int *__result; \
41 asm ("bcl 20,31,1f\n1:\t" \
42 "mflr 3\n\t" \
43 "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
44 "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
45 "addi 3,3," #x "@got@tlsld\n\t" \
46 "bl __tls_get_addr@plt\n\t" \
47 "addi %0,3," #x "@dtprel" \
48 : "=r" (__result) : \
49 : "3", __TLS_CALL_CLOBBERS); \
50 __result; })
51 #else
52 # define TLS_LD(x) \
53 ({ int *__result; \
54 asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
55 "mflr 3\n\t" \
56 "addi 3,3," #x "@got@tlsld\n\t" \
57 "bl __tls_get_addr@plt\n\t" \
58 "addi %0,3," #x "@dtprel" \
59 : "=r" (__result) : \
60 : "3", __TLS_CALL_CLOBBERS); \
61 __result; })
62 #endif
64 /* PowerPC32 General Dynamic TLS access. */
65 #ifdef HAVE_ASM_PPC_REL16
66 # define TLS_GD(x) \
67 ({ register int *__result __asm__ ("r3"); \
68 asm ("bcl 20,31,1f\n1:\t" \
69 "mflr 3\n\t" \
70 "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
71 "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
72 "addi 3,3," #x "@got@tlsgd\n\t" \
73 "bl __tls_get_addr@plt" \
74 : "=r" (__result) : \
75 : __TLS_CALL_CLOBBERS); \
76 __result; })
77 #else
78 # define TLS_GD(x) \
79 ({ register int *__result __asm__ ("r3"); \
80 asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
81 "mflr 3\n\t" \
82 "addi 3,3," #x "@got@tlsgd\n\t" \
83 "bl __tls_get_addr@plt" \
84 : "=r" (__result) : \
85 : __TLS_CALL_CLOBBERS); \
86 __result; })
87 #endif