Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-09-15 01:26:15 +0400
committerChristopher Faylor <me@cgf.cx>2005-09-15 01:26:15 +0400
commitc9629cefe942778a9c440e707e203b135de162ae (patch)
treee0927d50ab8b8c1266633af33876269c8c847203
parent1f48d233ebee49407b8900a2214e5d582be86555 (diff)
* 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.
-rw-r--r--winsup/cygwin/ChangeLog13
-rw-r--r--winsup/cygwin/cygtls.h38
-rw-r--r--winsup/cygwin/net.cc9
-rw-r--r--winsup/cygwin/tlsoffsets.h12
4 files changed, 46 insertions, 26 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e4bc02826..9fb967f33 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,18 @@
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
inexplicably cause problems with emacs.
diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h
index 65994ebfa..33ffccb2f 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 910eeca36..3a9684932 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 fa79106bb..824e02ca3 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)