summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/timer.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/timer.el')
-rw-r--r--lisp/emacs-lisp/timer.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index e140738d9f3..56323c85c2c 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -100,10 +100,16 @@ of SECS seconds since the epoch. SECS may be a fraction."
(integerp (cdr time)) (< 0 (cdr time)))
time
(encode-time time 1000000000000)))
+ (ticks (car ticks-hz))
(hz (cdr ticks-hz))
- (s-ticks (round (* secs hz)))
- (more-ticks (+ (car ticks-hz) s-ticks)))
- (encode-time (cons (- more-ticks (% more-ticks s-ticks)) hz))))
+ trunc-s-ticks)
+ (while (let ((s-ticks (* secs hz)))
+ (setq trunc-s-ticks (truncate s-ticks))
+ (/= s-ticks trunc-s-ticks))
+ (setq ticks (ash ticks 1))
+ (setq hz (ash hz 1)))
+ (let ((more-ticks (+ ticks trunc-s-ticks)))
+ (encode-time (cons (- more-ticks (% more-ticks trunc-s-ticks)) hz)))))
(defun timer-relative-time (time secs &optional usecs psecs)
"Advance TIME by SECS seconds and optionally USECS microseconds