summary refs log tree commit diff
path: root/sysdeps/unix/alarm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/alarm.c')
-rw-r--r--sysdeps/unix/alarm.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sysdeps/unix/alarm.c b/sysdeps/unix/alarm.c
index 7743256a09..e0dd3dbf57 100644
--- a/sysdeps/unix/alarm.c
+++ b/sysdeps/unix/alarm.c
@@ -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;
 }