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
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2006-05-16 07:14:24 +0400
committerChristopher Faylor <me@cgf.cx>2006-05-16 07:14:24 +0400
commit562adf789066f0bbcd2999944a2648b42e8e8df9 (patch)
tree4f94240c4750774b1d4c0ac8dab6e5766e19859d /winsup
parenta9e36321fda82e1f565f2291a2fc4eaf97de4fc6 (diff)
* sigproc.cc (no_signals_available): Detect hwait_sig == INVALID_HANDLE_VALUE.
(wait_sig): Set hwait_sig to INVALID_HANDLE_VALUE on __SIGEXIT. * cygtls.cc (_cygtls::init_thread): Zero entire _my_tls structure and no more. * cygtls.h (_my_tls::padding): Delete. (CYGTLS_PADSIZE): Redefine concept of padding to mean padding at the end of the stack. * dcrt0.cc (initialize_main_tls): Change return to void. * gentls_offsets: Treat const specially, too. Keep going after a '}' is found. Change negative offset calculation to use CYGTLS_PADSIZE. * init.cc (_my_oldfunc): New variable. (threadfunc_fe): Use stored tls value for oldfunc rather than blindly writing to the stack. (munge_threadfunc): Set oldfunc in tls. (dll_entry): Initialize tls allocation. * tlsoffsets.h: Regenerate.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog23
-rw-r--r--winsup/cygwin/cygtls.cc2
-rw-r--r--winsup/cygwin/cygtls.h11
-rw-r--r--winsup/cygwin/dcrt0.cc4
-rwxr-xr-xwinsup/cygwin/gentls_offsets11
-rw-r--r--winsup/cygwin/init.cc7
-rw-r--r--winsup/cygwin/sigproc.cc4
-rw-r--r--winsup/cygwin/tlsoffsets.h128
8 files changed, 105 insertions, 85 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index f8ff92e3a..0d419e55b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,26 @@
+2006-05-15 Christopher Faylor <cgf@timesys.com>
+
+ * sigproc.cc (no_signals_available): Detect hwait_sig ==
+ INVALID_HANDLE_VALUE.
+ (wait_sig): Set hwait_sig to INVALID_HANDLE_VALUE on __SIGEXIT.
+
+2006-05-14 Christopher Faylor <cgf@timesys.com>
+
+ * cygtls.cc (_cygtls::init_thread): Zero entire _my_tls structure and
+ no more.
+ * cygtls.h (_my_tls::padding): Delete.
+ (CYGTLS_PADSIZE): Redefine concept of padding to mean padding at the
+ end of the stack.
+ * dcrt0.cc (initialize_main_tls): Change return to void.
+ * gentls_offsets: Treat const specially, too. Keep going after a '}'
+ is found. Change negative offset calculation to use CYGTLS_PADSIZE.
+ * init.cc (_my_oldfunc): New variable.
+ (threadfunc_fe): Use stored tls value for oldfunc rather than blindly
+ writing to the stack.
+ (munge_threadfunc): Set oldfunc in tls.
+ (dll_entry): Initialize tls allocation.
+ * tlsoffsets.h: Regenerate.
+
2006-05-13 Christopher Faylor <cgf@timesys.com>
* ntdll.h (STATUS_INVALID_INFO_CLASS): Conditionalize.
diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc
index 70f5a56d8..f897ca53f 100644
--- a/winsup/cygwin/cygtls.cc
+++ b/winsup/cygwin/cygtls.cc
@@ -81,7 +81,7 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *))
{
if (x)
{
- memset (this, 0, CYGTLS_PADSIZE);
+ memset (this, 0, sizeof (*this));
stackptr = stack;
if (_GLOBAL_REENT)
{
diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h
index 030680be0..fb34df2d7 100644
--- a/winsup/cygwin/cygtls.h
+++ b/winsup/cygwin/cygtls.h
@@ -170,7 +170,6 @@ struct _cygtls
__stack_t *stackptr;
__stack_t stack[TLS_STACK_SIZE];
unsigned initialized;
- unsigned padding[0];
/*gentls_offsets*/
static CRITICAL_SECTION protect_linked_list;
@@ -235,13 +234,15 @@ struct _cygtls
};
#pragma pack(pop)
+const int CYGTLS_PADSIZE = 3 * sizeof (_cygtls);
+/*gentls_offsets*/
+
extern char *_tlsbase __asm__ ("%fs:4");
extern char *_tlstop __asm__ ("%fs:8");
-#define _my_tls (((_cygtls *) _tlsbase)[-1])
+#define _my_tls (*((_cygtls *) (_tlsbase - CYGTLS_PADSIZE)))
extern _cygtls *_main_tls;
extern _cygtls *_sig_tls;
-/*gentls_offsets*/
class myfault
{
jmp_buf buf;
@@ -253,9 +254,7 @@ public:
return _my_tls.setup_fault (buf, sebastian, myerrno);
}
};
-/*gentls_offsets*/
#define __getreent() (&_my_tls.local_clib)
-const int CYGTLS_PADSIZE = (((char *) _main_tls->padding) - ((char *) _main_tls));
-#endif /*_CYGTLS_H*/
+#endif /*_CYGTLS_H*/ /*gentls_offsets*/
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index dcc13d528..667699dd7 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -953,7 +953,7 @@ dll_crt0_1 (char *)
cygwin_exit (user_data->main (__argc, __argv, *user_data->envptr));
}
-struct _reent *
+static void
initialize_main_tls (char *padding)
{
if (!_main_tls)
@@ -961,7 +961,7 @@ initialize_main_tls (char *padding)
_main_tls = &_my_tls;
_main_tls->init_thread (padding, NULL);
}
- return &_main_tls->local_clib;
+ return;
}
/* Wrap the real one, otherwise gdb gets confused about
diff --git a/winsup/cygwin/gentls_offsets b/winsup/cygwin/gentls_offsets
index 21c9d1e7a..0ab6b64ab 100755
--- a/winsup/cygwin/gentls_offsets
+++ b/winsup/cygwin/gentls_offsets
@@ -21,12 +21,11 @@ $pre =~ s/\n#ifndef _[^\n]+\n/\n/os;
$pre .= "\n//*/";
$tls =~ s%/\*\s*gentls_offsets.*?/\*\s*gentls_offsets\s*\*/%%ogs;
foreach ($tls =~ /^.*\n/mg) {
- $def .= $_ if $struct;
- last if /^};/o;
- /^\s*typedef/o and do {
+ /^}|\s*(?:typedef|const)/o and do {
$def .= $_ ;
next;
};
+ $def .= $_ if $struct;
if (!s/;.*$//o) {
if (!$struct && /^\s*(?:struct|class)\s*([a-z_0-9]+)/o) {
$def .= $_;
@@ -55,9 +54,9 @@ $def
int
main(int argc, char **argv)
{
- $struct foo[1];
-# define foo_end ((char *) (foo + 1))
-# define offset(f) (((char *) &(foo->f)) - foo_end)
+ $struct *foo;
+# define foo_beg ((char *) foo)
+# define offset(f) (-CYGTLS_PADSIZE + ((char *) &(foo->f)) - foo_beg)
# define poffset(f) (((char *) &(foo->f)) - ((char *) foo))
EOF
print TMP 'puts ("//;# autogenerated: Do not edit.\n");', "\n\n";
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index f8b6cd652..f73be7236 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -18,6 +18,8 @@ details. */
#include <ntdef.h>
#include "ntdll.h"
+static DWORD _my_oldfunc;
+
int NO_COPY dynamically_loaded;
static char NO_COPY *search_for = (char *) cygthread::stub;
unsigned threadfunc_ix[8] __attribute__((section (".cygwin_dll_common"), shared));
@@ -30,7 +32,7 @@ threadfunc_fe (VOID *arg)
{
(void)__builtin_return_address(1);
asm volatile ("andl $-16,%%esp" ::: "%esp");
- _cygtls::call ((DWORD (*) (void *, void *)) (((char **) _tlsbase)[OLDFUNC_OFFSET]), arg);
+ _cygtls::call ((DWORD (*) (void *, void *)) TlsGetValue (_my_oldfunc), arg);
}
/* If possible, redirect the thread entry point to a cygwin routine which
@@ -62,7 +64,7 @@ munge_threadfunc ()
search_for = NULL;
for (i = 0; threadfunc_ix[i]; i++)
ebp[threadfunc_ix[i]] = (char *) threadfunc_fe;
- ((char **) _tlsbase)[OLDFUNC_OFFSET] = threadfunc;
+ TlsSetValue (_my_oldfunc, threadfunc);
}
}
}
@@ -145,6 +147,7 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
respawn_wow64_process ();
dll_crt0_0 ();
+ _my_oldfunc = TlsAlloc ();
break;
case DLL_PROCESS_DETACH:
break;
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 10ff3cefc..9eb918dc1 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -39,7 +39,7 @@ details. */
#define WSSC 60000 // Wait for signal completion
#define WPSP 40000 // Wait for proc_subproc mutex
-#define no_signals_available(x) (!hwait_sig || ((x) && myself->exitcode & EXITCODE_SET) || &_my_tls == _sig_tls || in_dllentry)
+#define no_signals_available(x) (!hwait_sig || hwait_sig == INVALID_HANDLE_VALUE || ((x) && myself->exitcode & EXITCODE_SET) || &_my_tls == _sig_tls || in_dllentry)
#define NPROCS 256
@@ -1209,7 +1209,7 @@ wait_sig (VOID *)
}
break;
case __SIGEXIT:
- hwait_sig = NULL;
+ hwait_sig = (cygthread *) INVALID_HANDLE_VALUE;
sigproc_printf ("saw __SIGEXIT");
break; /* handle below */
default:
diff --git a/winsup/cygwin/tlsoffsets.h b/winsup/cygwin/tlsoffsets.h
index 9002abfce..08702dadc 100644
--- a/winsup/cygwin/tlsoffsets.h
+++ b/winsup/cygwin/tlsoffsets.h
@@ -1,133 +1,129 @@
//;# autogenerated: Do not edit.
//; $tls::sizeof__cygtls = 4212;
-//; $tls::func = -4212;
+//; $tls::func = -12636;
//; $tls::pfunc = 0;
-//; $tls::saved_errno = -4208;
+//; $tls::saved_errno = -12632;
//; $tls::psaved_errno = 4;
-//; $tls::sa_flags = -4204;
+//; $tls::sa_flags = -12628;
//; $tls::psa_flags = 8;
-//; $tls::oldmask = -4200;
+//; $tls::oldmask = -12624;
//; $tls::poldmask = 12;
-//; $tls::deltamask = -4196;
+//; $tls::deltamask = -12620;
//; $tls::pdeltamask = 16;
-//; $tls::event = -4192;
+//; $tls::event = -12616;
//; $tls::pevent = 20;
-//; $tls::errno_addr = -4188;
+//; $tls::errno_addr = -12612;
//; $tls::perrno_addr = 24;
-//; $tls::sigmask = -4184;
+//; $tls::sigmask = -12608;
//; $tls::psigmask = 28;
-//; $tls::sigwait_mask = -4180;
+//; $tls::sigwait_mask = -12604;
//; $tls::psigwait_mask = 32;
-//; $tls::sigwait_info = -4176;
+//; $tls::sigwait_info = -12600;
//; $tls::psigwait_info = 36;
-//; $tls::thread_context = -4172;
+//; $tls::thread_context = -12596;
//; $tls::pthread_context = 40;
-//; $tls::thread_id = -3960;
+//; $tls::thread_id = -12384;
//; $tls::pthread_id = 252;
-//; $tls::threadkill = -3956;
+//; $tls::threadkill = -12380;
//; $tls::pthreadkill = 256;
-//; $tls::infodata = -3952;
+//; $tls::infodata = -12376;
//; $tls::pinfodata = 260;
-//; $tls::tid = -3804;
+//; $tls::tid = -12228;
//; $tls::ptid = 408;
-//; $tls::local_clib = -3800;
+//; $tls::local_clib = -12224;
//; $tls::plocal_clib = 412;
-//; $tls::__dontuse = -3800;
+//; $tls::__dontuse = -12224;
//; $tls::p__dontuse = 412;
-//; $tls::locals = -2736;
+//; $tls::locals = -11160;
//; $tls::plocals = 1476;
-//; $tls::_ctinfo = -1104;
+//; $tls::_ctinfo = -9528;
//; $tls::p_ctinfo = 3108;
-//; $tls::el = -1100;
+//; $tls::el = -9524;
//; $tls::pel = 3112;
-//; $tls::andreas = -1092;
+//; $tls::andreas = -9516;
//; $tls::pandreas = 3120;
-//; $tls::wq = -1084;
+//; $tls::wq = -9508;
//; $tls::pwq = 3128;
-//; $tls::prev = -1056;
+//; $tls::prev = -9480;
//; $tls::pprev = 3156;
-//; $tls::next = -1052;
+//; $tls::next = -9476;
//; $tls::pnext = 3160;
-//; $tls::sig = -1048;
+//; $tls::sig = -9472;
//; $tls::psig = 3164;
-//; $tls::incyg = -1044;
+//; $tls::incyg = -9468;
//; $tls::pincyg = 3168;
-//; $tls::spinning = -1040;
+//; $tls::spinning = -9464;
//; $tls::pspinning = 3172;
-//; $tls::stacklock = -1036;
+//; $tls::stacklock = -9460;
//; $tls::pstacklock = 3176;
-//; $tls::stackptr = -1032;
+//; $tls::stackptr = -9456;
//; $tls::pstackptr = 3180;
-//; $tls::stack = -1028;
+//; $tls::stack = -9452;
//; $tls::pstack = 3184;
-//; $tls::initialized = -4;
+//; $tls::initialized = -8428;
//; $tls::pinitialized = 4208;
-//; $tls::padding = 0;
-//; $tls::ppadding = 4212;
//; __DATA__
-#define tls_func (-4212)
+#define tls_func (-12636)
#define tls_pfunc (0)
-#define tls_saved_errno (-4208)
+#define tls_saved_errno (-12632)
#define tls_psaved_errno (4)
-#define tls_sa_flags (-4204)
+#define tls_sa_flags (-12628)
#define tls_psa_flags (8)
-#define tls_oldmask (-4200)
+#define tls_oldmask (-12624)
#define tls_poldmask (12)
-#define tls_deltamask (-4196)
+#define tls_deltamask (-12620)
#define tls_pdeltamask (16)
-#define tls_event (-4192)
+#define tls_event (-12616)
#define tls_pevent (20)
-#define tls_errno_addr (-4188)
+#define tls_errno_addr (-12612)
#define tls_perrno_addr (24)
-#define tls_sigmask (-4184)
+#define tls_sigmask (-12608)
#define tls_psigmask (28)
-#define tls_sigwait_mask (-4180)
+#define tls_sigwait_mask (-12604)
#define tls_psigwait_mask (32)
-#define tls_sigwait_info (-4176)
+#define tls_sigwait_info (-12600)
#define tls_psigwait_info (36)
-#define tls_thread_context (-4172)
+#define tls_thread_context (-12596)
#define tls_pthread_context (40)
-#define tls_thread_id (-3960)
+#define tls_thread_id (-12384)
#define tls_pthread_id (252)
-#define tls_threadkill (-3956)
+#define tls_threadkill (-12380)
#define tls_pthreadkill (256)
-#define tls_infodata (-3952)
+#define tls_infodata (-12376)
#define tls_pinfodata (260)
-#define tls_tid (-3804)
+#define tls_tid (-12228)
#define tls_ptid (408)
-#define tls_local_clib (-3800)
+#define tls_local_clib (-12224)
#define tls_plocal_clib (412)
-#define tls___dontuse (-3800)
+#define tls___dontuse (-12224)
#define tls_p__dontuse (412)
-#define tls_locals (-2736)
+#define tls_locals (-11160)
#define tls_plocals (1476)
-#define tls__ctinfo (-1104)
+#define tls__ctinfo (-9528)
#define tls_p_ctinfo (3108)
-#define tls_el (-1100)
+#define tls_el (-9524)
#define tls_pel (3112)
-#define tls_andreas (-1092)
+#define tls_andreas (-9516)
#define tls_pandreas (3120)
-#define tls_wq (-1084)
+#define tls_wq (-9508)
#define tls_pwq (3128)
-#define tls_prev (-1056)
+#define tls_prev (-9480)
#define tls_pprev (3156)
-#define tls_next (-1052)
+#define tls_next (-9476)
#define tls_pnext (3160)
-#define tls_sig (-1048)
+#define tls_sig (-9472)
#define tls_psig (3164)
-#define tls_incyg (-1044)
+#define tls_incyg (-9468)
#define tls_pincyg (3168)
-#define tls_spinning (-1040)
+#define tls_spinning (-9464)
#define tls_pspinning (3172)
-#define tls_stacklock (-1036)
+#define tls_stacklock (-9460)
#define tls_pstacklock (3176)
-#define tls_stackptr (-1032)
+#define tls_stackptr (-9456)
#define tls_pstackptr (3180)
-#define tls_stack (-1028)
+#define tls_stack (-9452)
#define tls_pstack (3184)
-#define tls_initialized (-4)
+#define tls_initialized (-8428)
#define tls_pinitialized (4208)
-#define tls_padding (0)
-#define tls_ppadding (4212)