Apply sleep_cancel patch

This commit is contained in:
Thomas Pfaff 2003-01-14 20:05:49 +00:00
parent d83b482409
commit 7ec66a2c28
2 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,10 @@
2003-01-10 Thomas Pfaff <tpfaff@gmx.net> 2003-01-14 Thomas Pfaff <tpfaff@gmx.net>
* signal.cc (sleep): Add pthread_testcancel call.
Wait for signal and cancellation event.
(usleep): Ditto.
2003-01-14 Thomas Pfaff <tpfaff@gmx.net>
* exceptions.cc (handle_sigsuspend): Add pthread_testcancel call. * exceptions.cc (handle_sigsuspend): Add pthread_testcancel call.
Wait for signal and cancellation event. Wait for signal and cancellation event.

View File

@ -74,12 +74,14 @@ sleep (unsigned int seconds)
sigframe thisframe (mainthread); sigframe thisframe (mainthread);
DWORD ms, start_time, end_time; DWORD ms, start_time, end_time;
pthread_testcancel ();
ms = seconds * 1000; ms = seconds * 1000;
start_time = GetTickCount (); start_time = GetTickCount ();
end_time = start_time + (seconds * 1000); end_time = start_time + (seconds * 1000);
syscall_printf ("sleep (%d)", seconds); syscall_printf ("sleep (%d)", seconds);
rc = WaitForSingleObject (signal_arrived, ms); rc = pthread::cancelable_wait (signal_arrived, ms);
DWORD now = GetTickCount (); DWORD now = GetTickCount ();
if (rc == WAIT_TIMEOUT || now >= end_time) if (rc == WAIT_TIMEOUT || now >= end_time)
ms = 0; ms = 0;
@ -97,9 +99,11 @@ sleep (unsigned int seconds)
extern "C" unsigned int extern "C" unsigned int
usleep (unsigned int useconds) usleep (unsigned int useconds)
{ {
pthread_testcancel ();
sig_dispatch_pending (0); sig_dispatch_pending (0);
syscall_printf ("usleep (%d)", useconds); syscall_printf ("usleep (%d)", useconds);
WaitForSingleObject (signal_arrived, (useconds + 500) / 1000); pthread::cancelable_wait (signal_arrived, (useconds + 500) / 1000);
syscall_printf ("0 = usleep (%d)", useconds); syscall_printf ("0 = usleep (%d)", useconds);
return 0; return 0;
} }