X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmach-support-arm.c;h=649487ccc096f9d67f96614b9c8096a6dc2b06a9;hb=b9e7bcabe48cd0d9f282a2eebe6ab9a8a010d9b0;hp=eb1e009bfc20c8648ef993432ee01ef1f7f25cda;hpb=bf2e5e58df2a6525126ad3a880c2c21bb890e10d;p=mono.git diff --git a/mono/utils/mach-support-arm.c b/mono/utils/mach-support-arm.c index eb1e009bfc2..649487ccc09 100644 --- a/mono/utils/mach-support-arm.c +++ b/mono/utils/mach-support-arm.c @@ -1,5 +1,6 @@ -/* - * mach-support-arm.c: mach support for ARM +/** + * \file + * mach support for ARM * * Authors: * Geoff Norton (gnorton@novell.com) @@ -46,111 +47,92 @@ 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) +mono_mach_arch_thread_states_to_mcontext (thread_state_t state, thread_state_t fpstate, 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) +mono_mach_arch_mcontext_to_thread_states (void *context, thread_state_t state, thread_state_t fpstate) { -#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_states_to_mono_context (thread_state_t state, thread_state_t fpstate, 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) +int +mono_mach_arch_get_thread_fpstate_size () { -#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; + return sizeof (arm_neon_state_t); +} - ret = thread_get_state (thread, ARM_UNIFIED_THREAD_STATE, (thread_state_t) arch_state, count); -#else +kern_return_t +mono_mach_arch_get_thread_states (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count, thread_state_t fpstate, mach_msg_type_number_t *fpcount) +{ +#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) +mono_mach_arch_set_thread_states (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count, thread_state_t fpstate, mach_msg_type_number_t fpcount) { -#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 +145,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 +184,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); }