Skip to content

Commit

Permalink
[runtime]Revert the fast tls check as we always need it on mach. Add …
Browse files Browse the repository at this point in the history
…another iOS 7 offset.
  • Loading branch information
kumpera committed Jul 9, 2013
1 parent 5804e12 commit bed040e
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions mono/utils/mach-support-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@

/* 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;

Expand Down Expand Up @@ -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
Expand All @@ -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 *
Expand All @@ -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;

Expand All @@ -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

0 comments on commit bed040e

Please sign in to comment.