From 6065411b88b27adf7908a7615c96d691f2879399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 13 Nov 2005 13:20:25 +0000 Subject: [PATCH] ualarm()'s arguments are actually useconds_t, too. Fixed implementation of ualarm() to support larger values. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14890 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/posix/unistd.h | 2 +- src/system/libroot/posix/unistd/ualarm.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/headers/posix/unistd.h b/headers/posix/unistd.h index 2c3191d35d..585a8b61e5 100644 --- a/headers/posix/unistd.h +++ b/headers/posix/unistd.h @@ -129,7 +129,7 @@ extern int tcsetpgrp(int fd, pid_t pgrpid); extern void *sbrk(long incr); extern unsigned int alarm(unsigned int seconds); -extern useconds_t ualarm(unsigned int microSeconds, unsigned int interval); +extern useconds_t ualarm(useconds_t microSeconds, useconds_t interval); extern unsigned int sleep(unsigned int seconds); extern int usleep(unsigned int microSeconds); extern clock_t clock(void); diff --git a/src/system/libroot/posix/unistd/ualarm.c b/src/system/libroot/posix/unistd/ualarm.c index 6331323c28..927827ac6b 100644 --- a/src/system/libroot/posix/unistd/ualarm.c +++ b/src/system/libroot/posix/unistd/ualarm.c @@ -1,7 +1,7 @@ /* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ + * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #include @@ -11,15 +11,15 @@ #include -uint -ualarm(uint usec, uint interval) +useconds_t +ualarm(useconds_t usec, useconds_t interval) { struct itimerval value, oldValue; - value.it_value.tv_sec = 0; - value.it_value.tv_usec = usec; - value.it_interval.tv_sec = 0; - value.it_interval.tv_usec = interval; + value.it_value.tv_sec = usec / 1000000; + value.it_value.tv_usec = usec % 1000000; + value.it_interval.tv_sec = interval / 1000000; + value.it_interval.tv_usec = interval % 1000000; if (setitimer(ITIMER_REAL, &value, &oldValue) < 0) return -1;