summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/window.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-11-28 00:06:35 +0000
committerChristopher Faylor <me@cgf.cx>2001-11-28 00:06:35 +0000
commit4d029f3940b1f91b5ee06ccd724c90245c9d52cc (patch)
tree4fd6a178d45eaa67f07ed6e1905b6e192987a743 /winsup/cygwin/window.cc
parenta6d66c13997c667dc5de8de8865371b9fc1d20ef (diff)
downloadcygnal-4d029f3940b1f91b5ee06ccd724c90245c9d52cc.tar.gz
cygnal-4d029f3940b1f91b5ee06ccd724c90245c9d52cc.tar.bz2
cygnal-4d029f3940b1f91b5ee06ccd724c90245c9d52cc.zip
* 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.
Diffstat (limited to 'winsup/cygwin/window.cc')
-rw-r--r--winsup/cygwin/window.cc34
1 files changed, 23 insertions, 11 deletions
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;
+}
+