From: Roland McGrath Date: Wed, 16 Feb 2005 09:26:38 +0000 (+0000) Subject: 2004-12-29 Roland McGrath X-Git-Tag: cvs/fedora-glibc-2_3-20050216T1256~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f43e546e93948f8577f2c2f89f71016a31710b9a;p=thirdparty%2Fglibc.git 2004-12-29 Roland McGrath [BZ #626] * sysdeps/unix/alarm.c (alarm): Round return value to nearest rather than always up; when nearest is zero, round up to one. --- diff --git a/sysdeps/unix/alarm.c b/sysdeps/unix/alarm.c index ae77782c547..dafada76b58 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; }