[runtime]Revert the fast tls check as we always need it on mach. Add another iOS...
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 9 Jul 2013 22:06:11 +0000 (18:06 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 9 Jul 2013 22:22:01 +0000 (18:22 -0400)
mono/utils/mach-support-arm.c

index 8333b64d1b18c0e3a87ed913e19c4b13db551a9e..b30fc3e54d02904533ce219894328f59307b8fa2 100644 (file)
 
 /* Known offsets used for TLS storage*/
 
-/*Found on iOS 6 */
-#define TLS_VECTOR_OFFSET_0 0x48
-#define TLS_VECTOR_OFFSET_1 0xA8
+
+static const int known_tls_offsets[] = {
+       0x48, /*Found on iOS 6 */
+       0xA4,
+       0xA8,
+};
+
+#define TLS_PROBE_COUNT (sizeof (known_tls_offsets) / sizeof (int))
 
 static int tls_vector_offset;
 
@@ -95,7 +100,6 @@ mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mac
 void *
 mono_mach_get_tls_address_from_thread (pthread_t thread, pthread_key_t key)
 {
-#ifdef MONO_HAVE_FAST_TLS
        /* Mach stores TLS values in a hidden array inside the pthread_t structure
         * They are keyed off a giant array from a known offset into the pointer. This value
         * is baked into their pthread_getspecific implementation
@@ -104,9 +108,6 @@ mono_mach_get_tls_address_from_thread (pthread_t thread, pthread_key_t key)
        intptr_t **tsd = (intptr_t **) ((char*)p + tls_vector_offset);
 
        return (void *) &tsd [key];
-#else
-       g_error ("fast tls not supported on this target");
-#endif
 }
 
 void *
@@ -118,7 +119,7 @@ mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key)
 void
 mono_mach_init (pthread_key_t key)
 {
-#ifdef MONO_HAVE_FAST_TLS
+       int i;
        void *old_value = pthread_getspecific (key);
        void *canary = (void*)0xDEADBEEFu;
 
@@ -128,18 +129,15 @@ mono_mach_init (pthread_key_t key)
        pthread_setspecific (key, canary);
 
        /*First we probe for cats*/
-       tls_vector_offset = TLS_VECTOR_OFFSET_0;
-       if (mono_mach_arch_get_tls_value_from_thread (pthread_self (), key) == canary)
-               goto ok;
-
-       tls_vector_offset = TLS_VECTOR_OFFSET_1;
-       if (mono_mach_arch_get_tls_value_from_thread (pthread_self (), key) == canary)
-               goto ok;
+       for (i = 0; i < TLS_PROBE_COUNT; ++i) {
+               tls_vector_offset = known_tls_offsets [i];
+               if (mono_mach_arch_get_tls_value_from_thread (pthread_self (), key) == canary)
+                       goto ok;
+       }
 
        g_error ("could not discover the mach TLS offset");
 ok:
        pthread_setspecific (key, old_value);
-#endif
 }
 
 #endif