2 * mini-arm-tls.S: tls getters and setters for arm platforms
4 * Copyright 2015 Xamarin, Inc.
9 #ifndef MONO_CROSS_COMPILE
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.
17 .macro DECLARE_GLOBAL_SYMBOL name
28 /* no .arch on clang. it only supports armv6+ anyway */
35 DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key
36 #if defined(__linux__)
37 mrc p15, 0, r1, c13, c0, 3
38 #if defined(HAVE_KW_THREAD)
40 #elif defined(TARGET_ANDROID)
41 ldr r0, [r1, r0, lsl #2]
44 #elif defined(TARGET_IOS)
45 mrc p15, 0, r1, c13, c0, 3
47 ldr r0, [r1, r0, lsl #2]
50 DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key_end
53 * The following thunks fetch the value corresponding to the key/offset
54 * passed in R0. These thunks are used in the unlikely cases where we determine
55 * at runtime that the current implementation is not accounted for.
59 DECLARE_GLOBAL_SYMBOL mono_fallback_get_tls_key
60 #if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
66 #elif defined(TARGET_IOS)
69 bl _pthread_getspecific
71 #elif defined(TARGET_ANDROID)
73 bl pthread_getspecific
77 * The following thunks set the value corresponding to the key/offset
78 * passed in R0. These thunks don't do jumps to external code so execution
79 * within can be tracked. The tls value is passed in R1.
83 DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key
84 #if defined(__linux__)
85 mrc p15, 0, r2, c13, c0, 3
86 #if defined(HAVE_KW_THREAD)
88 #elif defined(TARGET_ANDROID)
89 str r1, [r2, r0, lsl #2]
92 #elif defined(TARGET_IOS)
93 mrc p15, 0, r2, c13, c0, 3
95 str r1, [r2, r0, lsl #2]
98 DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key_end
101 * The following thunks set the value corresponding to the key/offset
102 * passed in R0. These thunks are used in the unlikely cases where we determine
103 * at runtime that the current implementation is not accounted for.
107 DECLARE_GLOBAL_SYMBOL mono_fallback_set_tls_key
108 #if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
114 #elif defined(TARGET_IOS)
117 bl _pthread_setspecific
119 #elif defined(TARGET_ANDROID)
121 bl pthread_setspecific
126 /* Additional tls getters/setters */
128 #if defined(TARGET_ANDROID)
130 DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key2
131 bic r0, r0, #0x80000000
132 mrc 15, 0, r1, cr13, cr0, #3
138 DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key2_end
141 * In order to use this fast setter we need to make sure that the key was
142 * already set at least once using the pthread api, otherwise it will not
143 * interwork with the api.
146 DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key2
147 bic r0, r0, #0x80000000
148 mrc 15, 0, r2, cr13, cr0, #3
154 DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key2_end