Cygwin: debugging: convert muto to SRWLOCK

this avoids having to call debug_init, because the SRWLOCK
is statically initialized.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2022-08-22 14:38:49 +02:00
parent d6c50e630a
commit 48a210a457
2 changed files with 4 additions and 23 deletions

View File

@ -854,10 +854,6 @@ dll_crt0_1 (void *)
strace.microseconds ();
#endif
/* Initialize debug muto, if DLL is built with --enable-debugging.
Need to do this before any helper threads start. */
debug_init ();
cygbench ("pre-forkee");
if (in_forkee)
{

View File

@ -22,30 +22,16 @@ details. */
class lock_debug
{
static muto locker;
static NO_COPY SRWLOCK lock;
public:
lock_debug ()
{
locker.acquire (INFINITE);
}
void unlock ()
{
locker.release ();
}
~lock_debug () {unlock ();}
friend void debug_init ();
lock_debug () { AcquireSRWLockExclusive (&lock); }
~lock_debug () { ReleaseSRWLockExclusive (&lock); }
};
muto NO_COPY lock_debug::locker;
SRWLOCK NO_COPY lock_debug::lock = SRWLOCK_INIT;
static bool mark_closed (const char *, int, HANDLE, const char *, bool);
void
debug_init ()
{
lock_debug::locker.init ("debug_lock");
}
/* Find a registered handle in the linked list of handles. */
static handle_list *
find_handle (HANDLE h)
@ -138,7 +124,6 @@ add_handle (const char *func, int ln, HANDLE h, const char *name, bool inh)
if ((hl = newh ()) == NULL)
{
here.unlock ();
debug_printf ("couldn't allocate memory for %s(%d): %s(%p)",
func, ln, name, h);
return;