aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2004-01-12 05:15:19 +0000
committerChristopher Faylor <me@cgf.cx>2004-01-12 05:15:19 +0000
commit5fe1d511b31fd096900fd6b576e256d41619c729 (patch)
tree918d456fd82af47c73eb99042e159695408b6752
parent9f56121f838c08352afc304f4f84e2fc2009aed6 (diff)
downloadnewlib-5fe1d511b31fd096900fd6b576e256d41619c729.zip
newlib-5fe1d511b31fd096900fd6b576e256d41619c729.tar.gz
newlib-5fe1d511b31fd096900fd6b576e256d41619c729.tar.bz2
* Makefile.in (DLL_IMPORTS): Link advapi32 to ensure proper DLL initialization.
* autoload.cc (RegCloseKey): Arbitrarily choose this function as a "seed" to pull the advapi32 link library in. So, comment out the autoloading. * cygtls.cc (_threadinfo::init_thread): Just clear CYGTLS_PADSIZE. (_threadinfo::remove): Add debugging. (_threadinfo::find_tls): Ditto. * cygtls.h (_threadinfo::padding): Make zero length (for now?). * dcrt0.cc (dll_crt0_0): Move more initialization here from dll_crt0_1. (dll_crt0_1): See above. * dtable.h (dtable::lock): Remove commented out critical section locking. * dtable.h (dtable::init_lock): Remove commented out critical section locking. * dtable.h (dtable::unlock): Remove commented out critical section locking. * exceptions.cc (interruptible): bool'ize. * init.cc (threadfunc_fe): Revert to storing threadfunc at stack bottom. (munge_threadfunc): Ditto. Avoid adding overhead to calibration_thread. (prime_threads): Don't initialize tls stuff. (dll_entry): Make minor change to initialization order. * tlsoffsets.h: Regenerate. * sigproc.cc (wait_sig): Add sanity check for end of process thread exit. * select.h: Make minor formatting change.
-rw-r--r--winsup/cygwin/ChangeLog33
-rw-r--r--winsup/cygwin/Makefile.in2
-rw-r--r--winsup/cygwin/autoload.cc2
-rw-r--r--winsup/cygwin/cygheap.cc1
-rw-r--r--winsup/cygwin/cygthread.cc3
-rw-r--r--winsup/cygwin/cygtls.cc4
-rw-r--r--winsup/cygwin/cygtls.h4
-rw-r--r--winsup/cygwin/dcrt0.cc28
-rw-r--r--winsup/cygwin/dtable.h6
-rw-r--r--winsup/cygwin/exceptions.cc10
-rw-r--r--winsup/cygwin/init.cc22
-rw-r--r--winsup/cygwin/select.h5
-rw-r--r--winsup/cygwin/sigproc.cc2
-rw-r--r--winsup/cygwin/tlsoffsets.h84
14 files changed, 122 insertions, 84 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 88606d1..2e91790 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,36 @@
+2004-01-12 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in (DLL_IMPORTS): Link advapi32 to ensure proper DLL
+ initialization.
+ * autoload.cc (RegCloseKey): Arbitrarily choose this function as a
+ "seed" to pull the advapi32 link library in. So, comment out the
+ autoloading.
+ * cygtls.cc (_threadinfo::init_thread): Just clear CYGTLS_PADSIZE.
+ (_threadinfo::remove): Add debugging.
+ (_threadinfo::find_tls): Ditto.
+ * cygtls.h (_threadinfo::padding): Make zero length (for now?).
+ * dcrt0.cc (dll_crt0_0): Move more initialization here from dll_crt0_1.
+ (dll_crt0_1): See above.
+ * dtable.h (dtable::lock): Remove commented out critical section
+ locking.
+ * dtable.h (dtable::init_lock): Remove commented out critical section
+ locking.
+ * dtable.h (dtable::unlock): Remove commented out critical section
+ locking.
+ * exceptions.cc (interruptible): bool'ize.
+ * init.cc (threadfunc_fe): Revert to storing threadfunc at stack
+ bottom.
+ (munge_threadfunc): Ditto. Avoid adding overhead to
+ calibration_thread.
+ (prime_threads): Don't initialize tls stuff.
+ (dll_entry): Make minor change to initialization order.
+ * tlsoffsets.h: Regenerate.
+
+ * sigproc.cc (wait_sig): Add sanity check for end of process thread
+ exit.
+
+ * select.h: Make minor formatting change.
+
2004-01-10 Christopher Faylor <cgf@redhat.com>
* Makefile.in: Add still more -fomit-frame-pointer functions.
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index c3336bc..cf15b32 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -113,7 +113,7 @@ EXTRA_OFILES=$(bupdir1)/libiberty/random.o $(bupdir1)/libiberty/strsignal.o
MALLOC_OFILES=@MALLOC_OFILES@
-DLL_IMPORTS:=$(w32api_lib)/libkernel32.a
+DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libadvapi32.a
MT_SAFE_OBJECTS:=
# Please maintain this list in sorted order, with maximum files per 80 col line
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 1628480..6d0177f 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -354,7 +354,7 @@ LoadDLLfunc (LsaQueryInformationPolicy, 12, advapi32)
LoadDLLfunc (MakeSelfRelativeSD, 12, advapi32)
LoadDLLfunc (OpenProcessToken, 12, advapi32)
LoadDLLfunc (OpenThreadToken, 16, advapi32)
-LoadDLLfunc (RegCloseKey, 4, advapi32)
+// LoadDLLfunc (RegCloseKey, 4, advapi32)
LoadDLLfunc (RegCreateKeyExA, 36, advapi32)
LoadDLLfunc (RegDeleteKeyA, 8, advapi32)
LoadDLLfunc (RegDeleteValueA, 8, advapi32)
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index b6dbe26..0171f99 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -216,6 +216,7 @@ cygheap_init ()
cygheap->fdtab.init ();
if (!cygheap->sigs)
sigalloc ();
+
if (!cygheap->shared_prefix)
cygheap->shared_prefix = cstrdup (
wincap.has_terminal_services ()
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index eb761ea..e830196 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -40,7 +40,7 @@ cygthread::stub (VOID *arg)
CloseHandle (info->ev);
CloseHandle (info->thread_sync);
}
- info->ev = info->thread_sync = info->stack_ptr = NULL;
+ info->ev = info->thread_sync = info->stack_ptr = NULL;
}
else
{
@@ -51,6 +51,7 @@ cygthread::stub (VOID *arg)
info->thread_sync = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
}
}
+
while (1)
{
if (!info->__name)
diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc
index 7fe9af5..4514ba1 100644
--- a/winsup/cygwin/cygtls.cc
+++ b/winsup/cygwin/cygtls.cc
@@ -98,7 +98,7 @@ _threadinfo::init_thread (void *x, DWORD (*func) (void *, void *))
{
if (x)
{
- memset (this, 0, ((char *) padding - (char *) this));
+ memset (this, 0, CYGTLS_PADSIZE);
stackptr = stack;
if (_GLOBAL_REENT)
{
@@ -134,6 +134,7 @@ _threadinfo::init_thread (void *x, DWORD (*func) (void *, void *))
void
_threadinfo::remove (DWORD wait)
{
+ debug_printf ("wait %p\n", wait);
sentry here (wait);
if (here.acquired ())
{
@@ -174,6 +175,7 @@ static size_t NO_COPY threadlist_ix = BAD_IX;
_threadinfo *
_threadinfo::find_tls (int sig)
{
+ debug_printf ("sig %d\n", sig);
sentry here (INFINITE);
__asm__ volatile (".equ _threadlist_exception_return,.");
_threadinfo *res = NULL;
diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h
index 5dcbbe3..f3fadfb 100644
--- a/winsup/cygwin/cygtls.h
+++ b/winsup/cygwin/cygtls.h
@@ -110,7 +110,7 @@ struct _threadinfo
__stack_t *stackptr;
int sig;
__stack_t stack[TLS_STACK_SIZE];
- unsigned padding[256];
+ unsigned padding[0];
/*gentls_offsets*/
static CRITICAL_SECTION protect_linked_list;
@@ -142,5 +142,5 @@ extern _threadinfo *_main_tls;
#define __getreent() (&_my_tls.local_clib)
-#define CYGTLS_PADSIZE (sizeof (_threadinfo))
+enum {CYGTLS_PADSIZE = (((char *) _main_tls->padding) - ((char *) _main_tls))};
#endif /*_CYGTLS_H*/
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index e512f35..57a26ac 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -577,7 +577,6 @@ dll_crt0_0 ()
char zeros[sizeof (child_proc_info->zero)] = {0};
static NO_COPY STARTUPINFO si;
- int mypid = 0;
_my_tls.stackptr = NULL;
@@ -591,8 +590,12 @@ dll_crt0_0 ()
DuplicateHandle (hMainProc, GetCurrentThread (), hMainProc,
&hMainThread, 0, false, DUPLICATE_SAME_ACCESS);
+ (void) SetErrorMode (SEM_FAILCRITICALERRORS);
+
GetStartupInfo (&si);
child_proc_info = (child_info *) si.lpReserved2;
+
+ int mypid = 0;
if (si.cbReserved2 < EXEC_MAGIC_SIZE || !child_proc_info
|| memcmp (child_proc_info->zero, zeros,
sizeof (child_proc_info->zero)) != 0)
@@ -641,6 +644,7 @@ dll_crt0_0 ()
device::init ();
winpids::init ();
do_global_ctors (&__CTOR_LIST__, 1);
+ cygthread::init ();
if (!child_proc_info)
memory_init ();
@@ -696,6 +700,13 @@ dll_crt0_0 ()
}
_threadinfo::init ();
+
+ /* Initialize events */
+ events_init ();
+
+ /* Init global well known SID objects */
+ cygsid::init ();
+ cygheap->cwd.init ();
}
/* Take over from libc's crt0.o and start the application. Note the
@@ -710,11 +721,12 @@ dll_crt0_1 (char *)
/* FIXME: Verify forked children get their exception handler set up ok. */
exception_list cygwin_except_entry;
- /* Initialize SIGSEGV handling, etc. */
- init_exceptions (&cygwin_except_entry);
check_sanity_and_sync (user_data);
malloc_init ();
+ /* Initialize SIGSEGV handling, etc. */
+ init_exceptions (&cygwin_except_entry);
+
/* Nasty static stuff needed by newlib -- point to a local copy of
the reent stuff.
Note: this MUST be done here (before the forkee code) as the
@@ -725,7 +737,6 @@ dll_crt0_1 (char *)
user_data->threadinterface->Init ();
ProtectHandle (hMainProc);
ProtectHandle (hMainThread);
- cygthread::init ();
/* Initialize pthread mainthread when not forked and it is safe to call new,
otherwise it is reinitalized in fixup_after_fork */
@@ -745,12 +756,6 @@ dll_crt0_1 (char *)
cygheap->fdtab.vfork_child_fixup ();
- (void) SetErrorMode (SEM_FAILCRITICALERRORS);
-
- /* Initialize events. */
- events_init ();
-
- cygheap->cwd.init ();
main_vfork = vfork_storage.create ();
cygbench ("pre-forkee");
@@ -779,9 +784,6 @@ dll_crt0_1 (char *)
}
#endif
- /* Init global well known SID objects */
- cygsid::init ();
-
/* Initialize our process table entry. */
pinfo_init (envp, envc);
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index 19de60e..2f10c2a 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -28,9 +28,9 @@ class dtable
static const int initial_archetype_size = 8;
int first_fd_for_open;
int cnt_need_fixup_before;
- void lock () {/*EnterCriticalSection (&lock_cs); */spf ("%u locked, tid %u\n", GetCurrentProcessId (), GetCurrentThreadId ());}
- void unlock () {/*LeaveCriticalSection (&lock_cs);*/ spf ("%u ulocked, tid %u\n", GetCurrentProcessId (), GetCurrentThreadId ());}
- void init_lock () {/*InitializeCriticalSection (&lock_cs); */spf ("%u initialized, tid %u\n", GetCurrentProcessId (), GetCurrentThreadId ());}
+ void lock () {EnterCriticalSection (&lock_cs); spf ("%u locked, tid %u\n", GetCurrentProcessId (), GetCurrentThreadId ());}
+ void unlock () {LeaveCriticalSection (&lock_cs); spf ("%u ulocked, tid %u\n", GetCurrentProcessId (), GetCurrentThreadId ());}
+ void init_lock () {InitializeCriticalSection (&lock_cs); spf ("%u initialized, tid %u\n", GetCurrentProcessId (), GetCurrentThreadId ());}
public:
size_t size;
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index dab839f..e30d8fd2 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -316,8 +316,6 @@ cygwin_stackdump ()
#define TIME_TO_WAIT_FOR_DEBUGGER 10000
-int keep_looping = 1;
-
extern "C" int
try_to_debug (bool waitloop)
{
@@ -617,7 +615,7 @@ sig_handle_tty_stop (int sig)
}
}
-int
+bool
interruptible (DWORD pc)
{
int res;
@@ -635,11 +633,11 @@ interruptible (DWORD pc)
GetThreadContext. These resolve to a strange allocation base.
These should *never* be treated as interruptible. */
if (!h || m.State != MEM_COMMIT)
- res = 0;
+ res = false;
else if (h == user_data->hmodule)
- res = 1;
+ res = true;
else if (!GetModuleFileName (h, checkdir, windows_system_directory_length + 2))
- res = 0;
+ res = false;
else
res = !strncasematch (windows_system_directory, checkdir,
windows_system_directory_length);
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index 5ca5294..6b3de8f 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -22,15 +22,15 @@ DWORD tls_func;
HANDLE sync_startup;
-#define OLDFUNC_OFFSET -3
+#define OLDFUNC_OFFSET -1
static void WINAPI
threadfunc_fe (VOID *arg)
{
- void *threadfunc = (void *) TlsGetValue (tls_func);
- TlsFree (tls_func);
- // _threadinfo::call ((DWORD (*) (void *, void *)) (((char **) _tlsbase)[OLDFUNC_OFFSET]));
- _threadinfo::call ((DWORD (*) (void *, void *)) (threadfunc), arg);
+ _threadinfo::call ((DWORD (*) (void *, void *)) (((char **) _tlsbase)[OLDFUNC_OFFSET]), arg);
+ // void *threadfunc = (void *) TlsGetValue (tls_func);
+ // TlsFree (tls_func);
+ // _threadinfo::call ((DWORD (*) (void *, void *)) (threadfunc), arg);
}
static DWORD WINAPI
@@ -61,20 +61,20 @@ munge_threadfunc (HANDLE cygwin_hmodule)
foundit:
char *threadfunc = ebp[threadfunc_ix];
- if (0 & (((DWORD) threadfunc & 0x80000000) == 0x80000000 || threadfunc == (char *) calibration_thread))
- /*nothing*/;
+ if (threadfunc == (char *) calibration_thread)
+ /* no need for the overhead */;
else
{
ebp[threadfunc_ix] = (char *) threadfunc_fe;
- // ((char **) _tlsbase)[OLDFUNC_OFFSET] = threadfunc;
- TlsSetValue (tls_func, (void *) threadfunc);
+ ((char **) _tlsbase)[OLDFUNC_OFFSET] = threadfunc;
+ // TlsSetValue (tls_func, (void *) threadfunc);
}
}
void
prime_threads ()
{
- tls_func = TlsAlloc ();
+ // tls_func = TlsAlloc ();
if (!threadfunc_ix)
{
DWORD id;
@@ -93,8 +93,8 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
case DLL_PROCESS_ATTACH:
dynamically_loaded = (static_load == NULL);
// __cygwin_user_data.impure_ptr = &_my_tls.local_clib;
- prime_threads ();
dll_crt0_0 ();
+ prime_threads ();
// small_printf ("%u, %p, %p\n", cygwin_pid (GetCurrentProcessId ()), _tlstop, _tlsbase);
break;
case DLL_PROCESS_DETACH:
diff --git a/winsup/cygwin/select.h b/winsup/cygwin/select.h
index 30b5996..d38e19c 100644
--- a/winsup/cygwin/select.h
+++ b/winsup/cygwin/select.h
@@ -1,6 +1,6 @@
/* select.h
- Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2004 Red Hat, Inc.
This file is part of Cygwin.
@@ -52,5 +52,4 @@ extern "C" int PASCAL win32_select(int, fd_set*, fd_set*, fd_set*, const struct
* type coercion need to appease confused prototypes
*/
#define WINSOCK_SELECT(nfd, rd, wr, ex, timeo) \
- win32_select (nfd, (fd_set *)rd, (fd_set *)wr, (fd_set *)ex, timeo)
-
+ win32_select (nfd, (fd_set *) rd, (fd_set *) wr, (fd_set *) ex, timeo)
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 79912b9..e143a82 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -1115,6 +1115,8 @@ wait_sig (VOID *self)
sigpacket pack;
if (!ReadFile (readsig, &pack, sizeof (pack), &nb, NULL))
break;
+ if (myself->sendsig == INVALID_HANDLE_VALUE)
+ break;
if (nb != sizeof (pack))
{
diff --git a/winsup/cygwin/tlsoffsets.h b/winsup/cygwin/tlsoffsets.h
index c61bad9..6aeea68 100644
--- a/winsup/cygwin/tlsoffsets.h
+++ b/winsup/cygwin/tlsoffsets.h
@@ -1,46 +1,46 @@
//;# autogenerated: Do not edit.
-//; $tls::func = -5100;
-//; $tls::saved_errno = -5096;
-//; $tls::sa_flags = -5092;
-//; $tls::oldmask = -5088;
-//; $tls::newmask = -5084;
-//; $tls::event = -5080;
-//; $tls::errno_addr = -5076;
-//; $tls::initialized = -5072;
-//; $tls::sigmask = -5068;
-//; $tls::sigwait_mask = -5064;
-//; $tls::sigwait_info = -5060;
-//; $tls::infodata = -5056;
-//; $tls::tid = -4532;
-//; $tls::local_clib = -4528;
-//; $tls::locals = -3600;
-//; $tls::prev = -2064;
-//; $tls::next = -2060;
-//; $tls::stackptr = -2056;
-//; $tls::sig = -2052;
-//; $tls::stack = -2048;
-//; $tls::padding = -1024;
+//; $tls::func = -4076;
+//; $tls::saved_errno = -4072;
+//; $tls::sa_flags = -4068;
+//; $tls::oldmask = -4064;
+//; $tls::newmask = -4060;
+//; $tls::event = -4056;
+//; $tls::errno_addr = -4052;
+//; $tls::initialized = -4048;
+//; $tls::sigmask = -4044;
+//; $tls::sigwait_mask = -4040;
+//; $tls::sigwait_info = -4036;
+//; $tls::infodata = -4032;
+//; $tls::tid = -3508;
+//; $tls::local_clib = -3504;
+//; $tls::locals = -2576;
+//; $tls::prev = -1040;
+//; $tls::next = -1036;
+//; $tls::stackptr = -1032;
+//; $tls::sig = -1028;
+//; $tls::stack = -1024;
+//; $tls::padding = 0;
//; __DATA__
-#define tls_func (-5100)
-#define tls_saved_errno (-5096)
-#define tls_sa_flags (-5092)
-#define tls_oldmask (-5088)
-#define tls_newmask (-5084)
-#define tls_event (-5080)
-#define tls_errno_addr (-5076)
-#define tls_initialized (-5072)
-#define tls_sigmask (-5068)
-#define tls_sigwait_mask (-5064)
-#define tls_sigwait_info (-5060)
-#define tls_infodata (-5056)
-#define tls_tid (-4532)
-#define tls_local_clib (-4528)
-#define tls_locals (-3600)
-#define tls_prev (-2064)
-#define tls_next (-2060)
-#define tls_stackptr (-2056)
-#define tls_sig (-2052)
-#define tls_stack (-2048)
-#define tls_padding (-1024)
+#define tls_func (-4076)
+#define tls_saved_errno (-4072)
+#define tls_sa_flags (-4068)
+#define tls_oldmask (-4064)
+#define tls_newmask (-4060)
+#define tls_event (-4056)
+#define tls_errno_addr (-4052)
+#define tls_initialized (-4048)
+#define tls_sigmask (-4044)
+#define tls_sigwait_mask (-4040)
+#define tls_sigwait_info (-4036)
+#define tls_infodata (-4032)
+#define tls_tid (-3508)
+#define tls_local_clib (-3504)
+#define tls_locals (-2576)
+#define tls_prev (-1040)
+#define tls_next (-1036)
+#define tls_stackptr (-1032)
+#define tls_sig (-1028)
+#define tls_stack (-1024)
+#define tls_padding (0)