2 * mini-arm-tls.S: tls getters and setters for arm platforms
4 * Copyright 2015 Xamarin, Inc.
5 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 #ifndef MONO_CROSS_COMPILE
13 * The following thunks fetch the value corresponding to the key/offset
14 * passed in R0. These thunks don't do jumps to external code so execution
15 * within can be tracked. The tls value is returned in R0.
18 .macro DECLARE_GLOBAL_SYMBOL name
29 /* no .arch on clang. it only supports armv6+ anyway */
36 DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key
37 #if defined(__linux__)
38 mrc p15, 0, r1, c13, c0, 3
39 #if defined(HAVE_KW_THREAD)
41 #elif defined(TARGET_ANDROID)
42 ldr r0, [r1, r0, lsl #2]
45 #elif defined(TARGET_IOS)
46 mrc p15, 0, r1, c13, c0, 3
48 ldr r0, [r1, r0, lsl #2]
51 DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key_end
54 * The following thunks fetch the value corresponding to the key/offset
55 * passed in R0. These thunks are used in the unlikely cases where we determine
56 * at runtime that the current implementation is not accounted for.
60 DECLARE_GLOBAL_SYMBOL mono_fallback_get_tls_key
61 #if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
67 #elif defined(TARGET_IOS)
70 bl _pthread_getspecific
72 #elif defined(TARGET_ANDROID)
74 bl pthread_getspecific
78 * The following thunks set the value corresponding to the key/offset
79 * passed in R0. These thunks don't do jumps to external code so execution
80 * within can be tracked. The tls value is passed in R1.
84 DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key
85 #if defined(__linux__)
86 mrc p15, 0, r2, c13, c0, 3
87 #if defined(HAVE_KW_THREAD)
89 #elif defined(TARGET_ANDROID)
90 str r1, [r2, r0, lsl #2]
93 #elif defined(TARGET_IOS)
94 mrc p15, 0, r2, c13, c0, 3
96 str r1, [r2, r0, lsl #2]
99 DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key_end
102 * The following thunks set the value corresponding to the key/offset
103 * passed in R0. These thunks are used in the unlikely cases where we determine
104 * at runtime that the current implementation is not accounted for.
108 DECLARE_GLOBAL_SYMBOL mono_fallback_set_tls_key
109 #if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
115 #elif defined(TARGET_IOS)
118 bl _pthread_setspecific
120 #elif defined(TARGET_ANDROID)
122 bl pthread_setspecific
127 /* Additional tls getters/setters */
129 #if defined(TARGET_ANDROID)
131 DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key2
132 bic r0, r0, #0x80000000
133 mrc p15, 0, r1, cr13, cr0, #3
139 DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key2_end
142 * In order to use this fast setter we need to make sure that the key was
143 * already set at least once using the pthread api, otherwise it will not
144 * interwork with the api.
147 DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key2
148 bic r0, r0, #0x80000000
149 mrc p15, 0, r2, cr13, cr0, #3
155 DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key2_end