* dcrt0.cc (dll_crt0_0): Eliminate muto::init call.
* sync.h (locker): New, currently unused class. (muto::init): Eliminate. * sync.cc (muto::init): Ditto. (muto::init): Eliminate critical section lock and instead use name as a guard to prevent against multiple attempts to initialize the same muto. * pinfo.cc (pinfo::init): Set myself procinfo when not execing and pid matches windows pid or cygwin pid.
This commit is contained in:
parent
4534561877
commit
18edcecfbf
@ -1,3 +1,15 @@
|
|||||||
|
2005-03-08 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
* dcrt0.cc (dll_crt0_0): Eliminate muto::init call.
|
||||||
|
* sync.h (locker): New, currently unused class.
|
||||||
|
(muto::init): Eliminate.
|
||||||
|
* sync.cc (muto::init): Ditto.
|
||||||
|
(muto::init): Eliminate critical section lock and instead use name as a
|
||||||
|
guard to prevent against multiple attempts to initialize the same muto.
|
||||||
|
|
||||||
|
* pinfo.cc (pinfo::init): Set myself procinfo when not execing and pid
|
||||||
|
matches windows pid or cygwin pid.
|
||||||
|
|
||||||
2005-03-06 Pavel Tsekov <ptsekov@gmx.net>
|
2005-03-06 Pavel Tsekov <ptsekov@gmx.net>
|
||||||
|
|
||||||
* path.cc (mount_info::read_cygdrive_info_from_registry): Use the user
|
* path.cc (mount_info::read_cygdrive_info_from_registry): Use the user
|
||||||
|
@ -574,7 +574,6 @@ void __stdcall
|
|||||||
dll_crt0_0 ()
|
dll_crt0_0 ()
|
||||||
{
|
{
|
||||||
wincap.init ();
|
wincap.init ();
|
||||||
muto::init ();
|
|
||||||
initial_env ();
|
initial_env ();
|
||||||
|
|
||||||
char zeros[sizeof (child_proc_info->zero)] = {0};
|
char zeros[sizeof (child_proc_info->zero)] = {0};
|
||||||
|
@ -173,7 +173,8 @@ void
|
|||||||
pinfo::init (pid_t n, DWORD flag, HANDLE h0)
|
pinfo::init (pid_t n, DWORD flag, HANDLE h0)
|
||||||
{
|
{
|
||||||
h = NULL;
|
h = NULL;
|
||||||
if (myself && n == myself->pid)
|
if (myself && !(flag & PID_EXECED)
|
||||||
|
&& (n == myself->pid || (DWORD) n == myself->dwProcessId))
|
||||||
{
|
{
|
||||||
procinfo = myself;
|
procinfo = myself;
|
||||||
destroy = 0;
|
destroy = 0;
|
||||||
|
@ -30,12 +30,6 @@ details. */
|
|||||||
DWORD NO_COPY muto::exiting_thread;
|
DWORD NO_COPY muto::exiting_thread;
|
||||||
CRITICAL_SECTION NO_COPY muto::init_lock;
|
CRITICAL_SECTION NO_COPY muto::init_lock;
|
||||||
|
|
||||||
void
|
|
||||||
muto::init ()
|
|
||||||
{
|
|
||||||
InitializeCriticalSection (&init_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
muto::grab ()
|
muto::grab ()
|
||||||
{
|
{
|
||||||
@ -46,23 +40,19 @@ muto::grab ()
|
|||||||
muto *
|
muto *
|
||||||
muto::init (const char *s)
|
muto::init (const char *s)
|
||||||
{
|
{
|
||||||
muto *res = this;
|
char *already_exists = (char *) InterlockedExchangePointer (&name, s);
|
||||||
EnterCriticalSection (&init_lock);
|
if (already_exists)
|
||||||
if (!bruteforce)
|
while (!bruteforce)
|
||||||
|
low_priority_sleep (0);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
waiters = -1;
|
waiters = -1;
|
||||||
bruteforce = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
|
||||||
/* Create event which is used in the fallback case when blocking is necessary */
|
/* Create event which is used in the fallback case when blocking is necessary */
|
||||||
if (bruteforce)
|
bruteforce = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
||||||
name = s;
|
if (!bruteforce)
|
||||||
else
|
api_fatal ("couldn't allocate muto '%s', %E", s);
|
||||||
{
|
|
||||||
DWORD oerr = GetLastError ();
|
|
||||||
SetLastError (oerr);
|
|
||||||
res = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LeaveCriticalSection (&init_lock);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,10 +40,15 @@ public:
|
|||||||
void upforgrabs () {tls = this;} // just set to an invalid address
|
void upforgrabs () {tls = this;} // just set to an invalid address
|
||||||
void grab () __attribute__ ((regparm (1)));
|
void grab () __attribute__ ((regparm (1)));
|
||||||
static void set_exiting_thread () {exiting_thread = GetCurrentThreadId ();}
|
static void set_exiting_thread () {exiting_thread = GetCurrentThreadId ();}
|
||||||
static void init ();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern muto muto_start;
|
class locker
|
||||||
|
{
|
||||||
|
muto *room;
|
||||||
|
public:
|
||||||
|
locker (muto *m) {room = m; room->acquire ();}
|
||||||
|
~locker () {room->release ();}
|
||||||
|
};
|
||||||
|
|
||||||
/* Use a statically allocated buffer as the storage for a muto */
|
/* Use a statically allocated buffer as the storage for a muto */
|
||||||
#define new_muto(__name) \
|
#define new_muto(__name) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user