emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 73d6b19 8/9: Omit temporary warning re obsolete timestamps


From: Paul Eggert
Subject: master 73d6b19 8/9: Omit temporary warning re obsolete timestamps
Date: Thu, 16 Dec 2021 14:17:38 -0500 (EST)

branch: master
commit 73d6b19024db10b65ba368bd079223157d73e737
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Omit temporary warning re obsolete timestamps
    
    Do not warn about timestamps like (1 . 1000).  This warning was added
    in Emacs 27 as a temporary transition aid, and has now served its
    purpose.  These timestamps, which Emacs 26 and earlier treated as (HI
    . LO) instead of as (TICKS . HZ), were never generated by Emacs
    primitives, and in practice the warning seems to have been triggered
    only by test cases designed to generate it.
    * src/timefns.c (WARN_OBSOLETE_TIMESTAMPS): Remove.
    All uses changed to assume it’s false.
    (decode_lisp_time): Simplify by taking a bool instead of an
    integer bitmask.  All uses changed.
---
 doc/lispref/os.texi |  5 +----
 etc/NEWS            |  6 ++++++
 src/systime.h       |  3 +--
 src/timefns.c       | 59 +++++++++--------------------------------------------
 4 files changed, 18 insertions(+), 55 deletions(-)

diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index e369618..de76ab4 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1507,10 +1507,7 @@ The optional @var{form} argument specifies the timestamp 
form to be
 returned.  If @var{form} is the symbol @code{integer}, this function
 returns an integer count of seconds.  If @var{form} is a positive
 integer, it specifies a clock frequency and this function returns an
-integer-pair timestamp @code{(@var{ticks}
-. @var{form})}.@footnote{Currently a positive integer @var{form}
-should be at least 65536 if the returned value is intended to be given
-to standard functions expecting Lisp timestamps.}  If @var{form} is
+integer-pair timestamp @code{(@var{ticks} . @var{form})}.  If @var{form} is
 @code{t}, this function treats it as a positive integer suitable for
 representing the timestamp; for example, it is treated as 1000000000
 if @var{time} is nil and the platform timestamp has nanosecond
diff --git a/etc/NEWS b/etc/NEWS
index 1d78f1f..be8b195 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1152,6 +1152,12 @@ cookies set by web pages on disk.
 This variable is bound to t during the preparation of a "*Help*" buffer.
 
 +++
+** Timestamps like (1 . 1000) now work without warnings being generated.
+For example, (time-add nil '(1 . 1000)) no longer warns that the
+(1 . 1000) acts like (1000 . 1000000).  This warning, which was a
+temporary transition aid for Emacs 27, has served its purpose.
+
++++
 ** 'date-to-time' now assumes earliest values if its argument lacks
 month, day, or time.  For example, (date-to-time "2021-12-04") now
 assumes a time of 00:00 instead of signaling an error.
diff --git a/src/systime.h b/src/systime.h
index 08ab5bd..ce9403c 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -80,8 +80,7 @@ struct lisp_time
   /* Clock count as a Lisp integer.  */
   Lisp_Object ticks;
 
-  /* Clock frequency (ticks per second) as a positive Lisp integer.
-     (TICKS . HZ) is a valid Lisp timestamp unless HZ < 65536.  */
+  /* Clock frequency (ticks per second) as a positive Lisp integer.  */
   Lisp_Object hz;
 };
 
diff --git a/src/timefns.c b/src/timefns.c
index 0c218ba..998490b 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -69,16 +69,6 @@ enum { TM_YEAR_BASE = 1900 };
 # define FASTER_TIMEFNS 1
 #endif
 
-/* Whether to warn about Lisp timestamps (TICKS . HZ) that may be
-   instances of obsolete-format timestamps (HI . LO) where HI is
-   the high-order bits and LO the low-order 16 bits.  Currently this
-   is true, but it should change to false in a future version of
-   Emacs.  Compile with -DWARN_OBSOLETE_TIMESTAMPS=0 to see what the
-   future will be like.  */
-#ifndef WARN_OBSOLETE_TIMESTAMPS
-enum { WARN_OBSOLETE_TIMESTAMPS = true };
-#endif
-
 /* Although current-time etc. generate list-format timestamps
    (HI LO US PS), the plan is to change these functions to generate
    frequency-based timestamps (TICKS . HZ) in a future release.
@@ -817,14 +807,10 @@ decode_time_components (enum timeform form,
   return decode_ticks_hz (make_integer_mpz (), hz, result, dresult);
 }
 
-enum { DECODE_SECS_ONLY = WARN_OBSOLETE_TIMESTAMPS + 1 };
-
 /* Decode a Lisp timestamp SPECIFIED_TIME that represents a time.
 
-   FLAGS specifies conversion flags.  If FLAGS & DECODE_SECS_ONLY,
-   ignore and do not validate any sub-second components of an
-   old-format SPECIFIED_TIME.  If FLAGS & WARN_OBSOLETE_TIMESTAMPS,
-   diagnose what could be obsolete (HIGH . LOW) timestamps.
+   If DECODE_SECS_ONLY, ignore and do not validate any sub-second
+   components of an old-format SPECIFIED_TIME.
 
    If RESULT is not null, store into *RESULT the converted time;
    otherwise, store into *DRESULT the number of seconds since the
@@ -833,7 +819,7 @@ enum { DECODE_SECS_ONLY = WARN_OBSOLETE_TIMESTAMPS + 1 };
 
    Return the form of SPECIFIED-TIME.  Signal an error if unsuccessful.  */
 static enum timeform
