* cygwait.h (LARGE_NULL): Define.

(cancelable_wait): Define variant which accepts DWORD time argument.
(cygwait): Use cancelable_wait with DWORD argument.
(cygwait): Use cancelable_wait with DWORD argument and cw_sig_eintr for
timeout-only case.
* exceptions.cc (handle_sigsuspend): Use LARGE_NULL as second argument to
distinguish between cancelable_wait variants.
* thread.cc (pthread_mutex::lock): Ditto.
(pthread::join): Ditto.
(semaphore::_timedwait): Ditto.
* thread.h (fast_mutex::lock): Ditto.
* wait.cc (wait4): Ditto.
This commit is contained in:
Christopher Faylor 2012-06-19 00:52:59 +00:00
parent 2addde8cb1
commit 978441cc0e
6 changed files with 31 additions and 9 deletions

View File

@ -1,3 +1,18 @@
2012-06-18 Christopher Faylor <me.cygwin2012@cgf.cx>
* cygwait.h (LARGE_NULL): Define.
(cancelable_wait): Define variant which accepts DWORD time argument.
(cygwait): Use cancelable_wait with DWORD argument.
(cygwait): Use cancelable_wait with DWORD argument and cw_sig_eintr for
timeout-only case.
* exceptions.cc (handle_sigsuspend): Use LARGE_NULL as second argument
to distinguish between cancelable_wait variants.
* thread.cc (pthread_mutex::lock): Ditto.
(pthread::join): Ditto.
(semaphore::_timedwait): Ditto.
* thread.h (fast_mutex::lock): Ditto.
* wait.cc (wait4): Ditto.
2012-06-18 Christopher Faylor <me.cygwin2012@cgf.cx>
* cygwait.cc (cancelable_wait): Mimic old cygwait behavior more closely

View File

@ -22,6 +22,7 @@ enum cw_wait_mask
cw_sig_eintr = 0x0008
};
#define LARGE_NULL ((PLARGE_INTEGER) NULL)
const unsigned cw_std_mask = cw_cancel | cw_cancel_self | cw_sig;
DWORD cancelable_wait (HANDLE, PLARGE_INTEGER timeout = NULL,
@ -29,7 +30,7 @@ DWORD cancelable_wait (HANDLE, PLARGE_INTEGER timeout = NULL,
__attribute__ ((regparm (3)));
static inline DWORD __attribute__ ((always_inline))
cygwait (HANDLE h, DWORD howlong = INFINITE)
cancelable_wait (HANDLE h, DWORD howlong, unsigned mask)
{
PLARGE_INTEGER pli_howlong;
LARGE_INTEGER li_howlong;
@ -40,11 +41,17 @@ cygwait (HANDLE h, DWORD howlong = INFINITE)
li_howlong.QuadPart = 10000ULL * howlong;
pli_howlong = &li_howlong;
}
return cancelable_wait (h, pli_howlong, cw_cancel | cw_sig);
return cancelable_wait (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);
}
static inline DWORD __attribute__ ((always_inline))
cygwait (DWORD howlong)
{
return cygwait ((HANDLE) NULL, howlong);
return cancelable_wait (NULL, howlong, cw_cancel | cw_sig_eintr);
}

View File

@ -715,7 +715,7 @@ handle_sigsuspend (sigset_t tempmask)
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
pthread_testcancel ();
cancelable_wait (signal_arrived, NULL, cw_cancel | cw_cancel_self);
cancelable_wait (signal_arrived, LARGE_NULL, cw_cancel | cw_cancel_self);
set_sig_errno (EINTR); // Per POSIX

View File

@ -1744,7 +1744,7 @@ pthread_mutex::lock ()
|| !pthread::equal (owner, self))
{
/* FIXME: no cancel? */
cancelable_wait (win32_obj_id, NULL, cw_sig);
cancelable_wait (win32_obj_id, LARGE_NULL, cw_sig);
set_owner (self);
}
else
@ -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, NULL, cw_sig | cw_cancel))
switch (cancelable_wait ((*thread)->win32_obj_id, LARGE_NULL, cw_sig | cw_cancel))
{
case WAIT_OBJECT_0:
if (return_val)
@ -3501,7 +3501,7 @@ semaphore::_timedwait (const struct timespec *abstime)
int
semaphore::_wait ()
{
switch (cancelable_wait (win32_obj_id, NULL, cw_cancel | cw_cancel_self | cw_sig_eintr))
switch (cancelable_wait (win32_obj_id, LARGE_NULL, cw_cancel | cw_cancel_self | cw_sig_eintr))
{
case WAIT_OBJECT_0:
currentvalue--;

View File

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

View File

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