* cygwin.din: Export nanosleep().
* signal.cc (nanosleep): New function. (sleep): Move old functionality to nanosleep(). Call nanosleep(). (usleep): Remove old functionality. Call nanosleep(). * include/cygwin/version.h: Bump API minor number.
This commit is contained in:
parent
13afd798c3
commit
89f7e8d1d3
|
@ -1,3 +1,11 @@
|
||||||
|
2003-01-21 Jason Tishler <jason@tishler.net>
|
||||||
|
|
||||||
|
* cygwin.din: Export nanosleep().
|
||||||
|
* signal.cc (nanosleep): New function.
|
||||||
|
(sleep): Move old functionality to nanosleep(). Call nanosleep().
|
||||||
|
(usleep): Remove old functionality. Call nanosleep().
|
||||||
|
* include/cygwin/version.h: Bump API minor number.
|
||||||
|
|
||||||
2003-01-21 Christopher Faylor <cgf@redhat.com>
|
2003-01-21 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* grp.cc: Call gr.refresh() rather than doing isunitialized tests
|
* grp.cc: Call gr.refresh() rather than doing isunitialized tests
|
||||||
|
|
|
@ -597,6 +597,8 @@ nan
|
||||||
_nan = nan
|
_nan = nan
|
||||||
nanf
|
nanf
|
||||||
_nanf = nanf
|
_nanf = nanf
|
||||||
|
nanosleep
|
||||||
|
_nanosleep = nanosleep
|
||||||
nextafter
|
nextafter
|
||||||
_nextafter = nextafter
|
_nextafter = nextafter
|
||||||
nextafterf
|
nextafterf
|
||||||
|
|
|
@ -169,12 +169,13 @@ details. */
|
||||||
69: Export strtof
|
69: Export strtof
|
||||||
70: Export asprintf, _asprintf_r, vasprintf, _vasprintf_r
|
70: Export asprintf, _asprintf_r, vasprintf, _vasprintf_r
|
||||||
71: Export strerror_r
|
71: Export strerror_r
|
||||||
|
72: Export nanosleep
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||||
|
|
||||||
#define CYGWIN_VERSION_API_MAJOR 0
|
#define CYGWIN_VERSION_API_MAJOR 0
|
||||||
#define CYGWIN_VERSION_API_MINOR 71
|
#define CYGWIN_VERSION_API_MINOR 72
|
||||||
|
|
||||||
/* There is also a compatibity version number associated with the
|
/* There is also a compatibity version number associated with the
|
||||||
shared memory regions. It is incremented when incompatible
|
shared memory regions. It is incremented when incompatible
|
||||||
|
|
|
@ -66,46 +66,63 @@ signal (int sig, _sig_func_ptr func)
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
sig_dispatch_pending (0);
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
|
pthread_testcancel ();
|
||||||
|
|
||||||
|
if (rqtp->tv_sec < 0 || rqtp->tv_nsec < 0 || rqtp->tv_nsec > 999999999)
|
||||||
|
{
|
||||||
|
set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD req = rqtp->tv_sec * 1000 + (rqtp->tv_nsec + 500000) / 1000000;
|
||||||
|
DWORD start_time = GetTickCount ();
|
||||||
|
DWORD end_time = start_time + req;
|
||||||
|
syscall_printf ("nanosleep (%ld)", req);
|
||||||
|
|
||||||
|
int rc = pthread::cancelable_wait (signal_arrived, req);
|
||||||
|
DWORD now = GetTickCount ();
|
||||||
|
DWORD rem = (rc == WAIT_TIMEOUT || now >= end_time) ? 0 : end_time - now;
|
||||||
|
if (WaitForSingleObject (signal_arrived, 0) == WAIT_OBJECT_0)
|
||||||
|
{
|
||||||
|
(void) thisframe.call_signal_handler ();
|
||||||
|
set_errno (EINTR);
|
||||||
|
res = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rmtp)
|
||||||
|
{
|
||||||
|
rmtp->tv_sec = rem / 1000;
|
||||||
|
rmtp->tv_nsec = (rem % 1000) * 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
syscall_printf ("%d = nanosleep (%ld, %ld)", res, req, rem);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" unsigned int
|
extern "C" unsigned int
|
||||||
sleep (unsigned int seconds)
|
sleep (unsigned int seconds)
|
||||||
{
|
{
|
||||||
int rc;
|
struct timespec req, rem;
|
||||||
sig_dispatch_pending (0);
|
req.tv_sec = seconds;
|
||||||
sigframe thisframe (mainthread);
|
req.tv_nsec = 0;
|
||||||
DWORD ms, start_time, end_time;
|
nanosleep (&req, &rem);
|
||||||
|
return rem.tv_sec + (rem.tv_nsec + 500000000) / 1000000000;
|
||||||
pthread_testcancel ();
|
|
||||||
|
|
||||||
ms = seconds * 1000;
|
|
||||||
start_time = GetTickCount ();
|
|
||||||
end_time = start_time + (seconds * 1000);
|
|
||||||
syscall_printf ("sleep (%d)", seconds);
|
|
||||||
|
|
||||||
rc = pthread::cancelable_wait (signal_arrived, ms);
|
|
||||||
DWORD now = GetTickCount ();
|
|
||||||
if (rc == WAIT_TIMEOUT || now >= end_time)
|
|
||||||
ms = 0;
|
|
||||||
else
|
|
||||||
ms = end_time - now;
|
|
||||||
if (WaitForSingleObject (signal_arrived, 0) == WAIT_OBJECT_0)
|
|
||||||
(void) thisframe.call_signal_handler ();
|
|
||||||
|
|
||||||
DWORD res = (ms + 500) / 1000;
|
|
||||||
syscall_printf ("%d = sleep (%d)", res, seconds);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" unsigned int
|
extern "C" unsigned int
|
||||||
usleep (unsigned int useconds)
|
usleep (unsigned int useconds)
|
||||||
{
|
{
|
||||||
pthread_testcancel ();
|
struct timespec req;
|
||||||
|
req.tv_sec = useconds / 1000000;
|
||||||
sig_dispatch_pending (0);
|
req.tv_nsec = (useconds % 1000000) * 1000;
|
||||||
syscall_printf ("usleep (%d)", useconds);
|
int res = nanosleep (&req, 0);
|
||||||
pthread::cancelable_wait (signal_arrived, (useconds + 500) / 1000);
|
return res;
|
||||||
syscall_printf ("0 = usleep (%d)", useconds);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
|
|
Loading…
Reference in New Issue