From: Christopher Faylor Date: Thu, 25 May 2006 02:33:13 +0000 (+0000) Subject: * cygtls.cc (_cygtls::call): Call call2 using _my_tls. X-Git-Tag: pre-ptymaster-archetype~25 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=38229bcdcf45221857163f39d865d1d5d113a9b7;p=newlib-cygwin.git * cygtls.cc (_cygtls::call): Call call2 using _my_tls. (_cygtls::init_exception_handler): Always replace existing exception handler with cygwin exception handler. * cygtls.h (_cygtls::call2): Remove static designation. * dcrto.cc (dll_crt0_1): Define in a way that allows calling via _cygtls::call. (_initialize_main_tls): Delete. (_dll_crt0): Call dll_crt0_1 via cygtls::call. Set _main_tls here. * external.cc (cygwin_internal): Implement CW_CYGTLS_PADSIZE. * include/sys/cygwin.h (CW_CYGTLS_PADSIZE): Define. * tlsoffsets.h: Regenerate. --- diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 67ecac124..fd2372706 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,17 @@ +2006-05-24 Christopher Faylor + + * cygtls.cc (_cygtls::call): Call call2 using _my_tls. + (_cygtls::init_exception_handler): Always replace existing exception + handler with cygwin exception handler. + * cygtls.h (_cygtls::call2): Remove static designation. + * dcrto.cc (dll_crt0_1): Define in a way that allows calling via + _cygtls::call. + (_initialize_main_tls): Delete. + (_dll_crt0): Call dll_crt0_1 via cygtls::call. Set _main_tls here. + * external.cc (cygwin_internal): Implement CW_CYGTLS_PADSIZE. + * include/sys/cygwin.h (CW_CYGTLS_PADSIZE): Define. + * tlsoffsets.h: Regenerate. + 2006-05-24 Christopher Faylor * configure.in: Update to newer autoconf. diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index 4f4fe06e2..d3a67565b 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -64,15 +64,15 @@ void _cygtls::call (DWORD (*func) (void *, void *), void *arg) { char buf[CYGTLS_PADSIZE]; - call2 (func, arg, buf); + _my_tls.call2 (func, arg, buf); } void _cygtls::call2 (DWORD (*func) (void *, void *), void *arg, void *buf) { - _my_tls.init_thread (buf, func); + init_thread (buf, func); DWORD res = func (arg, buf); - _my_tls.remove (INFINITE); + remove (INFINITE); ExitThread (res); } @@ -248,10 +248,7 @@ _cygtls::handle_threadlist_exception (EXCEPTION_RECORD *e, exception_list *frame 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 +/* Set up the exception handler for the current thread. The x86 uses segment register fs, offset 0 to point to the current exception handler. */ extern exception_list *_except_list asm ("%fs:0"); @@ -260,9 +257,7 @@ void _cygtls::init_exception_handler (exception_handler *eh) { el.handler = eh; - el.prev = _except_list; - if (!el.prev->prev && !el.prev->handler) - el.prev = ⪙ + el.prev = ⪙ _except_list = ⪙ } diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index fb34df2d7..6379f8cec 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -138,6 +138,7 @@ typedef __uint32_t __stack_t; struct _cygtls { void (*func) /*gentls_offsets*/(int)/*gentls_offsets*/; + exception_list el; int saved_errno; int sa_flags; sigset_t oldmask; @@ -159,7 +160,6 @@ struct _cygtls }; struct _local_storage locals; class cygthread *_ctinfo; - exception_list el; san andreas; waitq wq; struct _cygtls *prev, *next; @@ -176,7 +176,7 @@ struct _cygtls static void init (); void init_thread (void *, DWORD (*) (void *, void *)); static void call (DWORD (*) (void *, void *), void *); - static void call2 (DWORD (*) (void *, void *), void *, void *) __attribute__ ((regparm (3))); + void call2 (DWORD (*) (void *, void *), void *, void *) __attribute__ ((regparm (3))); static struct _cygtls *find_tls (int sig); void remove (DWORD); void push (__stack_t) __attribute__ ((regparm (2))); diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 667699dd7..5469e7598 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -784,7 +784,7 @@ dll_crt0_0 () opposed to being link-time loaded by Cygwin apps) from a non cygwin app via LoadLibrary. */ static void -dll_crt0_1 (char *) +dll_crt0_1 (void *, void *) { check_sanity_and_sync (user_data); malloc_init (); @@ -953,37 +953,17 @@ dll_crt0_1 (char *) cygwin_exit (user_data->main (__argc, __argv, *user_data->envptr)); } -static void -initialize_main_tls (char *padding) -{ - if (!_main_tls) - { - _main_tls = &_my_tls; - _main_tls->init_thread (padding, NULL); - } - return; -} - -/* Wrap the real one, otherwise gdb gets confused about - two symbols with the same name, but different addresses. - - UPTR is a pointer to global data that lives on the libc side of the - line [if one distinguishes the application from the dll]. */ - extern "C" void __stdcall _dll_crt0 () { main_environ = user_data->envptr; - - char padding[CYGTLS_PADSIZE]; - if (in_forkee) fork_info->alloc_stack (); else __sinit (_impure_ptr); - initialize_main_tls (padding); - dll_crt0_1 (padding); + _main_tls = &_my_tls; + _main_tls->call ((DWORD (*) (void *, void *)) dll_crt0_1, NULL); } void diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 62007304f..a033df01a 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -348,6 +348,8 @@ cygwin_internal (cygwin_getinfo_types t, ...) case CW_SYNC_WINENV: sync_winenv (); return 0; + case CW_CYGTLS_PADSIZE: + return CYGTLS_PADSIZE; default: break; } diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index 1380194fb..26bfee086 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -86,7 +86,8 @@ typedef enum CW_ARGV, CW_ENVP, CW_DEBUG_SELF, - CW_SYNC_WINENV + CW_SYNC_WINENV, + CW_CYGTLS_PADSIZE } cygwin_getinfo_types; #define CW_NEXTPID 0x80000000 /* or with pid to get next one */ diff --git a/winsup/cygwin/tlsoffsets.h b/winsup/cygwin/tlsoffsets.h index 08702dadc..b0ddd9aa7 100644 --- a/winsup/cygwin/tlsoffsets.h +++ b/winsup/cygwin/tlsoffsets.h @@ -3,44 +3,44 @@ //; $tls::sizeof__cygtls = 4212; //; $tls::func = -12636; //; $tls::pfunc = 0; -//; $tls::saved_errno = -12632; -//; $tls::psaved_errno = 4; -//; $tls::sa_flags = -12628; -//; $tls::psa_flags = 8; -//; $tls::oldmask = -12624; -//; $tls::poldmask = 12; -//; $tls::deltamask = -12620; -//; $tls::pdeltamask = 16; -//; $tls::event = -12616; -//; $tls::pevent = 20; -//; $tls::errno_addr = -12612; -//; $tls::perrno_addr = 24; -//; $tls::sigmask = -12608; -//; $tls::psigmask = 28; -//; $tls::sigwait_mask = -12604; -//; $tls::psigwait_mask = 32; -//; $tls::sigwait_info = -12600; -//; $tls::psigwait_info = 36; -//; $tls::thread_context = -12596; -//; $tls::pthread_context = 40; -//; $tls::thread_id = -12384; -//; $tls::pthread_id = 252; -//; $tls::threadkill = -12380; -//; $tls::pthreadkill = 256; -//; $tls::infodata = -12376; -//; $tls::pinfodata = 260; -//; $tls::tid = -12228; -//; $tls::ptid = 408; -//; $tls::local_clib = -12224; -//; $tls::plocal_clib = 412; -//; $tls::__dontuse = -12224; -//; $tls::p__dontuse = 412; -//; $tls::locals = -11160; -//; $tls::plocals = 1476; -//; $tls::_ctinfo = -9528; -//; $tls::p_ctinfo = 3108; -//; $tls::el = -9524; -//; $tls::pel = 3112; +//; $tls::el = -12632; +//; $tls::pel = 4; +//; $tls::saved_errno = -12624; +//; $tls::psaved_errno = 12; +//; $tls::sa_flags = -12620; +//; $tls::psa_flags = 16; +//; $tls::oldmask = -12616; +//; $tls::poldmask = 20; +//; $tls::deltamask = -12612; +//; $tls::pdeltamask = 24; +//; $tls::event = -12608; +//; $tls::pevent = 28; +//; $tls::errno_addr = -12604; +//; $tls::perrno_addr = 32; +//; $tls::sigmask = -12600; +//; $tls::psigmask = 36; +//; $tls::sigwait_mask = -12596; +//; $tls::psigwait_mask = 40; +//; $tls::sigwait_info = -12592; +//; $tls::psigwait_info = 44; +//; $tls::thread_context = -12588; +//; $tls::pthread_context = 48; +//; $tls::thread_id = -12376; +//; $tls::pthread_id = 260; +//; $tls::threadkill = -12372; +//; $tls::pthreadkill = 264; +//; $tls::infodata = -12368; +//; $tls::pinfodata = 268; +//; $tls::tid = -12220; +//; $tls::ptid = 416; +//; $tls::local_clib = -12216; +//; $tls::plocal_clib = 420; +//; $tls::__dontuse = -12216; +//; $tls::p__dontuse = 420; +//; $tls::locals = -11152; +//; $tls::plocals = 1484; +//; $tls::_ctinfo = -9520; +//; $tls::p_ctinfo = 3116; //; $tls::andreas = -9516; //; $tls::pandreas = 3120; //; $tls::wq = -9508; @@ -67,44 +67,44 @@ #define tls_func (-12636) #define tls_pfunc (0) -#define tls_saved_errno (-12632) -#define tls_psaved_errno (4) -#define tls_sa_flags (-12628) -#define tls_psa_flags (8) -#define tls_oldmask (-12624) -#define tls_poldmask (12) -#define tls_deltamask (-12620) -#define tls_pdeltamask (16) -#define tls_event (-12616) -#define tls_pevent (20) -#define tls_errno_addr (-12612) -#define tls_perrno_addr (24) -#define tls_sigmask (-12608) -#define tls_psigmask (28) -#define tls_sigwait_mask (-12604) -#define tls_psigwait_mask (32) -#define tls_sigwait_info (-12600) -#define tls_psigwait_info (36) -#define tls_thread_context (-12596) -#define tls_pthread_context (40) -#define tls_thread_id (-12384) -#define tls_pthread_id (252) -#define tls_threadkill (-12380) -#define tls_pthreadkill (256) -#define tls_infodata (-12376) -#define tls_pinfodata (260) -#define tls_tid (-12228) -#define tls_ptid (408) -#define tls_local_clib (-12224) -#define tls_plocal_clib (412) -#define tls___dontuse (-12224) -#define tls_p__dontuse (412) -#define tls_locals (-11160) -#define tls_plocals (1476) -#define tls__ctinfo (-9528) -#define tls_p_ctinfo (3108) -#define tls_el (-9524) -#define tls_pel (3112) +#define tls_el (-12632) +#define tls_pel (4) +#define tls_saved_errno (-12624) +#define tls_psaved_errno (12) +#define tls_sa_flags (-12620) +#define tls_psa_flags (16) +#define tls_oldmask (-12616) +#define tls_poldmask (20) +#define tls_deltamask (-12612) +#define tls_pdeltamask (24) +#define tls_event (-12608) +#define tls_pevent (28) +#define tls_errno_addr (-12604) +#define tls_perrno_addr (32) +#define tls_sigmask (-12600) +#define tls_psigmask (36) +#define tls_sigwait_mask (-12596) +#define tls_psigwait_mask (40) +#define tls_sigwait_info (-12592) +#define tls_psigwait_info (44) +#define tls_thread_context (-12588) +#define tls_pthread_context (48) +#define tls_thread_id (-12376) +#define tls_pthread_id (260) +#define tls_threadkill (-12372) +#define tls_pthreadkill (264) +#define tls_infodata (-12368) +#define tls_pinfodata (268) +#define tls_tid (-12220) +#define tls_ptid (416) +#define tls_local_clib (-12216) +#define tls_plocal_clib (420) +#define tls___dontuse (-12216) +#define tls_p__dontuse (420) +#define tls_locals (-11152) +#define tls_plocals (1484) +#define tls__ctinfo (-9520) +#define tls_p_ctinfo (3116) #define tls_andreas (-9516) #define tls_pandreas (3120) #define tls_wq (-9508)