diff --git a/lisp-kernel/thread_manager.c b/lisp-kernel/thread_manager.c index 7703ae49..93ce3832 100644 --- a/lisp-kernel/thread_manager.c +++ b/lisp-kernel/thread_manager.c @@ -1368,9 +1368,11 @@ shutdown_thread_tcr(void *arg) if (tcr->flags & (1<address; - + int (*foreign_thread_control)(int) = (int (*)(int))callback_ptr; + tsd_set(lisp_global(TCR_KEY), TCR_TO_TSD(tcr)); - ((void (*)())ptr_from_lispobj(callback_ptr))(1); + foreign_thread_control(1); + //((void (*)(int))ptr_from_lispobj(callback_ptr))(1); tsd_set(lisp_global(TCR_KEY), NULL); } #ifdef DARWIN @@ -1847,6 +1849,7 @@ get_tcr(Boolean create) if ((current == NULL) && create) { LispObj callback_macptr = nrs_FOREIGN_THREAD_CONTROL.vcell, callback_ptr = ((macptr *)ptr_from_lispobj(untag(callback_macptr)))->address; + int (*foreign_thread_control)(int) = (int (*)(int))callback_ptr; int i, nbindwords = 0; extern natural initial_stack_size; @@ -1877,13 +1880,13 @@ get_tcr(Boolean create) *(--current->save_vsp) = 0; current->vs_area->active -= node_size; } - nbindwords = ((int (*)())ptr_from_lispobj(callback_ptr))(-1); + nbindwords = foreign_thread_control(-1); for (i = 0; i < nbindwords; i++) { *(--current->save_vsp) = 0; current->vs_area->active -= node_size; } TCR_AUX(current)->shutdown_count = 1; - ((void (*)())ptr_from_lispobj(callback_ptr))(0); + foreign_thread_control(0); } @@ -2047,7 +2050,7 @@ create_thread_context_frame(mach_port_t, natural *, siginfo_t *, TCR*, native_th Boolean mach_suspend_tcr(TCR *tcr) { - thread_act_t thread = (thread_act_t)(tcr->native_thread_id); + mach_port_t thread = (mach_port_t)((intptr_t)tcr->native_thread_id); kern_return_t kret = thread_suspend(thread); if (kret == 0) { @@ -2209,7 +2212,7 @@ resume_tcr(TCR *tcr) Boolean mach_resume_tcr(TCR *tcr) { ExceptionInformation *xp = tcr->suspend_context; - mach_port_t thread = (mach_port_t)(tcr->native_thread_id); + mach_port_t thread = (mach_port_t)((intptr_t)(tcr->native_thread_id)); #if WORD_SIZE == 64 MCONTEXT_T mc = UC_MCONTEXT(xp); #else diff --git a/lisp-kernel/x86-exceptions.c b/lisp-kernel/x86-exceptions.c index 75dea85e..6eeee55a 100644 --- a/lisp-kernel/x86-exceptions.c +++ b/lisp-kernel/x86-exceptions.c @@ -678,7 +678,6 @@ handle_alloc_trap(ExceptionInformation *xp, TCR *tcr, Boolean *notify) return true; } - int callback_to_lisp (TCR * tcr, LispObj callback_macptr, ExceptionInformation *xp, natural arg1, natural arg2, natural arg3, natural arg4, natural arg5) @@ -712,8 +711,12 @@ callback_to_lisp (TCR * tcr, LispObj callback_macptr, ExceptionInformation *xp, pointers (and at least should have called prepare_for_callback()). */ callback_ptr = ((macptr *)ptr_from_lispobj(untag(callback_macptr)))->address; + typedef int (*callback_fn_type)(ExceptionInformation *, natural, natural, + natural, natural, natural); + callback_fn_type callback_fn = (callback_fn_type)callback_ptr; + UNLOCK(lisp_global(EXCEPTION_LOCK), tcr); - delta = ((int (*)())callback_ptr) (xp, arg1, arg2, arg3, arg4, arg5); + delta = callback_fn(xp, arg1, arg2, arg3, arg4, arg5); LOCK(lisp_global(EXCEPTION_LOCK), tcr); #ifdef X8632