* exceptions.cc (ctrl_c_handler): Always send signal to process if it has no
tty.
This commit is contained in:
parent
8b3bcfbab9
commit
17743fbc49
|
@ -1,3 +1,8 @@
|
||||||
|
Fri May 4 16:37:30 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* exceptions.cc (ctrl_c_handler): Always send signal to process if it
|
||||||
|
has no tty.
|
||||||
|
|
||||||
2001-05-04 Egor Duda <deo@logos-m.ru>
|
2001-05-04 Egor Duda <deo@logos-m.ru>
|
||||||
|
|
||||||
* fhandler_socket.cc (set_connect_secret): Use /dev/urandom to
|
* fhandler_socket.cc (set_connect_secret): Use /dev/urandom to
|
||||||
|
|
|
@ -70,9 +70,9 @@ std_dll_init (HANDLE &dll_handle, const char *dll_name, LONG &here)
|
||||||
{
|
{
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
|
||||||
while (InterlockedIncrement (&here))
|
while (ilockincr (&here))
|
||||||
{
|
{
|
||||||
InterlockedDecrement (&here);
|
ilockdecr (&here);
|
||||||
Sleep (0);
|
Sleep (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ std_dll_init (HANDLE &dll_handle, const char *dll_name, LONG &here)
|
||||||
else
|
else
|
||||||
api_fatal ("could not load %s, %E", dll_name);
|
api_fatal ("could not load %s, %E", dll_name);
|
||||||
|
|
||||||
InterlockedDecrement (&here);
|
ilockdecr (&here);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fhandler.h>
|
#include <fhandler.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -87,7 +87,7 @@ thread_stub (VOID *arg)
|
||||||
exception_list except_entry;
|
exception_list except_entry;
|
||||||
|
|
||||||
/* Give up our slot in the start_buf array */
|
/* Give up our slot in the start_buf array */
|
||||||
(void) InterlockedExchange (&((thread_start *) arg)->notavail, 0);
|
(void) ilockexch (&((thread_start *) arg)->notavail, 0);
|
||||||
|
|
||||||
/* Initialize this thread's ability to respond to things like
|
/* Initialize this thread's ability to respond to things like
|
||||||
SIGSEGV or SIGFPE. */
|
SIGSEGV or SIGFPE. */
|
||||||
|
@ -112,7 +112,7 @@ makethread (LPTHREAD_START_ROUTINE start, LPVOID param, DWORD flags,
|
||||||
{
|
{
|
||||||
/* Search the start_buf array for an empty slot to use */
|
/* Search the start_buf array for an empty slot to use */
|
||||||
for (info = start_buf; info < start_buf + NTHREADS; info++)
|
for (info = start_buf; info < start_buf + NTHREADS; info++)
|
||||||
if (!InterlockedExchange (&info->notavail, 1))
|
if (!ilockexch (&info->notavail, 1))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Should never hit here, but be defensive anyway. */
|
/* Should never hit here, but be defensive anyway. */
|
||||||
|
|
|
@ -114,7 +114,7 @@ getwinenv (const char *env, const char *in_posix)
|
||||||
if (!cur_environ () || !(val = in_posix ?: getenv(we->name)))
|
if (!cur_environ () || !(val = in_posix ?: getenv(we->name)))
|
||||||
debug_printf ("can't set native for %s since no environ yet",
|
debug_printf ("can't set native for %s since no environ yet",
|
||||||
we->name);
|
we->name);
|
||||||
else if (!envcache || !we->posix || strcmp (val, we->posix))
|
else if (!envcache || !we->posix || strcmp (val, we->posix) != 0)
|
||||||
we->add_cache (val);
|
we->add_cache (val);
|
||||||
return we;
|
return we;
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,11 +632,11 @@ bool
|
||||||
sigthread::get_winapi_lock (int test)
|
sigthread::get_winapi_lock (int test)
|
||||||
{
|
{
|
||||||
if (test)
|
if (test)
|
||||||
return !InterlockedExchange (&winapi_lock, 1);
|
return !ilockexch (&winapi_lock, 1);
|
||||||
|
|
||||||
/* Need to do a busy loop because we can't block or a potential SuspendThread
|
/* Need to do a busy loop because we can't block or a potential SuspendThread
|
||||||
will hang. */
|
will hang. */
|
||||||
while (InterlockedExchange (&winapi_lock, 1))
|
while (ilockexch (&winapi_lock, 1))
|
||||||
Sleep (1);
|
Sleep (1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -645,7 +645,7 @@ void
|
||||||
sigthread::release_winapi_lock ()
|
sigthread::release_winapi_lock ()
|
||||||
{
|
{
|
||||||
/* Assumes that we have the lock. */
|
/* Assumes that we have the lock. */
|
||||||
InterlockedExchange (&winapi_lock, 0);
|
ilockexch (&winapi_lock, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __stdcall interrupt_setup (int sig, void *handler, DWORD retaddr,
|
static void __stdcall interrupt_setup (int sig, void *handler, DWORD retaddr,
|
||||||
|
@ -892,8 +892,8 @@ ctrl_c_handler (DWORD type)
|
||||||
tty_min *t = cygwin_shared->tty.get_tty (myself->ctty);
|
tty_min *t = cygwin_shared->tty.get_tty (myself->ctty);
|
||||||
/* Ignore this if we're not the process group lead since it should be handled
|
/* Ignore this if we're not the process group lead since it should be handled
|
||||||
*by* the process group leader. */
|
*by* the process group leader. */
|
||||||
if (!t->getpgid () || t->getpgid () != myself->pid ||
|
if (t->getpgid () && (t->getpgid () != myself->pid ||
|
||||||
(GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP)
|
(GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
/* Otherwise we just send a SIGINT to the process group and return TRUE (to indicate
|
/* Otherwise we just send a SIGINT to the process group and return TRUE (to indicate
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
/* CYGNUS LOCAL */
|
/* CYGNUS LOCAL */
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
|
#include <string.h>
|
||||||
#define lint
|
#define lint
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#define USG_COMPAT
|
#define USG_COMPAT
|
||||||
|
|
||||||
|
|
|
@ -1931,9 +1931,9 @@ wsock_init ()
|
||||||
static LONG NO_COPY here = -1L;
|
static LONG NO_COPY here = -1L;
|
||||||
static int NO_COPY wsock_started = 0;
|
static int NO_COPY wsock_started = 0;
|
||||||
|
|
||||||
while (InterlockedIncrement (&here))
|
while (ilockincr (&here))
|
||||||
{
|
{
|
||||||
InterlockedDecrement (&here);
|
ilockdecr (&here);
|
||||||
Sleep (0);
|
Sleep (0);
|
||||||
}
|
}
|
||||||
if (!wsock_started && (wsock32_handle || ws2_32_handle))
|
if (!wsock_started && (wsock32_handle || ws2_32_handle))
|
||||||
|
@ -1960,6 +1960,6 @@ wsock_init ()
|
||||||
wsock_started = 1;
|
wsock_started = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InterlockedDecrement (&here);
|
ilockdecr (&here);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2837,17 +2837,13 @@ hash_path_name (unsigned long hash, const char *name)
|
||||||
if (name[1] == ':')
|
if (name[1] == ':')
|
||||||
{
|
{
|
||||||
char *nn, *newname = (char *) alloca (strlen (name) + 2);
|
char *nn, *newname = (char *) alloca (strlen (name) + 2);
|
||||||
nn = strncpy (newname, name, 2);
|
nn = newname;
|
||||||
if (isupper (*nn))
|
*nn = isupper (*name) ? cyg_tolower (*name) : *name;
|
||||||
*newname = cyg_tolower (*nn);
|
*++nn = ':';
|
||||||
*(nn += 2) = '\0';
|
|
||||||
name += 2;
|
name += 2;
|
||||||
if (*name != '\\')
|
if (*name != '\\')
|
||||||
{
|
*++nn = '\\';
|
||||||
*nn = '\\';
|
strcpy (++nn, name);
|
||||||
*++nn = '\0';
|
|
||||||
}
|
|
||||||
strcpy (nn, name);
|
|
||||||
name = newname;
|
name = newname;
|
||||||
goto hashit;
|
goto hashit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ enum
|
||||||
__SIGFLUSH = -2,
|
__SIGFLUSH = -2,
|
||||||
__SIGSTRACE = -1,
|
__SIGSTRACE = -1,
|
||||||
__SIGUNUSED = 0,
|
__SIGUNUSED = 0,
|
||||||
__SIGOFFSET = 3
|
__SIGOFFSET = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PSIZE 63
|
#define PSIZE 63
|
||||||
|
|
|
@ -39,9 +39,9 @@
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include "regexp.h"
|
#include "regexp.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include "regmagic.h"
|
#include "regmagic.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -10,8 +10,9 @@ This software is a copyrighted work licensed under the terms of the
|
||||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
#include "winsup.h"
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
#include "winsup.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
|
@ -473,7 +473,7 @@ proc_terminate (void)
|
||||||
void __stdcall
|
void __stdcall
|
||||||
sig_clear (int sig)
|
sig_clear (int sig)
|
||||||
{
|
{
|
||||||
(void) InterlockedExchange (myself->getsigtodo (sig), 0L);
|
(void) ilockexch (myself->getsigtodo (sig), 0L);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,7 +696,7 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
|
||||||
|
|
||||||
/* Increment the sigtodo array to signify which signal to assert.
|
/* Increment the sigtodo array to signify which signal to assert.
|
||||||
*/
|
*/
|
||||||
(void) InterlockedIncrement (p->getsigtodo (sig));
|
(void) ilockincr (p->getsigtodo (sig));
|
||||||
|
|
||||||
/* Notify the process that a signal has arrived.
|
/* Notify the process that a signal has arrived.
|
||||||
*/
|
*/
|
||||||
|
@ -783,7 +783,7 @@ out:
|
||||||
void __stdcall
|
void __stdcall
|
||||||
sig_set_pending (int sig)
|
sig_set_pending (int sig)
|
||||||
{
|
{
|
||||||
(void) InterlockedIncrement (myself->getsigtodo (sig));
|
(void) ilockincr (myself->getsigtodo (sig));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1137,7 +1137,7 @@ wait_sig (VOID *)
|
||||||
int dispatched_sigchld = 0;
|
int dispatched_sigchld = 0;
|
||||||
for (int sig = -__SIGOFFSET; sig < NSIG; sig++)
|
for (int sig = -__SIGOFFSET; sig < NSIG; sig++)
|
||||||
{
|
{
|
||||||
while (InterlockedDecrement (myself->getsigtodo (sig)) >= 0)
|
while (ilockdecr (myself->getsigtodo (sig)) >= 0)
|
||||||
{
|
{
|
||||||
if (sig == SIGCHLD)
|
if (sig == SIGCHLD)
|
||||||
saw_sigchld = 1;
|
saw_sigchld = 1;
|
||||||
|
@ -1171,14 +1171,14 @@ wait_sig (VOID *)
|
||||||
dispatched_sigchld = 1;
|
dispatched_sigchld = 1;
|
||||||
/* Need to decrement again to offset increment below since
|
/* Need to decrement again to offset increment below since
|
||||||
we really do want to decrement in this case. */
|
we really do want to decrement in this case. */
|
||||||
InterlockedDecrement (myself->getsigtodo (sig));
|
ilockdecr (myself->getsigtodo (sig));
|
||||||
goto nextsig; /* FIXME: shouldn't this allow the loop to continue? */
|
goto nextsig; /* FIXME: shouldn't this allow the loop to continue? */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nextsig:
|
nextsig:
|
||||||
/* Decremented too far. */
|
/* Decremented too far. */
|
||||||
if (InterlockedIncrement (myself->getsigtodo (sig)) > 0)
|
if (ilockincr (myself->getsigtodo (sig)) > 0)
|
||||||
saw_pending_signals = 1;
|
saw_pending_signals = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ details. */
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
int __small_sprintf (char *dst, const char *fmt,...);
|
int __small_sprintf (char *dst, const char *fmt,...);
|
||||||
|
|
|
@ -58,7 +58,7 @@ muto::~muto ()
|
||||||
be handled correctly.
|
be handled correctly.
|
||||||
|
|
||||||
Note: The goal here is to minimize, as much as possible, calls to the
|
Note: The goal here is to minimize, as much as possible, calls to the
|
||||||
OS. Hence the use of InterlockedIncrement, etc., rather than (much) more
|
OS. Hence the use of ilockincr, etc., rather than (much) more
|
||||||
expensive OS mutexes. */
|
expensive OS mutexes. */
|
||||||
int
|
int
|
||||||
muto::acquire (DWORD ms)
|
muto::acquire (DWORD ms)
|
||||||
|
@ -69,7 +69,7 @@ muto::acquire (DWORD ms)
|
||||||
{
|
{
|
||||||
/* Increment the waiters part of the class. Need to do this first to
|
/* Increment the waiters part of the class. Need to do this first to
|
||||||
avoid potential races. */
|
avoid potential races. */
|
||||||
LONG was_waiting = InterlockedIncrement (&waiters);
|
LONG was_waiting = ilockincr (&waiters);
|
||||||
|
|
||||||
/* This is deceptively simple. Basically, it allows multiple attempts to
|
/* This is deceptively simple. Basically, it allows multiple attempts to
|
||||||
lock the same muto to succeed without attempting to manipulate sync.
|
lock the same muto to succeed without attempting to manipulate sync.
|
||||||
|
@ -82,7 +82,7 @@ muto::acquire (DWORD ms)
|
||||||
case, it is possible for a thread which is going to wait for bruteforce
|
case, it is possible for a thread which is going to wait for bruteforce
|
||||||
to wake up immediately. It will then attempt to grab sync but will fail
|
to wake up immediately. It will then attempt to grab sync but will fail
|
||||||
and go back to waiting. */
|
and go back to waiting. */
|
||||||
while (tid != this_tid && (was_waiting || InterlockedExchange (&sync, 1) != 0))
|
while (tid != this_tid && (was_waiting || ilockexch (&sync, 1) != 0))
|
||||||
{
|
{
|
||||||
switch (WaitForSingleObject (bruteforce, ms))
|
switch (WaitForSingleObject (bruteforce, ms))
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ muto::acquire (DWORD ms)
|
||||||
goto gotit;
|
goto gotit;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
InterlockedDecrement (&waiters);
|
ilockdecr (&waiters);
|
||||||
return 0; /* failed. */
|
return 0; /* failed. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,11 +117,11 @@ muto::release ()
|
||||||
if (!--visits)
|
if (!--visits)
|
||||||
{
|
{
|
||||||
tid = 0; /* We were the last unlocker. */
|
tid = 0; /* We were the last unlocker. */
|
||||||
(void) InterlockedExchange (&sync, 0); /* Reset trigger. */
|
(void) ilockexch (&sync, 0); /* Reset trigger. */
|
||||||
/* This thread had incremented waiters but had never decremented it.
|
/* This thread had incremented waiters but had never decremented it.
|
||||||
Decrement it now. If it is >= 0 then there are possibly other
|
Decrement it now. If it is >= 0 then there are possibly other
|
||||||
threads waiting for the lock, so trigger bruteforce. */
|
threads waiting for the lock, so trigger bruteforce. */
|
||||||
if (InterlockedDecrement (&waiters) >= 0)
|
if (ilockdecr (&waiters) >= 0)
|
||||||
(void) SetEvent (bruteforce); /* Wake up one of the waiting threads */
|
(void) SetEvent (bruteforce); /* Wake up one of the waiting threads */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ void
|
||||||
muto::reset ()
|
muto::reset ()
|
||||||
{
|
{
|
||||||
visits = sync = tid = 0;
|
visits = sync = tid = 0;
|
||||||
InterlockedExchange (&waiters, -1);
|
ilockexch (&waiters, -1);
|
||||||
if (bruteforce)
|
if (bruteforce)
|
||||||
{
|
{
|
||||||
CloseHandle (bruteforce);
|
CloseHandle (bruteforce);
|
||||||
|
|
|
@ -412,7 +412,7 @@ pthread_cond::BroadCast ()
|
||||||
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return;
|
return;
|
||||||
PulseEvent (win32_obj_id);
|
PulseEvent (win32_obj_id);
|
||||||
while (InterlockedDecrement (&waiting) != 0)
|
while (ilockdecr (&waiting) != 0)
|
||||||
PulseEvent (win32_obj_id);
|
PulseEvent (win32_obj_id);
|
||||||
mutex = NULL;
|
mutex = NULL;
|
||||||
}
|
}
|
||||||
|
@ -798,7 +798,7 @@ __pthread_create (pthread_t * thread, const pthread_attr_t * attr,
|
||||||
*thread = NULL;
|
*thread = NULL;
|
||||||
return EAGAIN;
|
return EAGAIN;
|
||||||
}
|
}
|
||||||
InterlockedIncrement (&MT_INTERFACE->threadcount);
|
ilockincr (&MT_INTERFACE->threadcount);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1073,7 +1073,7 @@ __pthread_testcancel (void)
|
||||||
/*
|
/*
|
||||||
* Races in pthread_atfork:
|
* Races in pthread_atfork:
|
||||||
* We are race safe in that any additions to the lists are made via
|
* We are race safe in that any additions to the lists are made via
|
||||||
* InterlockedExchangePointer.
|
* ilockexch.
|
||||||
* However, if the user application doesn't perform syncronisation of some sort
|
* However, if the user application doesn't perform syncronisation of some sort
|
||||||
* It's not guaranteed that a near simultaneous call to pthread_atfork and fork
|
* It's not guaranteed that a near simultaneous call to pthread_atfork and fork
|
||||||
* will result in the new atfork handlers being calls.
|
* will result in the new atfork handlers being calls.
|
||||||
|
@ -1084,7 +1084,7 @@ __pthread_testcancel (void)
|
||||||
* will result in an indeterminate order for parent and child calls (what gets inserted
|
* will result in an indeterminate order for parent and child calls (what gets inserted
|
||||||
* first isn't guaranteed.)
|
* first isn't guaranteed.)
|
||||||
*
|
*
|
||||||
* There is one potential race... Does the result of InterlockedExchangePointer
|
* There is one potential race... Does the result of ilockexch
|
||||||
* get committed to the return location _before_ any context switches can occur?
|
* get committed to the return location _before_ any context switches can occur?
|
||||||
* If yes, we're safe, if no, we're not.
|
* If yes, we're safe, if no, we're not.
|
||||||
*/
|
*/
|
||||||
|
@ -1123,7 +1123,7 @@ __pthread_atforkchild (void)
|
||||||
|
|
||||||
/* FIXME: implement InterlockExchangePointer and get rid of the silly typecasts below
|
/* FIXME: implement InterlockExchangePointer and get rid of the silly typecasts below
|
||||||
*/
|
*/
|
||||||
#define InterlockedExchangePointer InterlockedExchange
|
/*#define ilockexch ilockExchange */
|
||||||
|
|
||||||
/* Register a set of functions to run before and after fork.
|
/* Register a set of functions to run before and after fork.
|
||||||
* prepare calls are called in LI-FC order.
|
* prepare calls are called in LI-FC order.
|
||||||
|
@ -1165,7 +1165,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
|
||||||
if (prepcb)
|
if (prepcb)
|
||||||
{
|
{
|
||||||
prepcb->cb = prepare;
|
prepcb->cb = prepare;
|
||||||
prepcb->next=(callback *)InterlockedExchangePointer ((LONG *) &MT_INTERFACE->pthread_prepare, (long int) prepcb);
|
prepcb->next=(callback *)ilockexch ((LONG *) &MT_INTERFACE->pthread_prepare, (long int) prepcb);
|
||||||
}
|
}
|
||||||
if (parentcb)
|
if (parentcb)
|
||||||
{
|
{
|
||||||
|
@ -1174,7 +1174,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
|
||||||
while (*t)
|
while (*t)
|
||||||
t = &(*t)->next;
|
t = &(*t)->next;
|
||||||
/* t = pointer to last next in the list */
|
/* t = pointer to last next in the list */
|
||||||
parentcb->next=(callback *)InterlockedExchangePointer ((LONG *) t, (long int) parentcb);
|
parentcb->next=(callback *)ilockexch ((LONG *) t, (long int) parentcb);
|
||||||
}
|
}
|
||||||
if (childcb)
|
if (childcb)
|
||||||
{
|
{
|
||||||
|
@ -1183,7 +1183,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
|
||||||
while (*t)
|
while (*t)
|
||||||
t = &(*t)->next;
|
t = &(*t)->next;
|
||||||
/* t = pointer to last next in the list */
|
/* t = pointer to last next in the list */
|
||||||
childcb->next=(callback *)InterlockedExchangePointer ((LONG *) t, (long int) childcb);
|
childcb->next=(callback *)ilockexch ((LONG *) t, (long int) childcb);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1351,7 +1351,7 @@ __pthread_exit (void *value_ptr)
|
||||||
MT_INTERFACE->destructors.IterateNull ();
|
MT_INTERFACE->destructors.IterateNull ();
|
||||||
|
|
||||||
thread->return_ptr = value_ptr;
|
thread->return_ptr = value_ptr;
|
||||||
if (InterlockedDecrement (&MT_INTERFACE->threadcount) == 0)
|
if (ilockdecr (&MT_INTERFACE->threadcount) == 0)
|
||||||
exit (0);
|
exit (0);
|
||||||
else
|
else
|
||||||
ExitThread (0);
|
ExitThread (0);
|
||||||
|
@ -1626,15 +1626,15 @@ __pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
|
||||||
if ((*cond)->waiting)
|
if ((*cond)->waiting)
|
||||||
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
|
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
InterlockedIncrement (&((*cond)->waiting));
|
ilockincr (&((*cond)->waiting));
|
||||||
|
|
||||||
(*cond)->mutex = (*themutex);
|
(*cond)->mutex = (*themutex);
|
||||||
InterlockedIncrement (&((*themutex)->condwaits));
|
ilockincr (&((*themutex)->condwaits));
|
||||||
rv = (*cond)->TimedWait (abstime->tv_sec * 1000);
|
rv = (*cond)->TimedWait (abstime->tv_sec * 1000);
|
||||||
(*cond)->mutex->Lock ();
|
(*cond)->mutex->Lock ();
|
||||||
if (InterlockedDecrement (&((*cond)->waiting)) == 0)
|
if (ilockdecr (&((*cond)->waiting)) == 0)
|
||||||
(*cond)->mutex = NULL;
|
(*cond)->mutex = NULL;
|
||||||
InterlockedDecrement (&((*themutex)->condwaits));
|
ilockdecr (&((*themutex)->condwaits));
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1657,15 +1657,15 @@ __pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex)
|
||||||
if ((*cond)->waiting)
|
if ((*cond)->waiting)
|
||||||
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
|
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
InterlockedIncrement (&((*cond)->waiting));
|
ilockincr (&((*cond)->waiting));
|
||||||
|
|
||||||
(*cond)->mutex = (*themutex);
|
(*cond)->mutex = (*themutex);
|
||||||
InterlockedIncrement (&((*themutex)->condwaits));
|
ilockincr (&((*themutex)->condwaits));
|
||||||
rv = (*cond)->TimedWait (INFINITE);
|
rv = (*cond)->TimedWait (INFINITE);
|
||||||
(*cond)->mutex->Lock ();
|
(*cond)->mutex->Lock ();
|
||||||
if (InterlockedDecrement (&((*cond)->waiting)) == 0)
|
if (ilockdecr (&((*cond)->waiting)) == 0)
|
||||||
(*cond)->mutex = NULL;
|
(*cond)->mutex = NULL;
|
||||||
InterlockedDecrement (&((*themutex)->condwaits));
|
ilockdecr (&((*themutex)->condwaits));
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ details. */
|
||||||
|
|
||||||
#define __INSIDE_CYGWIN__
|
#define __INSIDE_CYGWIN__
|
||||||
|
|
||||||
|
#include "interlock.h"
|
||||||
|
|
||||||
#define alloca __builtin_alloca
|
#define alloca __builtin_alloca
|
||||||
#define strlen __builtin_strlen
|
#define strlen __builtin_strlen
|
||||||
#define strcmp __builtin_strcmp
|
#define strcmp __builtin_strcmp
|
||||||
|
@ -33,25 +35,6 @@ details. */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/strace.h>
|
#include <sys/strace.h>
|
||||||
|
|
||||||
#undef strchr
|
|
||||||
#define strchr cygwin_strchr
|
|
||||||
extern "C" inline __stdcall char * strchr(const char * s, int c)
|
|
||||||
{
|
|
||||||
register char * __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"movb %%al,%%ah\n"
|
|
||||||
"1:\tmovb (%1),%%al\n\t"
|
|
||||||
"cmpb %%ah,%%al\n\t"
|
|
||||||
"je 2f\n\t"
|
|
||||||
"incl %1\n\t"
|
|
||||||
"testb %%al,%%al\n\t"
|
|
||||||
"jne 1b\n\t"
|
|
||||||
"xorl %1,%1\n"
|
|
||||||
"2:\tmovl %1,%0\n\t"
|
|
||||||
:"=a" (__res), "=r" (s)
|
|
||||||
:"0" (c), "1" (s));
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern char case_folded_lower[];
|
extern char case_folded_lower[];
|
||||||
#define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)])
|
#define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)])
|
||||||
|
|
Loading…
Reference in New Issue