* exceptions.cc (set_signal_mask): Redefine to not pass by address. Report

calculated mask in debugging output.
* sigproc.h (set_signal_mask): Reflect above change in declaration.
* path.cc (mount_item::build_win32): Take path apart before feeding it to
fnmunge.  Throughout, change use of _reent_winsup()-> to _my_tls.locals.
instead.  Throughout, remove obsolete MT_SAFE/_CYG_THREAD_FAILSAFE
considerations.  Througout, add cygtls.h include.
* Makefile.in (DLL_OFILES): Add cygtls.o.  Add some more objects to the
-fomit-frame-pointer list.
* acconfig.h: Remove obsolete settings.
* config.h.in: Ditto.
* bsdlib.cc: Add cygtls.h include.
* configure.in: Remove --enable-extra-threadsafe-checking.
* configure: Regenerate.
* cygtls.h (_local_storage): New struct renamed from _winsup_t (sic).
(_threadinfo:local_clib): Add new field.
(_threadinfo::locals): Ditto.
(_threadinfo::init_thread): Accept second _reent * argument.
(_threadinfo::call): Define as regparm.
(CYGTLS_PADSIZE): Remove unnecessary slop.
(_getreent): Define as a macro.
* thread.h: Remove _CYG_THREAD_FAILSAFE and MT_SAFE stuff.
(_winsup_t): Move to cygtls.h.
(ResourceLocks::ResourceLocks): Eliminate empty constructor.
(MTinterface::reents): Eliminate.
(MTinterface::thread_self_key): Eliminate.
(MTinterface::MTinterface): Eliminate.
* dcrt0.cc: Include stdio.h for _impure_ptr initialization.
(do_global_ctors): Remove run_ctors_p (sic) considerations.  Don't call atexit
here.
(__main): Initialize destructors for user here.
(dll_crt0_1): Accept a dummy argument.  Don't call init_thread here.  Don't set
_impure_ptr here.  Call do_global_ctors after more things have been
initialized.
(_dll_crt0): Define zeros buffer as max of needed size of CYGTLS_PADSIZE so
that it can be used for two purposes while minimizing stack usage.  Initialize
_impure_ptr specifically, for speed.  Call dll_crt0_1 with buffer argument.
(cygwin_dll_init): Call dll_crt0_1 with dummy argument.
* dtable.cc (dtable::find_unused_handle): Remove call to AssertResourceOwner.
* exceptions.cc: Move _threadinfo stuff to new file.
* cygtls.cc: New file.
* gentls_offsets: Accommodate increasing complexity of cygtls.h.
* hires.h (hires_base::~hires_base): Remove.
* init.cc (dll_entry): Remove setting of reents.
* thread.cc: Remove syslog.h include.
(__getreent): Simplify to use _my_tls.
(_reent_winsup): Delete.
(AssertResourceOwner): Delete.
(MTinterface::Init): Remove setting of _clib and _winsup, with all that
entails.
(MTinterface::fixup_after_fork): Ditto.
(pthread::thread_init_wrapper): Ditto.  Also remove call to
set_tls_self_pointer.
(pthread::set_tls_self_pointer): Eliminate.
(pthread::get_tls_self_pointer): Just return _my_tls.tid;
(__reent_t::init_clib): Eliminate.
* tlsoffsets.h: Regenerate.
This commit is contained in:
Christopher Faylor
2003-12-23 16:26:31 +00:00
parent 1fb9256d7e
commit 29d52c8a27
35 changed files with 513 additions and 744 deletions

View File

