X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmach-support-arm.c;h=d535fbc18ddce3689a7701acc1da0cd4eeca0492;hb=bc9d5d113ab7064fc199a2f430751643466cb477;hp=eb1e009bfc20c8648ef993432ee01ef1f7f25cda;hpb=6bc565c1f7e7fd9aaf6ee6a141ea18479a316ac4;p=mono.git diff --git a/mono/utils/mach-support-arm.c b/mono/utils/mach-support-arm.c index eb1e009bfc2..d535fbc18dd 100644 --- a/mono/utils/mach-support-arm.c +++ b/mono/utils/mach-support-arm.c @@ -46,111 +46,86 @@ void * mono_mach_arch_get_ip (thread_state_t state) { /* Can't use unified_thread_state on !ARM64 since this has to compile on armv6 too */ -#ifdef TARGET_ARM64 - arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state; - - return (void *) arch_state->ts_64.__pc; -#else arm_thread_state_t *arch_state = (arm_thread_state_t *) state; return (void *) arch_state->__pc; -#endif } void * mono_mach_arch_get_sp (thread_state_t state) { -#ifdef TARGET_ARM64 - arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state; - - return (void *) arch_state->ts_64.__sp; -#else arm_thread_state_t *arch_state = (arm_thread_state_t *) state; return (void *) arch_state->__sp; -#endif } int mono_mach_arch_get_mcontext_size () { -#ifdef TARGET_ARM64 - return sizeof (struct __darwin_mcontext64); -#else return sizeof (struct __darwin_mcontext); -#endif } void mono_mach_arch_thread_state_to_mcontext (thread_state_t state, void *context) { -#ifdef TARGET_ARM64 - arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state; - struct __darwin_mcontext64 *ctx = (struct __darwin_mcontext64 *) context; - - ctx->__ss = arch_state->ts_64; -#else arm_thread_state_t *arch_state = (arm_thread_state_t *) state; struct __darwin_mcontext *ctx = (struct __darwin_mcontext *) context; ctx->__ss = *arch_state; -#endif } void mono_mach_arch_mcontext_to_thread_state (void *context, thread_state_t state) { -#ifdef TARGET_ARM64 - arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state; - struct __darwin_mcontext64 *ctx = (struct __darwin_mcontext64 *) context; - - arch_state->ts_64 = ctx->__ss; -#else arm_thread_state_t *arch_state = (arm_thread_state_t *) state; struct __darwin_mcontext *ctx = (struct __darwin_mcontext *) context; *arch_state = ctx->__ss; -#endif +} + +void +mono_mach_arch_thread_state_to_mono_context (thread_state_t state, MonoContext *context) +{ + int i; + arm_thread_state_t *arch_state = (arm_thread_state_t *) state; + for (i = 0; i < 13; ++i) + context->regs [i] = arch_state->__r [i]; + context->regs [ARMREG_R13] = arch_state->__sp; + context->regs [ARMREG_R14] = arch_state->__lr; + context->regs [ARMREG_R15] = arch_state->__pc; + context->pc = arch_state->__pc; + context->cpsr = arch_state->__cpsr; } int mono_mach_arch_get_thread_state_size () { -#ifdef TARGET_ARM64 - return sizeof (arm_unified_thread_state_t); -#else return sizeof (arm_thread_state_t); -#endif } kern_return_t mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count) { -#ifdef TARGET_ARM64 - arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state; - kern_return_t ret; - - *count = ARM_UNIFIED_THREAD_STATE_COUNT; - - ret = thread_get_state (thread, ARM_UNIFIED_THREAD_STATE, (thread_state_t) arch_state, count); -#else +#if defined(HOST_WATCHOS) + g_error ("thread_get_state() is not supported by this platform"); +#else arm_thread_state_t *arch_state = (arm_thread_state_t *) state; kern_return_t ret; *count = ARM_THREAD_STATE_COUNT; ret = thread_get_state (thread, ARM_THREAD_STATE, (thread_state_t) arch_state, count); -#endif 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) { -#ifdef TARGET_ARM64 - return thread_set_state (thread, ARM_UNIFIED_THREAD_STATE_COUNT, state, count); +#if defined(HOST_WATCHOS) + g_error ("thread_set_state() is not supported by this platform"); #else - return thread_set_state (thread, ARM_THREAD_STATE_COUNT, state, count); + return thread_set_state (thread, ARM_THREAD_STATE, state, count); #endif } @@ -163,6 +138,7 @@ mono_mach_get_tls_address_from_thread (pthread_t thread, pthread_key_t key) */ intptr_t *p = (intptr_t *) thread; intptr_t **tsd = (intptr_t **) ((char*)p + tls_vector_offset); + g_assert (tls_vector_offset != -1); return (void *) &tsd [key]; } @@ -201,7 +177,8 @@ mono_mach_init (pthread_key_t key) } } - g_error ("could not discover the mach TLS offset"); + tls_vector_offset = -1; + g_warning ("could not discover the mach TLS offset"); ok: pthread_setspecific (key, old_value); }