* 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.
This commit is contained in:
Christopher Faylor 2005-09-14 21:26:15 +00:00
parent 1f48d233eb
commit c9629cefe9
4 changed files with 46 additions and 26 deletions

View File

@ -1,3 +1,16 @@
2005-09-14 Christopher Faylor <cgf@timesys.com>
* 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 <cgf@timesys.com>
* heap.cc (heap_init): Revert 2005-09-11 patch as it seems to

View File

@ -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*/

View File

@ -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);

View File

@ -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)