-decode_lisp_time (Lisp_Object specified_time, int flags,
+decode_lisp_time (Lisp_Object specified_time, bool decode_secs_only,
                  struct lisp_time *result, double *dresult)
 {
   Lisp_Object high = make_fixnum (0);
@@ -854,7 +840,7 @@ decode_lisp_time (Lisp_Object specified_time, int flags,
        {
          Lisp_Object low_tail = XCDR (low);
          low = XCAR (low);
-         if (! (flags & DECODE_SECS_ONLY))
+         if (! decode_secs_only)
            {
              if (CONSP (low_tail))
                {
@@ -877,9 +863,6 @@ decode_lisp_time (Lisp_Object specified_time, int flags,
        }
       else
        {
-         if (flags & WARN_OBSOLETE_TIMESTAMPS
-             && RANGED_FIXNUMP (0, low, (1 << LO_TIME_BITS) - 1))
-           message ("obsolete timestamp with cdr %"pI"d", XFIXNUM (low));
          form = TIMEFORM_TICKS_HZ;
        }
 
@@ -1008,8 +991,7 @@ static struct lisp_time
 lisp_time_struct (Lisp_Object specified_time, enum timeform *pform)
 {
   struct lisp_time t;
-  enum timeform form
-    = decode_lisp_time (specified_time, WARN_OBSOLETE_TIMESTAMPS, &t, 0);
+  enum timeform form = decode_lisp_time (specified_time, false, &t, 0);
   if (pform)
     *pform = form;
   return t;
@@ -1034,9 +1016,8 @@ lisp_time_argument (Lisp_Object specified_time)
 static time_t
 lisp_seconds_argument (Lisp_Object specified_time)
 {
-  int flags = WARN_OBSOLETE_TIMESTAMPS | DECODE_SECS_ONLY;
   struct lisp_time lt;
-  decode_lisp_time (specified_time, flags, &lt, 0);
+  decode_lisp_time (specified_time, true, &lt, 0);
   struct timespec t = lisp_to_timespec (lt);
   if (! timespec_valid_p (t))
     time_overflow ();
@@ -1138,24 +1119,6 @@ time_arith (Lisp_Object a, Lisp_Object b, bool subtract)
       mpz_t *ihz = &mpz[0];
       mpz_mul (*ihz, *fa, *db);
 
-      /* When warning about obsolete timestamps, if the smaller
-        denominator comes from a non-(TICKS . HZ) timestamp and could
-        generate a (TICKS . HZ) timestamp that would look obsolete,
-        arrange for the result to have a higher HZ to avoid a
-        spurious warning by a later consumer of this function's
-        returned value.  */
-      verify (1 << LO_TIME_BITS <= ULONG_MAX);
-      if (WARN_OBSOLETE_TIMESTAMPS
-         && (da_lt_db ? aform : bform) == TIMEFORM_FLOAT
-         && (da_lt_db ? bform : aform) != TIMEFORM_TICKS_HZ
-         && mpz_cmp_ui (*hzmin, 1) > 0
-         && mpz_cmp_ui (*hzmin, 1 << LO_TIME_BITS) < 0)
-       {
-         mpz_t *hzmin1 = &mpz[2 - da_lt_db];
-         mpz_set_ui (*hzmin1, 1 << LO_TIME_BITS);
-         hzmin = hzmin1;
-       }
-
       /* iticks = (fb * na) OP (fa * nb), where OP is + or -.  */
       mpz_t const *na = bignum_integer (iticks, ta.ticks);
       mpz_mul (*iticks, *fb, *na);
@@ -1303,7 +1266,7 @@ or (if you need time as a string) `format-time-string'.  
*/)
   (Lisp_Object specified_time)
 {
   double t;
-  decode_lisp_time (specified_time, 0, 0, &t);
+  decode_lisp_time (specified_time, false, 0, &t);
   return make_float (t);
 }
 
@@ -1702,7 +1665,7 @@ usage: (encode-time TIME &rest OBSOLESCENT-ARGUMENTS)  */)
 
   /* Let SEC = floor (LT.ticks / HZ), with SUBSECTICKS the remainder.  */
   struct lisp_time lt;
-  decode_lisp_time (secarg, 0, &lt, 0);
+  decode_lisp_time (secarg, false, &lt, 0);
   Lisp_Object hz = lt.hz, sec, subsecticks;
   if (FASTER_TIMEFNS && EQ (hz, make_fixnum (1)))
     {
@@ -1755,9 +1718,7 @@ Truncate the returned value toward minus infinity.
 If FORM is nil (the default), return the same form as `current-time'.
 If FORM is a positive integer, return a pair of integers (TICKS . FORM),
 where TICKS is the number of clock ticks and FORM is the clock frequency
-in ticks per second.  (Currently the positive integer should be at least
-65536 if the returned value is expected to be given to standard functions
-expecting Lisp timestamps.)  If FORM is t, return (TICKS . PHZ), where
+in ticks per second.  If FORM is t, return (TICKS . PHZ), where
 PHZ is a suitable clock frequency in ticks per second.  If FORM is
 `integer', return an integer count of seconds.  If FORM is `list',
 return an integer list (HIGH LOW USEC PSEC), where HIGH has the most
@@ -1766,7 +1727,7 @@ bits, and USEC and PSEC are the microsecond and 
picosecond counts.  */)
      (Lisp_Object time, Lisp_Object form)
 {
   struct lisp_time t;
-  enum timeform input_form = decode_lisp_time (time, 0, &t, 0);
+  enum timeform input_form = decode_lisp_time (time, false, &t, 0);
   if (NILP (form))
     form = CURRENT_TIME_LIST ? Qlist : Qt;
   if (EQ (form, Qlist))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]