summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2005-02-16 09:26:38 +0000
committerRoland McGrath <roland@gnu.org>2005-02-16 09:26:38 +0000
commitf43e546e93948f8577f2c2f89f71016a31710b9a (patch)
tree55ca6614fdfee7dd564fd40a34bd57b202d599bd /sysdeps
parent49145ae4e7f0066c01fada708b2d4b540e5de720 (diff)
2004-12-29 Roland McGrath <roland@redhat.com>
[BZ #626] * sysdeps/unix/alarm.c (alarm): Round return value to nearest rather than always up; when nearest is zero, round up to one.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/alarm.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sysdeps/unix/alarm.c b/sysdeps/unix/alarm.c
index ae77782c54..dafada76b5 100644
--- a/sysdeps/unix/alarm.c
+++ b/sysdeps/unix/alarm.c
@@ -41,7 +41,10 @@ alarm (seconds)
return 0;
retval = old.it_value.tv_sec;
- if (old.it_value.tv_usec)
+ /* Round to the nearest second, but never report zero seconds when
+ the alarm is still set. */
+ if (old.it_value.tv_usec >= 500000
+ || (retval == 0 && old.it_value.tv_usec > 0))
++retval;
return retval;
}