Add mono_mach_get_tls_address_from_thread for arm/x86/amd64.
[mono.git] / mono / utils / mach-support-amd64.c
index a2abd0bbf8fd70478133f75d79f876f4f4d0e114..ab59ed5cfdf8a9f29720ac880440021eede6934d 100644 (file)
@@ -82,7 +82,7 @@ mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mac
 }
 
 void *
-mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key)
+mono_mach_get_tls_address_from_thread (pthread_t thread, pthread_key_t key)
 {
        /* OSX stores TLS values in a hidden array inside the pthread_t structure
         * They are keyed off a giant array offset 0x60 into the pointer.  This value
@@ -91,6 +91,13 @@ mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key)
        intptr_t *p = (intptr_t *)thread;
        intptr_t **tsd = (intptr_t **) ((char*)p + 0x60);
 
-       return (void *) tsd [key];
+       return (void *) &tsd [key];
 }
+
+void *
+mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key)
+{
+       return *(void**)mono_mach_get_tls_address_from_thread (thread, key);
+}
+
 #endif