From 4d029f3940b1f91b5ee06ccd724c90245c9d52cc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 28 Nov 2001 00:06:35 +0000 Subject: * cygwin.din (ualarm): New export. * dcrt0.cc (_dll_crt0): Add experimental tls storage declaration. (dll_crt0): Ditto. * debug.cc (thread_stub): Ditto. * thread.cc: Minor cleanup. (__pthread_create): Add experimental tls storage declaration. * miscfuncs.cc: Define tls index. * winsup.h: Declare experimental tls storage. * window.cc (alarm): Use old timer return from setitimer. (ualarm): New function. --- winsup/cygwin/window.cc | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'winsup/cygwin/window.cc') diff --git a/winsup/cygwin/window.cc b/winsup/cygwin/window.cc index 0554f37df..dbff12b69 100644 --- a/winsup/cygwin/window.cc +++ b/winsup/cygwin/window.cc @@ -150,8 +150,7 @@ window_terminate () SendMessage (ourhwnd, WM_DESTROY, 0, 0); } -extern "C" -int +extern "C" int setitimer (int which, const struct itimerval *value, struct itimerval *oldvalue) { UINT elapse; @@ -195,8 +194,7 @@ setitimer (int which, const struct itimerval *value, struct itimerval *oldvalue) return 0; } -extern "C" -int +extern "C" int getitimer (int which, struct itimerval *value) { UINT elapse, val; @@ -221,27 +219,41 @@ getitimer (int which, struct itimerval *value) elapse = GetTickCount () - start_time; val = itv.it_value.tv_sec * 1000 + itv.it_value.tv_usec / 1000; val -= elapse; - value->it_value.tv_sec = val/1000; - value->it_value.tv_usec = val%1000; + value->it_value.tv_sec = val / 1000; + value->it_value.tv_usec = val % 1000; return 0; } -extern "C" -unsigned int +extern "C" unsigned int alarm (unsigned int seconds) { int ret; struct itimerval newt, oldt; - getitimer (ITIMER_REAL, &oldt); - newt.it_value.tv_sec = seconds; newt.it_value.tv_usec = 0; newt.it_interval.tv_sec = 0; newt.it_interval.tv_usec = 0; - setitimer (ITIMER_REAL, &newt, NULL); + setitimer (ITIMER_REAL, &newt, &oldt); ret = oldt.it_value.tv_sec; if (ret == 0 && oldt.it_value.tv_usec) ret = 1; return ret; } + +extern "C" useconds_t +ualarm (useconds_t value, useconds_t interval) +{ + struct itimerval timer, otimer; + + timer.it_value.tv_sec = 0; + timer.it_value.tv_usec = value; + timer.it_interval.tv_sec = 0; + timer.it_interval.tv_usec = interval; + + if (setitimer (ITIMER_REAL, &timer, &otimer) < 0) + return (u_int)-1; + + return (otimer.it_value.tv_sec * 1000000) + otimer.it_value.tv_usec; +} + -- cgit v1.2.3