Wed Feb 14 00:21:17 1996 David Mosberger-Tang <davidm@azstarnet.com>
authorroland <roland>
Tue, 19 Mar 1996 19:54:00 +0000 (19:54 +0000)
committerroland <roland>
Tue, 19 Mar 1996 19:54:00 +0000 (19:54 +0000)
* sysdeps/unix/alarm.c (alarm): do roundup using test & increment
instead of multiplication.

sysdeps/unix/alarm.c

index 7743256..e0dd3db 100644 (file)
@@ -31,6 +31,7 @@ unsigned int
 DEFUN(alarm, (seconds), unsigned int seconds)
 {
   struct itimerval old, new;
+  unsigned int retval;
 
   new.it_interval.tv_usec = 0;
   new.it_interval.tv_sec = 0;
@@ -39,5 +40,8 @@ DEFUN(alarm, (seconds), unsigned int seconds)
   if (__setitimer(ITIMER_REAL, &new, &old) < 0)
     return 0;
 
-  return (old.it_value.tv_sec + (old.it_value.tv_usec + 999999) / 1000000);
+  retval = old.it_value.tv_sec;
+  if (old.it_value.tv_usec)
+    ++retval;
+  return retval;
 }