diff options
author | Christopher Faylor <me@cgf.cx> | 2011-12-04 22:32:00 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2011-12-04 22:32:00 +0400 |
commit | 79e59d522afe5692c09ab21eade08947eca3ec19 (patch) | |
tree | cd44280ba1c10616a5bb8d19ed01f2681d75045c | |
parent | 4510afa90d42eec08a2ec91f4203ed126ab998c8 (diff) |
* sigproc.cc (cygWFMO): Don't assume that cancellable event is always
available.
* fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::waitforspace): Use cygWFMO
instead of WaitForMultipleObjects.
(fhandler_dev_dsp::Audio_in::waitfordata): Ditto.
* fhandler_fifo.cc (fhandler_fifo::wait): Ditto.
* fhandler_serial.cc (fhandler_serial::raw_read): Ditto.
(fhandler_serial::raw_write): Ditto.
* fhandler_tty.cc (fhandler_pty_slave::read): Ditto.
* select.cc (cygwin_select): Ditto for degenerate case.
-rw-r--r-- | winsup/cygwin/ChangeLog | 13 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_dsp.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_fifo.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_serial.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/select.cc | 5 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.h | 9 |
7 files changed, 26 insertions, 31 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c18f292dc..e132a724f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,18 @@ 2011-12-04 Christopher Faylor <me.cygwin2011@cgf.cx> + * sigproc.cc (cygWFMO): Don't assume that cancellable event is always + available. + * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::waitforspace): Use + cygWFMO instead of WaitForMultipleObjects. + (fhandler_dev_dsp::Audio_in::waitfordata): Ditto. + * fhandler_fifo.cc (fhandler_fifo::wait): Ditto. + * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. + (fhandler_serial::raw_write): Ditto. + * fhandler_tty.cc (fhandler_pty_slave::read): Ditto. + * select.cc (cygwin_select): Ditto for degenerate case. + +2011-12-04 Christopher Faylor <me.cygwin2011@cgf.cx> + * sigproc.h (cygWFMO): Move inside "INSIDE_CYGWIN" #ifdef. 2011-12-04 Christopher Faylor <me.cygwin2011@cgf.cx> diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc index fb363e19d..e46214fe5 100644 --- a/winsup/cygwin/fhandler_dsp.cc +++ b/winsup/cygwin/fhandler_dsp.cc @@ -540,10 +540,8 @@ fhandler_dev_dsp::Audio_out::waitforspace () set_errno (EAGAIN); return false; } - HANDLE w4[2] = { signal_arrived, pthread::get_cancel_event () }; - DWORD cnt = w4[1] ? 2 : 1; debug_printf ("100ms"); - switch (WaitForMultipleObjects (cnt, w4, FALSE, 100)) + switch (cygWFMO (0, 100)) { case WAIT_OBJECT_0: if (!_my_tls.call_signal_handler ()) @@ -920,10 +918,8 @@ fhandler_dev_dsp::Audio_in::waitfordata () set_errno (EAGAIN); return false; } - HANDLE w4[2] = { signal_arrived, pthread::get_cancel_event () }; - DWORD cnt = w4[1] ? 2 : 1; debug_printf ("100ms"); - switch (WaitForMultipleObjects (cnt, w4, FALSE, 100)) + switch (cygWFMO (0, 100)) { case WAIT_OBJECT_0: if (!_my_tls.call_signal_handler ()) diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index a7aecef96..ae5705483 100644 --- a/winsup/cygwin/fhandler_fifo.cc +++ b/winsup/cygwin/fhandler_fifo.cc @@ -210,15 +210,13 @@ fhandler_fifo::wait (HANDLE h) else what = "overlapped event"; #endif - HANDLE w4[3] = {h, signal_arrived, pthread::get_cancel_event ()}; - /* Set the wait to zero for non-blocking I/O-related events. */ DWORD wait = ((h == read_ready || h == write_ready) && get_flags () & O_NONBLOCK) ? 0 : INFINITE; debug_only_printf ("waiting for %s", what); /* Wait for the event. Set errno, as appropriate if something goes wrong. */ - switch (WaitForMultipleObjects (3, w4, false, wait)) + switch (cygWFMO (1, wait)) { case WAIT_OBJECT_0: debug_only_printf ("successfully waited for %s", what); diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 90494b8e9..1503cdc75 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -94,12 +94,9 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen) } else { - HANDLE w4[3] = { io_status.hEvent, signal_arrived, - pthread::get_cancel_event () }; - DWORD cnt = w4[2] ? 3 : 2; overlapped_armed = 1; restart: - switch (WaitForMultipleObjects (cnt, w4, FALSE, INFINITE)) + switch (cygWFMO (1, INFINITE, io_status.hEvent)) { case WAIT_OBJECT_0: if (!GetOverlappedResult (get_handle (), &io_status, &n, @@ -205,11 +202,8 @@ fhandler_serial::raw_write (const void *ptr, size_t len) if (!is_nonblocking ()) { - HANDLE w4[3] = { write_status.hEvent, signal_arrived, - pthread::get_cancel_event () }; - DWORD cnt = w4[2] ? 3 : 2; restart: - switch (WaitForMultipleObjects (cnt, w4, FALSE, INFINITE)) + switch (cygWFMO (1, INFINITE, write_status.hEvent)) { case WAIT_OBJECT_0: break; diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 6b7ad80f2..1906b06b2 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -702,10 +702,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len) while (len) { - HANDLE w4[3] = { input_available_event, signal_arrived, - pthread::get_cancel_event () }; - DWORD cnt = w4[2] ? 3 : 2; - switch (WaitForMultipleObjects (cnt, w4, FALSE, time_to_wait)) + switch (cygWFMO (1, time_to_wait, input_available_event)) { case WAIT_OBJECT_0: break; @@ -741,8 +738,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len) } /* Now that we know that input is available we have to grab the input mutex. */ - w4[0] = input_mutex; - switch (WaitForMultipleObjects (cnt, w4, FALSE, 1000)) + switch (cygWFMO (1, 1000, input_mutex)) { case WAIT_OBJECT_0: case WAIT_ABANDONED_0: diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 4e68041ba..b8135954e 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -133,10 +133,7 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, /* Degenerate case. No fds to wait for. Just wait. */ if (sel.start.next == NULL) { - HANDLE w4[2] = { signal_arrived, pthread::get_cancel_event () }; - DWORD cnt = w4[1] ? 2 : 1; - - switch (WaitForMultipleObjects (cnt, w4, FALSE, ms)) + switch (cygWFMO (0, ms)) { case WAIT_OBJECT_0: select_printf ("signal received"); diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index 2c027a9e4..21293ccb9 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -88,11 +88,12 @@ DWORD cygWFMO (DWORD n, DWORD howlong, ...) va_start (ap, howlong); HANDLE w4[n + 2]; va_start (ap, howlong); - unsigned i; - for (i = 0; i < n; i++) + for (unsigned i = 0; i < n; i++) w4[i] = va_arg (ap, HANDLE); - w4[i++] = signal_arrived; - w4[i++] = pthread::get_cancel_event (); + w4[n++] = signal_arrived; + w4[n++] = pthread::get_cancel_event (); + if (!w4[n - 1]) + n--; return WaitForMultipleObjects (n, w4, FALSE, howlong); } #endif |