Fixes process names trimmed to 15 chars.
[mono.git] / mono / mini / mini-arm-tls.S
1 /*
2  * mini-arm-tls.S: tls getters and setters for arm platforms
3  *
4  * Copyright 2015 Xamarin, Inc.
5  */
6
7 #include <config.h>
8
9 #ifndef MONO_CROSS_COMPILE
10
11         /*
12          * The following thunks fetch the value corresponding to the key/offset
13          * passed in R0. These thunks don't do jumps to external code so execution
14          * within can be tracked. The tls value is returned in R0.
15          */
16
17         .text
18 /* no .arch on clang. it only supports armv6+ anyway */
19 #ifndef TARGET_MACH
20         .arch armv5
21 #endif
22         .arm
23         .align 4
24 #ifdef TARGET_MACH
25         .global _mono_fast_get_tls_key
26 _mono_fast_get_tls_key :
27 #else
28         .global mono_fast_get_tls_key
29 mono_fast_get_tls_key :
30 #endif
31 #if defined(__linux__)
32         mrc     p15, 0, r1, c13, c0, 3
33 #if defined(HAVE_KW_THREAD)
34         ldr     r0, [r1, r0]
35 #elif defined(TARGET_ANDROID)
36         ldr     r0, [r1, r0, lsl #2]
37 #endif
38         bx      lr
39 #elif defined(TARGET_IOS)
40         mrc     p15, 0, r1, c13, c0, 3
41         bic     r1, r1, #3
42         ldr     r0, [r1, r0, lsl #2]
43         bx      lr
44 #endif
45
46         /*
47          * The following thunks fetch the value corresponding to the key/offset
48          * passed in R0. These thunks are used in the unlikely cases where we determine
49          * at runtime that the current implementation is not accounted for.
50          */
51
52         .align 4
53 #ifdef TARGET_MACH
54         .global _mono_fallback_get_tls_key
55 _mono_fallback_get_tls_key :
56 #else
57         .global mono_fallback_get_tls_key
58 mono_fallback_get_tls_key :
59 #endif
60 #if defined(__linux__)
61         mov     r1, r0
62         mvn     r0, #0xf000
63         sub     r0, r0, #31
64         push    {lr}
65         blx     r0
66 #if defined(HAVE_KW_THREAD)
67         ldr     r0, [r0, r1]
68 #elif defined(TARGET_ANDROID)
69         ldr     r0, [r0, r1, lsl #2]
70 #endif
71         pop     {pc}
72 #elif defined(TARGET_IOS)
73         push    {lr}
74         bl      _pthread_getspecific
75         pop     {pc}
76 #endif
77
78         /*
79          * The following thunks set the value corresponding to the key/offset
80          * passed in R0. These thunks don't do jumps to external code so execution
81          * within can be tracked. The tls value is passed in R1.
82          */
83
84         .align 4
85 #ifdef TARGET_MACH
86         .global _mono_fast_set_tls_key
87 _mono_fast_set_tls_key :
88 #else
89         .global mono_fast_set_tls_key
90 mono_fast_set_tls_key :
91 #endif
92 #if defined(__linux__)
93         mrc     p15, 0, r2, c13, c0, 3
94 #if defined(HAVE_KW_THREAD)
95         str     r1, [r2, r0]
96 #elif defined(TARGET_ANDROID)
97         str     r1, [r2, r0, lsl #2]
98 #endif
99         bx      lr
100 #elif defined(TARGET_IOS)
101         mrc     p15, 0, r2, c13, c0, 3
102         bic     r2, r2, #3
103         str     r1, [r2, r0, lsl #2]
104         bx      lr
105 #endif
106
107         /*
108          * The following thunks set the value corresponding to the key/offset
109          * passed in R0. These thunks are used in the unlikely cases where we determine
110          * at runtime that the current implementation is not accounted for.
111          */
112
113         .align 4
114 #ifdef TARGET_MACH
115         .global _mono_fallback_set_tls_key
116 _mono_fallback_set_tls_key :
117 #else
118         .global mono_fallback_set_tls_key
119 mono_fallback_set_tls_key :
120 #endif
121 #if defined(__linux__)
122         mov     r2, r0
123         mvn     r0, #0xf000
124         sub     r0, r0, #31
125         push    {lr}
126         blx     r0
127 #if defined(HAVE_KW_THREAD)
128         str     r1, [r0, r2]
129 #elif defined(TARGET_ANDROID)
130         str     r1, [r0, r2, lsl #2]
131 #endif
132         pop     {pc}
133 #elif defined(TARGET_IOS)
134         push    {lr}
135         bl      _pthread_setspecific
136         pop     {pc}
137 #endif
138
139 #endif
140