Merge pull request #896 from echampet/webresource
[mono.git] / mono / utils / mach-support-x86.c
index cc09323c48ce94d300d9e4f8fe9d922036c3137b..3e8b166eaf2b51a7dc69f49d889c896762d75732 100644 (file)
@@ -72,6 +72,22 @@ mono_mach_arch_mcontext_to_thread_state (void *context, thread_state_t state)
        *arch_state = ctx->__ss;
 }
 
+void
+mono_mach_arch_thread_state_to_mono_context (thread_state_t state, MonoContext *context)
+{
+       x86_thread_state32_t *arch_state = (x86_thread_state32_t *) state;
+       context->eax = arch_state->__eax;
+       context->ebx = arch_state->__ebx;
+       context->ecx = arch_state->__ecx;
+       context->edx = arch_state->__edx;
+       context->ebp = arch_state->__ebp;
+       context->esp = arch_state->__esp;
+       context->esi = arch_state->__edi;
+       context->edi = arch_state->__esi;
+       context->eip = arch_state->__eip;
+}
+
+
 int
 mono_mach_arch_get_thread_state_size ()
 {
@@ -81,20 +97,27 @@ mono_mach_arch_get_thread_state_size ()
 kern_return_t
 mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count)
 {
+#if defined(HOST_WATCHOS)
+       g_error ("thread_get_state() is not supported by this platform");
+#else
        x86_thread_state32_t *arch_state = (x86_thread_state32_t *) state;
        kern_return_t ret;
 
        *count = x86_THREAD_STATE32_COUNT;
-
        ret = thread_get_state (thread, x86_THREAD_STATE32, (thread_state_t) arch_state, count);
 
        return ret;
+#endif
 }
 
 kern_return_t
 mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count)
 {
+#if defined(HOST_WATCHOS)
+       g_error ("thread_set_state() is not supported by this platform");
+#else
        return thread_set_state (thread, x86_THREAD_STATE32, state, count);
+#endif 
 }
 
 void *
@@ -137,10 +160,6 @@ mono_mach_init (pthread_key_t key)
        tls_vector_offset = TLS_VECTOR_OFFSET_10_9;
        if (mono_mach_arch_get_tls_value_from_thread (pthread_self (), key) == canary)
                goto ok;
-    
-    tls_vector_offset = TLS_VECTOR_OFFSET_10_11;
-    if (mono_mach_arch_get_tls_value_from_thread (pthread_self (), key) == canary)
-        goto ok;
 
        tls_vector_offset = TLS_VECTOR_OFFSET_10_11;
        if (mono_mach_arch_get_tls_value_from_thread (pthread_self (), key) == canary)