mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-09 07:40:39 -08:00
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html (Bug#32902). * doc/lispref/buffers.texi (Modification Time): * doc/lispref/os.texi (Processor Run Time, Time Calculations) * doc/lispref/processes.texi (System Processes): * doc/lispref/text.texi (Undo): Let the "Time of Day" section cover timestamp format details. * doc/lispref/os.texi (Time of Day): Say that timestamp internal format should not be assumed. Document new (ticks . hz) format. Omit mention of seconds-to-time since it is now just an alias for encode-time. (Time Conversion): Document encode-time extension. * etc/NEWS: Mention changes. * lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const. * lisp/calendar/cal-dst.el (calendar-absolute-from-time) (calendar-time-from-absolute) (calendar-next-time-zone-transition): * lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time): Simplify by using bignums, (TICKS . HZ), and new encode-time. * lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time): Simplify by using bignums and new encode-time. * lisp/calendar/parse-time.el (parse-iso8601-time-string): Handle DST more accurately, by using new encode-time. * lisp/calendar/time-date.el (seconds-to-time): * lisp/calendar/timeclock.el (timeclock-seconds-to-time): Now just an alias for encode-time. * lisp/calendar/time-date.el (days-to-time): * lisp/emacs-lisp/timer.el (timer--time-setter): * lisp/net/ntlm.el (ntlm-compute-timestamp): * lisp/obsolete/vc-arch.el (vc-arch-add-tagline): * lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36): * lisp/tar-mode (tar-octal-time): Don't assume timestamps default to list form. * lisp/tar-mode.el (tar-parse-octal-long-integer): Now an obsolete alias for tar-parse-octal-integer. * src/keyboard.c (decode_timer): Adjust to changes to time decoding functions elsewhere. * src/timefns.c: Include bignum.h, limits.h. (FASTER_TIMEFNS): New macro. (WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST) (timespec_hz, trillion, ztrillion): New constants. (make_timeval): Use TIME_T_MAX instead of its definiens. (check_time_validity, time_add, time_subtract): Remove. All uses removed. (disassemble_lisp_time): Remove; old code now folded into decode_lisp_time. All callers changed. (invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time) (timespec_mpz, timespec_ticks, time_hz_ticks) (lisp_time_hz_ticks, lisp_time_seconds) (time_form_stamp, lisp_time_form_stamp, decode_ticks_hz) (decode_lisp_time, mpz_time, list4_to_timespec): New functions. (decode_float_time, decode_time_components, lisp_to_timespec): Adjust to new struct lisp_time, which does not lose information like the old one did. (enum timeform): New enum. (decode_time_components): New arg FORM. All callers changed. RESULT and DRESULT are now mutually exclusive; no callers need to change because of this. (decode_time_components, lisp_time_struct) (lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time) (Fencode_time): Add support for (TICKS . HZ) form. (DECODE_SECS_ONLY): New constant. (lisp_time_struct): 2nd arg is now enum timeform, not int. All callers changed. (check_tm_member): Support bignums.m (Fencode_time): Add new two-arg functionality. * src/systime.h (struct lisp_time): Now ticks+hz rather than hi+lo+us+ps, since ticks+hz does not lose info. * test/src/systime-tests.el (time-equal-p-nil-nil): New test.
This commit is contained in:
parent
84f39d3389
commit
93fe420942
20 changed files with 1040 additions and 570 deletions
|
|
@ -57,17 +57,11 @@
|
|||
|
||||
(defun timer--time-setter (timer time)
|
||||
(timer--check timer)
|
||||
(setf (timer--high-seconds timer) (pop time))
|
||||
(let ((low time) (usecs 0) (psecs 0))
|
||||
(when (consp time)
|
||||
(setq low (pop time))
|
||||
(when time
|
||||
(setq usecs (pop time))
|
||||
(when time
|
||||
(setq psecs (car time)))))
|
||||
(setf (timer--low-seconds timer) low)
|
||||
(setf (timer--usecs timer) usecs)
|
||||
(setf (timer--psecs timer) psecs)
|
||||
(let ((lt (encode-time time 'list)))
|
||||
(setf (timer--high-seconds timer) (nth 0 lt))
|
||||
(setf (timer--low-seconds timer) (nth 1 lt))
|
||||
(setf (timer--usecs timer) (nth 2 lt))
|
||||
(setf (timer--psecs timer) (nth 3 lt))
|
||||
time))
|
||||
|
||||
;; Pseudo field `time'.
|
||||
|
|
@ -102,24 +96,14 @@ fire each time Emacs is idle for that many seconds."
|
|||
"Yield the next value after TIME that is an integral multiple of SECS.
|
||||
More precisely, the next value, after TIME, that is an integral multiple
|
||||
of SECS seconds since the epoch. SECS may be a fraction."
|
||||
(let* ((trillion 1000000000000)
|
||||
(time-sec (+ (nth 1 time)
|
||||
(* 65536 (nth 0 time))))
|
||||
(delta-sec (mod (- time-sec) secs))
|
||||
(next-sec (+ time-sec (floor delta-sec)))
|
||||
(next-sec-psec (floor (* trillion (mod delta-sec 1))))
|
||||
(sub-time-psec (+ (or (nth 3 time) 0)
|
||||
(* 1000000 (nth 2 time))))
|
||||
(psec-diff (- sub-time-psec next-sec-psec)))
|
||||
(if (and (<= next-sec time-sec) (< 0 psec-diff))
|
||||
(setq next-sec-psec (+ sub-time-psec
|
||||
(mod (- psec-diff) (* trillion secs)))))
|
||||
(setq next-sec (+ next-sec (floor next-sec-psec trillion)))
|
||||
(setq next-sec-psec (mod next-sec-psec trillion))
|
||||
(list (floor next-sec 65536)
|
||||
(floor (mod next-sec 65536))
|
||||
(floor next-sec-psec 1000000)
|
||||
(floor (mod next-sec-psec 1000000)))))
|
||||
(let* ((ticks-hz (if (and (consp time) (integerp (car time))
|
||||
(integerp (cdr time)) (< 0 (cdr time)))
|
||||
time
|
||||
(encode-time time 1000000000000)))
|
||||
(hz (cdr ticks-hz))
|
||||
(s-ticks (* secs hz))
|
||||
(more-ticks (+ (car ticks-hz) s-ticks)))
|
||||
(encode-time (cons (- more-ticks (% more-ticks s-ticks)) hz))))
|
||||
|
||||
(defun timer-relative-time (time secs &optional usecs psecs)
|
||||
"Advance TIME by SECS seconds and optionally USECS microseconds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue