;; Same as above for the location of the current control stack
;; pointer. This is also used on threaded x86oids to allow LDB to
;; print an approximation of the CSP as needed.
- #!+(and sb-thread)
+ #!+sb-thread
(control-stack-pointer :c-type "lispobj *")
+ #!+mach-exception-handler
+ (mach-port-name :c-type "mach_port_name_t")
;; KLUDGE: On alpha, until STEPPING we have been lucky and the 32
;; bit slots came in pairs. However the C compiler will align
;; interrupt_contexts on a double word boundary. This logic should
return ret;
}
+kern_return_t
+mach_lisp_thread_init(struct thread *thread) {
+ mach_port_t port = (mach_port_t) thread;
+ kern_return_t ret;
+ ret = mach_thread_init(port);
+ thread->mach_port_name = port;
+
+ return ret;
+}
+
+kern_return_t
+mach_lisp_thread_destroy(struct thread *thread) {
+ mach_port_t port = (mach_port_t) thread;
+
+ FSHOW((stderr, "Deallocating mach port %x\n", port));
+ mach_port_move_member(current_mach_task, port, MACH_PORT_NULL);
+ mach_port_deallocate(current_mach_task, port);
+
+ return mach_port_destroy(current_mach_task, port);
+}
+
void
setup_mach_exceptions() {
+ mach_port_t port = (mach_port_t) all_threads;
setup_mach_exception_handling_thread();
- mach_thread_init(THREAD_STRUCT_TO_EXCEPTION_PORT(all_threads));
+ mach_thread_init(port);
}
pid_t
(sizeof (struct interrupt_data)));
#ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
- FSHOW((stderr, "Deallocating mach port %x\n", THREAD_STRUCT_TO_EXCEPTION_PORT(th)));
- mach_port_move_member(current_mach_task,
- THREAD_STRUCT_TO_EXCEPTION_PORT(th),
- MACH_PORT_NULL);
- mach_port_deallocate(current_mach_task,
- THREAD_STRUCT_TO_EXCEPTION_PORT(th));
- mach_port_destroy(current_mach_task,
- THREAD_STRUCT_TO_EXCEPTION_PORT(th));
+ mach_lisp_thread_destroy(th);
#endif
schedule_thread_post_mortem(th);
return th;
}
-#ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
-mach_port_t setup_mach_exception_handling_thread();
-kern_return_t mach_thread_init(mach_port_t thread_exception_port);
-
-#endif
-
void create_initial_thread(lispobj initial_function) {
struct thread *th=create_thread_struct(initial_function);
#ifdef LISP_FEATURE_SB_THREAD
}
#if defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER)
-#define THREAD_STRUCT_TO_EXCEPTION_PORT(th) ((mach_port_t) th)
-#define EXCEPTION_PORT_TO_THREAD_STRUCT(th) ((struct thread *) th)
+extern kern_return_t mach_lisp_thread_init(struct thread *thread);
+extern kern_return_t mach_lisp_thread_destroy(struct thread *thread);
#endif
extern void create_initial_thread(lispobj);
#include <machine/fpu.h>
#endif
-#ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
-#include <mach/mach.h>
-
-kern_return_t mach_thread_init(mach_port_t thread_exception_port);
-#endif
-
/* KLUDGE: There is strong family resemblance in the signal context
* stuff in FreeBSD and OpenBSD, but in detail they're different in
* almost every line of code. It would be nice to find some way to
#endif
#ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
- mach_thread_init(THREAD_STRUCT_TO_EXCEPTION_PORT(thread));
+ mach_lisp_thread_init(thread);
#endif
#ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
#ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
-kern_return_t mach_thread_init(mach_port_t thread_exception_port);
-
void sigill_handler(int signal, siginfo_t *siginfo, os_context_t *context);
void sigtrap_handler(int signal, siginfo_t *siginfo, os_context_t *context);
void memory_fault_handler(int signal, siginfo_t *siginfo,
#endif
-#ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
-kern_return_t mach_thread_init(mach_port_t thread_exception_port);
-#endif
-
int arch_os_thread_init(struct thread *thread) {
#ifdef LISP_FEATURE_SB_THREAD
int n;
pthread_setspecific(specials,thread);
#endif
#ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
- mach_thread_init(THREAD_STRUCT_TO_EXCEPTION_PORT(thread));
+ mach_lisp_thread_init(thread);
#endif
#ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
exception_data_t code_vector,
mach_msg_type_number_t code_count)
{
- struct thread *th = (struct thread*) exception_port;
x86_thread_state32_t thread_state;
mach_msg_type_number_t state_count;
vm_address_t region_addr;
siginfo_t siginfo;
kern_return_t ret, dealloc_ret;
+ struct thread *th = (struct thread*) exception_port;
+
+ FSHOW((stderr,"/entering catch_exception_raise with exception: %d\n", exception));
+
/* Get state and info */
state_count = x86_THREAD_STATE32_COUNT;
if ((ret = thread_get_state(thread,