* 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:
parent
2addde8cb1
commit
978441cc0e
|
@ -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>
|
2012-06-18 Christopher Faylor <me.cygwin2012@cgf.cx>
|
||||||
|
|
||||||
* cygwait.cc (cancelable_wait): Mimic old cygwait behavior more closely
|
* cygwait.cc (cancelable_wait): Mimic old cygwait behavior more closely
|
||||||
|
|
|
@ -22,6 +22,7 @@ enum cw_wait_mask
|
||||||
cw_sig_eintr = 0x0008
|
cw_sig_eintr = 0x0008
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define LARGE_NULL ((PLARGE_INTEGER) NULL)
|
||||||
const unsigned cw_std_mask = cw_cancel | cw_cancel_self | cw_sig;
|
const unsigned cw_std_mask = cw_cancel | cw_cancel_self | cw_sig;
|
||||||
|
|
||||||
DWORD cancelable_wait (HANDLE, PLARGE_INTEGER timeout = NULL,
|
DWORD cancelable_wait (HANDLE, PLARGE_INTEGER timeout = NULL,
|
||||||
|
@ -29,7 +30,7 @@ DWORD cancelable_wait (HANDLE, PLARGE_INTEGER timeout = NULL,
|
||||||
__attribute__ ((regparm (3)));
|
__attribute__ ((regparm (3)));
|
||||||
|
|
||||||
static inline DWORD __attribute__ ((always_inline))
|
static inline DWORD __attribute__ ((always_inline))
|
||||||
cygwait (HANDLE h, DWORD howlong = INFINITE)
|
cancelable_wait (HANDLE h, DWORD howlong, unsigned mask)
|
||||||
{
|
{
|
||||||
PLARGE_INTEGER pli_howlong;
|
PLARGE_INTEGER pli_howlong;
|
||||||
LARGE_INTEGER li_howlong;
|
LARGE_INTEGER li_howlong;
|
||||||
|
@ -40,11 +41,17 @@ cygwait (HANDLE h, DWORD howlong = INFINITE)
|
||||||
li_howlong.QuadPart = 10000ULL * howlong;
|
li_howlong.QuadPart = 10000ULL * howlong;
|
||||||
pli_howlong = &li_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))
|
static inline DWORD __attribute__ ((always_inline))
|
||||||
cygwait (DWORD howlong)
|
cygwait (DWORD howlong)
|
||||||
{
|
{
|
||||||
return cygwait ((HANDLE) NULL, howlong);
|
return cancelable_wait (NULL, howlong, cw_cancel | cw_sig_eintr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -715,7 +715,7 @@ handle_sigsuspend (sigset_t tempmask)
|
||||||
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
|
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
|
||||||
|
|
||||||
pthread_testcancel ();
|
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
|
set_sig_errno (EINTR); // Per POSIX
|
||||||
|
|
||||||
|
|
|
@ -1744,7 +1744,7 @@ pthread_mutex::lock ()
|
||||||
|| !pthread::equal (owner, self))
|
|| !pthread::equal (owner, self))
|
||||||
{
|
{
|
||||||
/* FIXME: no cancel? */
|
/* FIXME: no cancel? */
|
||||||
cancelable_wait (win32_obj_id, NULL, cw_sig);
|
cancelable_wait (win32_obj_id, LARGE_NULL, cw_sig);
|
||||||
set_owner (self);
|
set_owner (self);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2364,7 +2364,7 @@ pthread::join (pthread_t *thread, void **return_val)
|
||||||
(*thread)->attr.joinable = PTHREAD_CREATE_DETACHED;
|
(*thread)->attr.joinable = PTHREAD_CREATE_DETACHED;
|
||||||
(*thread)->mutex.unlock ();
|
(*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:
|
case WAIT_OBJECT_0:
|
||||||
if (return_val)
|
if (return_val)
|
||||||
|
@ -3501,7 +3501,7 @@ semaphore::_timedwait (const struct timespec *abstime)
|
||||||
int
|
int
|
||||||
semaphore::_wait ()
|
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:
|
case WAIT_OBJECT_0:
|
||||||
currentvalue--;
|
currentvalue--;
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
void lock ()
|
void lock ()
|
||||||
{
|
{
|
||||||
if (InterlockedIncrement ((long *) &lock_counter) != 1)
|
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 ()
|
void unlock ()
|
||||||
|
|
|
@ -80,7 +80,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
|
||||||
if ((waitfor = w->ev) == NULL)
|
if ((waitfor = w->ev) == NULL)
|
||||||
goto nochildren;
|
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);
|
sigproc_printf ("%d = cancelable_wait (...)", res);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue