Add mono_mach_get_tls_address_from_thread for arm/x86/amd64.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 19 Jan 2012 21:33:44 +0000 (19:33 -0200)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 23 Jan 2012 18:12:43 +0000 (16:12 -0200)
mono/utils/mach-support-amd64.c
mono/utils/mach-support-arm.c
mono/utils/mach-support-x86.c
mono/utils/mach-support.h

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
index ebead18cab8e9bad44640b271d7c307c77d6cdc0..cca95abe2ac5884743b9ff1af027527d4e83fa46 100644 (file)
@@ -84,7 +84,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 0x48 into the pointer.  This value
@@ -93,6 +93,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 + 0x48 + (key << 2));
 
-       return (void *) *tsd;
+       return (void *)tsd;
 }
+
+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
index aac2fb2b4abcab6e849e79d4d9ed8734bbcd52b6..d3c967d2ed8019a957721ecf2b2595eaea00ee05 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 0x48 into the pointer.  This value
@@ -91,6 +91,14 @@ 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 + 0x48);
 
-       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
index ff7ea5bbc51a3f40ca1511ca824b06bd52d348e0..116721206a34200f062edc7c50f199e12451a3ef 100644 (file)
@@ -33,6 +33,7 @@ kern_return_t mono_mach_free_threads (thread_act_array_t threads, guint32 count)
 kern_return_t mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count) MONO_INTERNAL;
 kern_return_t mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count) MONO_INTERNAL;
 void *mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key) MONO_INTERNAL;
+void *mono_mach_get_tls_address_from_thread (pthread_t thread, pthread_key_t key) MONO_INTERNAL;
 
 #endif
 #endif /* __MONO_MACH_SUPPORT_H__ */