bug#76227: SRFI 19's current-time-monotonic is not actually monotonic

Maxim Cournoyer <[email protected]> Wed, 12 Feb 2025 22:54:53 +0900
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Hi,

Seen in srfi-19.scm:

--8<---------------cut here---------------start------------->8---
;; -- we define it to be the same as TAI.
;;    A different implementation of current-time-monotonic
;;    will require rewriting all of the time-monotonic converters,
;;    of course.

(define (current-time-monotonic)
  ;; Guile monotonic and TAI times are the same.
  (let ((tai (current-time-tai)))
    (make-time time-monotonic
               (time-nanosecond tai)
               (time-second tai))))
--8<---------------cut here---------------end--------------->8---

which as far as I can see uses CLOCK_REALTIME and not CLOCK_MONOTONIC as
it relies on gettimeofday(2), which has this note in its documentation:

    The time returned by gettimeofday() is affected by discontinuous  jumps
    in  the system time (e.g., if the system administrator manually changes
    the system time).  If you need a monotonically  increasing  clock,  see
    clock_gettime(2).

-- 
Thanks,
Maxim