From f153e6b2804f06315d748bd1c8cad9f76798db09 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 3 Dec 2005 04:23:35 +0000 Subject: * cygtls.h (_cygtls::el): New field. (_cygtls::handle_exceptions): New function declaration. (_cygtls::handle_threadlist_exception): Ditto. (_cygtls::init_exception_handler): Ditto. (_cygtls::init_threadlist_exceptions): Remove arg from declaration. * cygtls.cc (_cygtls::call2): Don't initialize exceptions here. (_cygtls::init_thread): Do it here instead and use member function. (_cygtls::handle_threadlist_exception): Move into _cygtls class. (_cygtls::init_exception_handler): Ditto. Rely on existence of 'el' memmber in _cygtls. (_cygtls::init_threadlist_exceptions): Ditto. * dcrt0.cc (dll_crt0_1): Remove exception_list definition and setting since it now commonly resides in the tls. * exceptions.cc (init_exception_handler): Move to cygtls.cc. (init_exceptions): Ditto. (rtl_unwind): New, safe wrapper function for RtlUnwind. (_cygtls::handle_exceptions): Move to _cygtls. Call rtl_unwind to unwind frames and eliminate copying of structures. Put address of failing instruction in si_addr, not the address on the stack. Return 0 to indicate that we've handled this exception. * external.cc (cygwin_internal): Make CW_INIT_EXCEPTIONS a no-op. * sigproc.cc (wait_sig): Accommodate argument change to _cygtls::init_threadlist_exceptions. * tlsoffsets.h: Regenerate. * include/exceptions.h (exception_list): Add more stuff to the exception list. Apparently windows needs this? (init_exceptions): Remove bogus declaration. * include/cygwin/signal.h (SI_USER): Redefine as zero as per SUSv3. * thread.cc (pthread_kill): Set si_pid and si_uid. * timer.cc (timer_thread): Set si_code to SI_TIMER. --- winsup/cygwin/cygtls.cc | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'winsup/cygwin/cygtls.cc') diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index da72fc2ec..1e6ff4dd0 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -88,10 +88,6 @@ _cygtls::call (DWORD (*func) (void *, void *), void *arg) void _cygtls::call2 (DWORD (*func) (void *, void *), void *arg, void *buf) { - exception_list except_entry; - /* Initialize this thread's ability to respond to things like - SIGSEGV or SIGFPE. */ - init_exceptions (&except_entry); _my_tls.init_thread (buf, func); DWORD res = func (arg, buf); _my_tls.remove (INFINITE); @@ -117,6 +113,9 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *)) } local_clib._current_locale = "C"; locals.process_logmask = LOG_UPTO (LOG_DEBUG); + /* Initialize this thread's ability to respond to things like + SIGSEGV or SIGFPE. */ + init_exception_handler (handle_exceptions); } locals.exitsock = INVALID_SOCKET; @@ -240,8 +239,8 @@ _cygtls::set_siginfo (sigpacket *pack) } extern "C" DWORD __stdcall RtlUnwind (void *, void *, void *, DWORD); -static int -handle_threadlist_exception (EXCEPTION_RECORD *e, void *frame, CONTEXT *c, void *) +int +_cygtls::handle_threadlist_exception (EXCEPTION_RECORD *e, void *frame, CONTEXT *c, void *) { if (e->ExceptionCode != STATUS_ACCESS_VIOLATION) { @@ -269,9 +268,24 @@ handle_threadlist_exception (EXCEPTION_RECORD *e, void *frame, CONTEXT *c, void return 0; } +/* Set up the exception handler for the current thread. The PowerPC & Mips + use compiler generated tables to set up the exception handlers for each + region of code, and the kernel walks the call list until it finds a region + of code that handles exceptions. The x86 on the other hand uses segment + register fs, offset 0 to point to the current exception handler. */ + +extern exception_list *_except_list asm ("%fs:0"); + +void +_cygtls::init_exception_handler (exception_handler *eh) +{ + el.handler = eh; + el.prev = _except_list; + _except_list = ⪙ +} + void -_cygtls::init_threadlist_exceptions (exception_list *el) +_cygtls::init_threadlist_exceptions () { - extern void init_exception_handler (exception_list *, exception_handler *); - init_exception_handler (el, handle_threadlist_exception); + init_exception_handler (handle_threadlist_exception); } -- cgit v1.2.3