From: cgf Date: Wed, 14 Sep 2005 21:26:11 +0000 (+0000) Subject: * cygtls.h (san): New structure. X-Git-Tag: post_wait_sig_exit~92 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7d5b174309e6e1dc2f2104d7549b6eb15446d069;p=pf3gnuchains%2Fpf3gnuchains4x.git * cygtls.h (san): New structure. (cygtls::andreas): New element. Replaces _myfault and _myfault_errno. (cygtls::fault_guarded): Use andreas. (cygtls::return_from_fault): Ditto. (cygtls::setup_fault): Add a parameter denoting where to store old fault handler, if any and use it to "stack" faults. (cygtls::reset_fault): Restore fault from parameter. (myfault::sebastian): New variable. (myfault::~myfault): Pass sebastian to reset_fault. (myfault::myfault): Store old fault values in sebastian. --- diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e4bc02826f..9fb967f33d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,18 @@ 2005-09-14 Christopher Faylor + * cygtls.h (san): New structure. + (cygtls::andreas): New element. Replaces _myfault and _myfault_errno. + (cygtls::fault_guarded): Use andreas. + (cygtls::return_from_fault): Ditto. + (cygtls::setup_fault): Add a parameter denoting where to store old + fault handler, if any and use it to "stack" faults. + (cygtls::reset_fault): Restore fault from parameter. + (myfault::sebastian): New variable. + (myfault::~myfault): Pass sebastian to reset_fault. + (myfault::myfault): Store old fault values in sebastian. + +2005-09-14 Christopher Faylor + * heap.cc (heap_init): Revert 2005-09-11 patch as it seems to inexplicably cause problems with emacs. diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 65994ebfa8..33ffccb2f9 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -138,6 +138,12 @@ typedef struct struct_waitq HANDLE thread_ev; } waitq; +typedef struct +{ + void *_myfault; + int _myfault_errno; +} san; + /* Changes to the below structure may require acompanying changes to the very simple parser in the perl script 'gentls_offsets' (<<-- start parsing here). The union in this structure is used to force alignment between the version @@ -176,8 +182,7 @@ struct _cygtls }; struct _local_storage locals; class cygthread *_ctinfo; - void *_myfault; - int _myfault_errno; + san andreas; waitq wq; struct _cygtls *prev, *next; __stack_t *stackptr; @@ -220,25 +225,25 @@ struct _cygtls void lock () __attribute__ ((regparm (1))); void unlock () __attribute__ ((regparm (1))); bool locked () __attribute__ ((regparm (1))); - void*& fault_guarded () {return _myfault;} + void*& fault_guarded () {return andreas._myfault;} void return_from_fault () { - if (_myfault_errno) - set_errno (_myfault_errno); - __ljfault ((int *) _myfault, 1); + if (andreas._myfault_errno) + set_errno (andreas._myfault_errno); + __ljfault ((int *) andreas._myfault, 1); } - int setup_fault (jmp_buf j, int myerrno) __attribute__ ((always_inline)) + int setup_fault (jmp_buf j, san& old_j, int myerrno) __attribute__ ((always_inline)) { - if (_myfault) - return 0; - _myfault = (void *) j; - _myfault_errno = myerrno; + old_j._myfault = andreas._myfault; + old_j._myfault_errno = andreas._myfault_errno; + andreas._myfault = (void *) j; + andreas._myfault_errno = myerrno; return __sjfault (j); } - void clear_fault (jmp_buf j) __attribute__ ((always_inline)) + void reset_fault (san& old_j) __attribute__ ((always_inline)) { - if (j == _myfault) - _myfault = NULL; + andreas._myfault = old_j._myfault; + andreas._myfault_errno = old_j._myfault_errno; } /*gentls_offsets*/ }; @@ -254,11 +259,12 @@ extern _cygtls *_sig_tls; class myfault { jmp_buf buf; + san sebastian; public: - ~myfault () __attribute__ ((always_inline)) { _my_tls.clear_fault (buf); } + ~myfault () __attribute__ ((always_inline)) { _my_tls.reset_fault (sebastian); } inline int faulted (int myerrno = 0) __attribute__ ((always_inline)) { - return _my_tls.setup_fault (buf, myerrno); + return _my_tls.setup_fault (buf, sebastian, myerrno); } }; /*gentls_offsets*/ diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 910eeca361..3a96849326 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -938,7 +938,9 @@ cygwin_gethostbyname (const char *name) sig_dispatch_pending (); myfault efault; if (efault.faulted (EFAULT)) - return NULL; +{ console_printf ("OUCH!\n"); + return NULL; +} unsigned char tmp_addr[4]; struct hostent tmp, *h; @@ -969,7 +971,10 @@ cygwin_gethostbyname (const char *name) hostent *res = (hostent *) dup_ent (hostent_buf, h, t_hostent); if (res) - debug_printf ("h_name %s", res); +{ + debug_printf ("h_name %s", res->h_name); +debug_printf ("HERE"); +} else { debug_printf ("dup_ent returned NULL for name %s, h %p", name, h); diff --git a/winsup/cygwin/tlsoffsets.h b/winsup/cygwin/tlsoffsets.h index fa79106bb1..824e02ca38 100644 --- a/winsup/cygwin/tlsoffsets.h +++ b/winsup/cygwin/tlsoffsets.h @@ -37,10 +37,8 @@ //; $tls::plocals = 1264; //; $tls::_ctinfo = -1092; //; $tls::p_ctinfo = 2896; -//; $tls::_myfault = -1088; -//; $tls::p_myfault = 2900; -//; $tls::_myfault_errno = -1084; -//; $tls::p_myfault_errno = 2904; +//; $tls::andreas = -1088; +//; $tls::pandreas = 2900; //; $tls::wq = -1080; //; $tls::pwq = 2908; //; $tls::prev = -1052; @@ -99,10 +97,8 @@ #define tls_plocals (1264) #define tls__ctinfo (-1092) #define tls_p_ctinfo (2896) -#define tls__myfault (-1088) -#define tls_p_myfault (2900) -#define tls__myfault_errno (-1084) -#define tls_p_myfault_errno (2904) +#define tls_andreas (-1088) +#define tls_pandreas (2900) #define tls_wq (-1080) #define tls_pwq (2908) #define tls_prev (-1052)