@ -36,11 +36,6 @@ static int handle_exceptions (EXCEPTION_RECORD *, void *, CONTEXT *, void *);
extern void sigdelayed ();
};
_threadinfo NO_COPY dummy_thread;
_threadinfo NO_COPY *_last_thread = &dummy_thread;
CRITICAL_SECTION NO_COPY _threadinfo::protect_linked_list;
extern DWORD sigtid;
extern HANDLE hExeced;
@ -129,101 +124,6 @@ init_exceptions (exception_list *el)
init_exception_handler (el);
}
void
_threadinfo::set_state (bool is_exception)
{
initialized = CYGTLS_INITIALIZED + is_exception;
}
void
_threadinfo::reset_exception ()
{
if (initialized == CYGTLS_EXCEPTION)
{
#ifdef DEBUGGING
debug_printf ("resetting stack after an exception stack %p, stackptr %p", stack, stackptr);
#endif
set_state (false);
stackptr--;
}
}
void
_threadinfo::call (DWORD (*func) (void *, void *), void *arg)
{
char buf[CYGTLS_PADSIZE];
_my_tls.call2 (func, arg, buf);
}
void
_threadinfo::call2 (DWORD (*func) (void *, void *), void *arg, void *buf)
{
init_thread (buf);
ExitThread (func (arg, buf));
}
void
_threadinfo::init ()
{
InitializeCriticalSection (&protect_linked_list);
}
void
_threadinfo::init_thread (void *x)
{
if (x)
{
memset (this, 0, sizeof (*this));
stackptr = stack;
}
EnterCriticalSection (&protect_linked_list);
prev = _last_thread;
_last_thread->next = this;
_last_thread = this;
LeaveCriticalSection (&protect_linked_list);
set_state (false);
errno_addr = &errno;
}
void
_threadinfo::remove ()
{
EnterCriticalSection (&protect_linked_list);
if (prev)
{
prev->next = next;
if (next)
next->prev = prev;
if (this == _last_thread)
_last_thread = prev;
prev = next = NULL;
}
LeaveCriticalSection (&protect_linked_list);
}
void
_threadinfo::push (__stack_t addr, bool exception)
{
*stackptr++ = (__stack_t) addr;
set_state (exception);
}
__stack_t
_threadinfo::pop ()
{
#ifdef DEBUGGING
assert (stackptr > stack);
#endif
__stack_t res = *--stackptr;
#ifdef DEBUGGING
*stackptr = 0;
debug_printf ("popped %p, stack %p, stackptr %p", res, stack, stackptr);
#endif
return res;
}
extern "C" void
error_start_init (const char *buf)
{
@ -663,9 +563,9 @@ handle_sigsuspend (sigset_t tempmask)
sig_dispatch_pending ();
sigset_t oldmask = myself->getsigmask (); // Remember for restoration
set_signal_mask (tempmask & ~SIG_NONMASKABLE);// Let signals we're
set_signal_mask (tempmask &= ~SIG_NONMASKABLE, oldmask);// Let signals we're
// interested in through.
sigproc_printf ("old mask %x, new mask %x", oldmask, tempmask);
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
pthread_testcancel ();
pthread::cancelable_wait (signal_arrived, INFINITE);
@ -974,20 +874,24 @@ set_process_mask (sigset_t newmask)
/* Set the signal mask for this process.
Note that some signals are unmaskable, as in UNIX. */
extern "C" void __stdcall
set_signal_mask (sigset_t newmask, sigset_t& oldmask)
set_signal_mask (sigset_t newmask, sigset_t oldmask)
{
mask_sync->acquire (INFINITE);
newmask &= ~SIG_NONMASKABLE;
sigproc_printf ("old mask %p, new mask %p", oldmask, newmask);
sigset_t mask_bits = oldmask & ~newmask;
sigproc_printf ("oldmask %p, newmask %p, mask_bits %p", oldmask, newmask,
mask_bits);
myself->setsigmask (newmask); // Set a new mask
mask_sync->release ();
if (oldmask & ~newmask)
if (mask_bits)
sig_dispatch_pending ();
else
sigproc_printf ("not calling sig_dispatch_pending");
return;
}
extern _threadinfo *_last_thread;
_threadinfo *
_threadinfo::find_tls (int sig)
{