diff options
author | Roland McGrath <roland@gnu.org> | 2005-02-16 09:26:38 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2005-02-16 09:26:38 +0000 |
commit | f43e546e93948f8577f2c2f89f71016a31710b9a (patch) | |
tree | 55ca6614fdfee7dd564fd40a34bd57b202d599bd /sysdeps | |
parent | 49145ae4e7f0066c01fada708b2d4b540e5de720 (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.c | 5 |
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; } |