Rename cancelable_wait -> cygwait throughout.

* DevNotes: Add entry cgf-000015.
* cygwait.h (cygwait): Don't allow an optional PLARGE_INTERGER argument.
This commit is contained in:
Christopher Faylor 2012-08-15 19:07:42 +00:00
parent 879f3ad5ee
commit 806e732c01
13 changed files with 36 additions and 25 deletions

View File

@ -1,3 +1,10 @@
2012-08-15 Christopher Faylor <me.cygwin2012@cgf.cx>
Rename cancelable_wait -> cygwait throughout.
* DevNotes: Add entry cgf-000015.
* cygwait.h (cygwait): Don't allow an optional PLARGE_INTERGER
argument.
2012-08-15 Christopher Faylor <me.cygwin2012@cgf.cx>
* cygtls.h (_cygtls::create_signal_arrived): New function.

View File

@ -1,3 +1,7 @@
2012-08-15 cgf-000015
RIP cancelable_wait. Yay.
2012-08-09 cgf-000014
So, apparently I got it somewhat right before wrt signal handling.

View File

@ -24,7 +24,7 @@
LARGE_INTEGER cw_nowait_storage;
DWORD
cancelable_wait (HANDLE object, PLARGE_INTEGER timeout, unsigned mask)
cygwait (HANDLE object, PLARGE_INTEGER timeout, unsigned mask)
{
DWORD res;
DWORD num = 0;

View File

@ -28,12 +28,12 @@ extern LARGE_INTEGER cw_nowait_storage;
const unsigned cw_std_mask = cw_cancel | cw_cancel_self | cw_sig;
DWORD cancelable_wait (HANDLE, PLARGE_INTEGER timeout = NULL,
DWORD cygwait (HANDLE, PLARGE_INTEGER timeout,
unsigned = cw_std_mask)
__attribute__ ((regparm (3)));
extern inline DWORD __attribute__ ((always_inline))
cancelable_wait (HANDLE h, DWORD howlong, unsigned mask)
cygwait (HANDLE h, DWORD howlong, unsigned mask)
{
LARGE_INTEGER li_howlong;
PLARGE_INTEGER pli_howlong;
@ -44,13 +44,13 @@ cancelable_wait (HANDLE h, DWORD howlong, unsigned mask)
li_howlong.QuadPart = -(10000ULL * howlong);
pli_howlong = &li_howlong;
}
return cancelable_wait (h, pli_howlong, mask);
return cygwait (h, pli_howlong, mask);
}
static inline DWORD __attribute__ ((always_inline))
cygwait (HANDLE h, DWORD howlong = INFINITE)
{
return cancelable_wait (h, howlong, cw_cancel | cw_sig);
return cygwait (h, howlong, cw_cancel | cw_sig);
}
static inline DWORD __attribute__ ((always_inline))

View File

@ -708,7 +708,7 @@ handle_sigsuspend (sigset_t tempmask)
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
pthread_testcancel ();
cancelable_wait (NULL, cw_infinite, cw_cancel | cw_cancel_self | cw_sig_eintr);
cygwait (NULL, cw_infinite, cw_cancel | cw_cancel_self | cw_sig_eintr);
set_sig_errno (EINTR); // Per POSIX
@ -739,7 +739,7 @@ sig_handle_tty_stop (int sig)
sigproc_printf ("process %d stopped by signal %d", myself->pid, sig);
/* FIXME! This does nothing to suspend anything other than the main
thread. */
DWORD res = cancelable_wait (NULL, cw_infinite, cw_sig_eintr);
DWORD res = cygwait (NULL, cw_infinite, cw_sig_eintr);
switch (res)
{
case WAIT_SIGNALED:

View File

@ -125,7 +125,7 @@ get_inet_addr (const struct sockaddr *in, int inlen,
some greedy Win32 application. Therefore we should never wait
endlessly without checking for signals and thread cancel event. */
pthread_testcancel ();
if (cancelable_wait (NULL, cw_nowait, cw_sig_eintr) == WAIT_SIGNALED
if (cygwait (NULL, cw_nowait, cw_sig_eintr) == WAIT_SIGNALED
&& !_my_tls.call_signal_handler ())
{
set_errno (EINTR);

View File

@ -1150,7 +1150,7 @@ fhandler_dev_tape::_lock (bool cancelable)
/* O_NONBLOCK is only valid in a read or write call. Only those are
cancelable. */
DWORD timeout = cancelable && is_nonblocking () ? 0 : INFINITE;
switch (cancelable_wait (mt_mtx, timeout, cw_sig | cw_cancel | cw_cancel_self))
switch (cygwait (mt_mtx, timeout, cw_sig | cw_cancel | cw_cancel_self))
{
case WAIT_OBJECT_0:
return true;

View File

@ -281,7 +281,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
goto out;
}
pthread_testcancel ();
if (cancelable_wait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED
if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED
&& !_my_tls.call_signal_handler ())
{
set_errno (EINTR);

View File

@ -119,7 +119,7 @@ ipc_mutex_init (HANDLE *pmtx, const char *name)
static int
ipc_mutex_lock (HANDLE mtx)
{
switch (cancelable_wait (mtx, cw_infinite, cw_sig_eintr | cw_cancel | cw_cancel_self))
switch (cygwait (mtx, cw_infinite, cw_sig_eintr | cw_cancel | cw_cancel_self))
{
case WAIT_OBJECT_0:
case WAIT_ABANDONED_0:

View File

@ -120,7 +120,7 @@ clock_nanosleep (clockid_t clk_id, int flags, const struct timespec *rqtp,
syscall_printf ("clock_nanosleep (%ld.%09ld)", rqtp->tv_sec, rqtp->tv_nsec);
int rc = cancelable_wait (NULL, &timeout, cw_sig_eintr | cw_cancel | cw_cancel_self);
int rc = cygwait (NULL, &timeout, cw_sig_eintr | cw_cancel | cw_cancel_self);
if (rc == WAIT_SIGNALED)
res = EINTR;
@ -580,7 +580,7 @@ sigwaitinfo (const sigset_t *set, siginfo_t *info)
sig_dispatch_pending (true);
int res;
switch (cancelable_wait (NULL, cw_infinite, cw_sig_eintr | cw_cancel | cw_cancel_self))
switch (cygwait (NULL, cw_infinite, cw_sig_eintr | cw_cancel | cw_cancel_self))
{
case WAIT_SIGNALED:
if (!sigismember (set, _my_tls.infodata.si_signo))

View File

@ -585,7 +585,7 @@ pthread::cancel ()
}
mutex.unlock ();
/* See above. For instance, a thread which waits for a semaphore in sem_wait
will call cancelable_wait which in turn calls WFMO. While this WFMO call
will call cygwait which in turn calls WFMO. While this WFMO call
is cancelable by setting the thread's cancel_event object, the OS
apparently refuses to set the thread's context and continues to wait for
the WFMO conditions. This is *not* reflected in the return value of
@ -1228,7 +1228,7 @@ pthread_cond::wait (pthread_mutex_t mutex, PLARGE_INTEGER timeout)
++mutex->condwaits;
mutex->unlock ();
rv = cancelable_wait (sem_wait, timeout, cw_cancel | cw_sig_eintr);
rv = cygwait (sem_wait, timeout, cw_cancel | cw_sig_eintr);
mtx_out.lock ();
@ -1744,7 +1744,7 @@ pthread_mutex::lock ()
|| !pthread::equal (owner, self))
{
/* FIXME: no cancel? */
cancelable_wait (win32_obj_id, cw_infinite, cw_sig);
cygwait (win32_obj_id, cw_infinite, cw_sig);
set_owner (self);
}
else
@ -1885,7 +1885,7 @@ pthread_spinlock::lock ()
LARGE_INTEGER timeout;
timeout.QuadPart = -10000LL;
/* FIXME: no cancel? */
cancelable_wait (win32_obj_id, &timeout, cw_sig);
cygwait (win32_obj_id, &timeout, cw_sig);
}
}
while (result == -1);
@ -2364,7 +2364,7 @@ pthread::join (pthread_t *thread, void **return_val)
(*thread)->attr.joinable = PTHREAD_CREATE_DETACHED;
(*thread)->mutex.unlock ();
switch (cancelable_wait ((*thread)->win32_obj_id, cw_infinite, cw_sig | cw_cancel))
switch (cygwait ((*thread)->win32_obj_id, cw_infinite, cw_sig | cw_cancel))
{
case WAIT_OBJECT_0:
if (return_val)
@ -3476,7 +3476,7 @@ semaphore::_timedwait (const struct timespec *abstime)
timeout.QuadPart = abstime->tv_sec * NSPERSEC
+ (abstime->tv_nsec + 99) / 100 + FACTOR;
switch (cancelable_wait (win32_obj_id, &timeout, cw_cancel | cw_cancel_self | cw_sig_eintr))
switch (cygwait (win32_obj_id, &timeout, cw_cancel | cw_cancel_self | cw_sig_eintr))
{
case WAIT_OBJECT_0:
currentvalue--;
@ -3488,7 +3488,7 @@ semaphore::_timedwait (const struct timespec *abstime)
set_errno (ETIMEDOUT);
return -1;
default:
pthread_printf ("cancelable_wait failed. %E");
pthread_printf ("cygwait failed. %E");
__seterrno ();
return -1;
}
@ -3498,7 +3498,7 @@ semaphore::_timedwait (const struct timespec *abstime)
int
semaphore::_wait ()
{
switch (cancelable_wait (win32_obj_id, cw_infinite, cw_cancel | cw_cancel_self | cw_sig_eintr))
switch (cygwait (win32_obj_id, cw_infinite, cw_cancel | cw_cancel_self | cw_sig_eintr))
{
case WAIT_OBJECT_0:
currentvalue--;
@ -3507,7 +3507,7 @@ semaphore::_wait ()
set_errno (EINTR);
return -1;
default:
pthread_printf ("cancelable_wait failed. %E");
pthread_printf ("cygwait failed. %E");
break;
}
return 0;

View File

@ -60,7 +60,7 @@ public:
void lock ()
{
if (InterlockedIncrement ((long *) &lock_counter) != 1)
cancelable_wait (win32_obj_id, cw_infinite, cw_sig);
cygwait (win32_obj_id, cw_infinite, cw_sig);
}
void unlock ()

View File

@ -80,9 +80,9 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
if ((waitfor = w->ev) == NULL)
goto nochildren;
res = cancelable_wait (waitfor, cw_infinite, cw_cancel | cw_cancel_self);
res = cygwait (waitfor, cw_infinite, cw_cancel | cw_cancel_self);
sigproc_printf ("%d = cancelable_wait (...)", res);
sigproc_printf ("%d = cygwait (...)", res);
if (w->ev == NULL)
{