diff options
author | Christopher Faylor <me@cgf.cx> | 2012-06-19 04:31:15 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2012-06-19 04:31:15 +0400 |
commit | af5cd145835d35519af02d0d226f67eb777e4945 (patch) | |
tree | d31ebb964550d4e73c3f0d63d3fa0d1b502e44f4 /winsup/cygwin/cygwait.h | |
parent | 88fbcb5afd6d7d687387b22509037d99e2aa07ff (diff) |
* cygwait.cc (cancelable_wait): Mimic old cygwait behavior more closely wrt
handling of call_signal_handler.
* cygwait.h (WAIT_CANCELED): Move here and redefine.
(WAIT_SIGNALED): Ditto.
* thread.h (WAIT_CANCELED): Delete.
(WAIT_SIGNALED): Ditto.
Diffstat (limited to 'winsup/cygwin/cygwait.h')
-rw-r--r-- | winsup/cygwin/cygwait.h | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/winsup/cygwin/cygwait.h b/winsup/cygwin/cygwait.h index c2b7f5801..a7daf88eb 100644 --- a/winsup/cygwin/cygwait.h +++ b/winsup/cygwin/cygwait.h @@ -19,6 +19,8 @@ enum cw_wait_mask cw_sig_eintr = 0x0008 }; +extern TIMER_BASIC_INFORMATION cw_nowait; + const unsigned cw_std_mask = cw_cancel | cw_cancel_self | cw_sig; DWORD cancelable_wait (HANDLE, PLARGE_INTEGER timeout = NULL, @@ -26,7 +28,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; @@ -37,7 +39,14 @@ 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_eintr); + + return cancelable_wait (h, pi_howlong, mask); +} + +static inline DWORD __attribute__ ((always_inline)) +cygwait (HANDLE h, DWORD howlong = INFINITE) +{ + return cancelable_wait (h, howlong, cw_cancel | cw_sig_eintr); } static inline DWORD __attribute__ ((always_inline)) @@ -45,3 +54,29 @@ cygwait (DWORD howlong) { return cygwait ((HANDLE) NULL, howlong); } + +class set_thread_waiting +{ + void doit (bool setit, DWORD& here) + { + if (setit) + { + if (_my_tls.signal_arrived == NULL) + _my_tls.signal_arrived = CreateEvent (&sec_none_nih, false, false, NULL); + here = _my_tls.signal_arrived; + _my_tls.waiting = true; + } + } +public: + set_thread_waiting (bool setit, DWORD& here) { doit (setit, here); } + set_thread_waiting (DWORD& here) { doit (true, here); } + + ~set_thread_waiting () + { + if (_my_tls.waiting) + { + _my_tls.waiting = false; + ResetEvent (_my_tls.signal_arrived); + } + } +}; |