diff options
| author | Paul Eggert | 2021-12-16 09:40:22 -0800 |
|---|---|---|
| committer | Paul Eggert | 2021-12-16 11:17:27 -0800 |
| commit | 73d6b19024db10b65ba368bd079223157d73e737 (patch) | |
| tree | d41cc6917293e012bfcc88099b28d9681f158a04 /src | |
| parent | f25ad39983cc3e89b007390bc0fd860f48379497 (diff) | |
| download | emacs-73d6b19024db10b65ba368bd079223157d73e737.tar.gz emacs-73d6b19024db10b65ba368bd079223157d73e737.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/systime.h | 3 | ||||
| -rw-r--r-- | src/timefns.c | 59 |
2 files changed, 11 insertions, 51 deletions
diff --git a/src/systime.h b/src/systime.h index 08ab5bdde33..ce9403c931d 100644 --- a/src/systime.h +++ b/src/systime.h | |||
| @@ -80,8 +80,7 @@ struct lisp_time | |||
| 80 | /* Clock count as a Lisp integer. */ | 80 | /* Clock count as a Lisp integer. */ |
| 81 | Lisp_Object ticks; | 81 | Lisp_Object ticks; |
| 82 | 82 | ||
| 83 | /* Clock frequency (ticks per second) as a positive Lisp integer. | 83 | /* Clock frequency (ticks per second) as a positive Lisp integer. */ |
| 84 | (TICKS . HZ) is a valid Lisp timestamp unless HZ < 65536. */ | ||
| 85 | Lisp_Object hz; | 84 | Lisp_Object hz; |
| 86 | }; | 85 | }; |
| 87 | 86 | ||
diff --git a/src/timefns.c b/src/timefns.c index 0c218ba6ef2..998490bb7fb 100644 --- a/src/timefns.c +++ b/src/timefns.c | |||
| @@ -69,16 +69,6 @@ enum { TM_YEAR_BASE = 1900 }; | |||
| 69 | # define FASTER_TIMEFNS 1 | 69 | # define FASTER_TIMEFNS 1 |
| 70 | #endif | 70 | #endif |
| 71 | 71 | ||
| 72 | /* Whether to warn about Lisp timestamps (TICKS . HZ) that may be | ||
| 73 | instances of obsolete-format timestamps (HI . LO) where HI is | ||
| 74 | the high-order bits and LO the low-order 16 bits. Currently this | ||
| 75 | is true, but it should change to false in a future version of | ||
| 76 | Emacs. Compile with -DWARN_OBSOLETE_TIMESTAMPS=0 to see what the | ||
| 77 | future will be like. */ | ||
| 78 | #ifndef WARN_OBSOLETE_TIMESTAMPS | ||
| 79 | enum { WARN_OBSOLETE_TIMESTAMPS = true }; | ||
| 80 | #endif | ||
| 81 | |||
| 82 | /* Although current-time etc. generate list-format timestamps | 72 | /* Although current-time etc. generate list-format timestamps |
| 83 | (HI LO US PS), the plan is to change these functions to generate | 73 | (HI LO US PS), the plan is to change these functions to generate |
| 84 | frequency-based timestamps (TICKS . HZ) in a future release. | 74 | frequency-based timestamps (TICKS . HZ) in a future release. |
| @@ -817,14 +807,10 @@ decode_time_components (enum timeform form, | |||
| 817 | return decode_ticks_hz (make_integer_mpz (), hz, result, dresult); | 807 | return decode_ticks_hz (make_integer_mpz (), hz, result, dresult); |
| 818 | } | 808 | } |
| 819 | 809 | ||
| 820 | enum { DECODE_SECS_ONLY = WARN_OBSOLETE_TIMESTAMPS + 1 }; | ||
| 821 | |||
| 822 | /* Decode a Lisp timestamp SPECIFIED_TIME that represents a time. | 810 | /* Decode a Lisp timestamp SPECIFIED_TIME that represents a time. |
| 823 | 811 | ||
| 824 | FLAGS specifies conversion flags. If FLAGS & DECODE_SECS_ONLY, | 812 | If DECODE_SECS_ONLY, ignore and do not validate any sub-second |
| 825 | ignore and do not validate any sub-second components of an | 813 | components of an old-format SPECIFIED_TIME. |
| 826 | old-format SPECIFIED_TIME. If FLAGS & WARN_OBSOLETE_TIMESTAMPS, | ||
| 827 | diagnose what could be obsolete (HIGH . LOW) timestamps. | ||
| 828 | 814 | ||
| 829 | If RESULT is not null, store into *RESULT the converted time; | 815 | If RESULT is not null, store into *RESULT the converted time; |
| 830 | otherwise, store into *DRESULT the number of seconds since the | 816 | otherwise, store into *DRESULT the number of seconds since the |
| @@ -833,7 +819,7 @@ enum { DECODE_SECS_ONLY = WARN_OBSOLETE_TIMESTAMPS + 1 }; | |||
| 833 | 819 | ||
| 834 | Return the form of SPECIFIED-TIME. Signal an error if unsuccessful. */ | 820 | Return the form of SPECIFIED-TIME. Signal an error if unsuccessful. */ |
| 835 | static enum timeform | 821 | static enum timeform |
| 836 | decode_lisp_time (Lisp_Object specified_time, int flags, | 822 | decode_lisp_time (Lisp_Object specified_time, bool decode_secs_only, |
| 837 | struct lisp_time *result, double *dresult) | 823 | struct lisp_time *result, double *dresult) |
| 838 | { | 824 | { |
| 839 | Lisp_Object high = make_fixnum (0); | 825 | Lisp_Object high = make_fixnum (0); |
| @@ -854,7 +840,7 @@ decode_lisp_time (Lisp_Object specified_time, int flags, | |||
| 854 | { | 840 | { |
| 855 | Lisp_Object low_tail = XCDR (low); | 841 | Lisp_Object low_tail = XCDR (low); |
| 856 | low = XCAR (low); | 842 | low = XCAR (low); |
| 857 | if (! (flags & DECODE_SECS_ONLY)) | 843 | if (! decode_secs_only) |
| 858 | { | 844 | { |
| 859 | if (CONSP (low_tail)) | 845 | if (CONSP (low_tail)) |
| 860 | { | 846 | { |
| @@ -877,9 +863,6 @@ decode_lisp_time (Lisp_Object specified_time, int flags, | |||
| 877 | } | 863 | } |
| 878 | else | 864 | else |
| 879 | { | 865 | { |
| 880 | if (flags & WARN_OBSOLETE_TIMESTAMPS | ||
| 881 | && RANGED_FIXNUMP (0, low, (1 << LO_TIME_BITS) - 1)) | ||
| 882 | message ("obsolete timestamp with cdr %"pI"d", XFIXNUM (low)); | ||
| 883 | form = TIMEFORM_TICKS_HZ; | 866 | form = TIMEFORM_TICKS_HZ; |
| 884 | } | 867 | } |
| 885 | 868 | ||
| @@ -1008,8 +991,7 @@ static struct lisp_time | |||
| 1008 | lisp_time_struct (Lisp_Object specified_time, enum timeform *pform) | 991 | lisp_time_struct (Lisp_Object specified_time, enum timeform *pform) |
| 1009 | { | 992 | { |
| 1010 | struct lisp_time t; | 993 | struct lisp_time t; |
| 1011 | enum timeform form | 994 | enum timeform form = decode_lisp_time (specified_time, false, &t, 0); |
| 1012 | = decode_lisp_time (specified_time, WARN_OBSOLETE_TIMESTAMPS, &t, 0); | ||
| 1013 | if (pform) | 995 | if (pform) |
| 1014 | *pform = form; | 996 | *pform = form; |
| 1015 | return t; | 997 | return t; |
| @@ -1034,9 +1016,8 @@ lisp_time_argument (Lisp_Object specified_time) | |||
| 1034 | static time_t | 1016 | static time_t |
| 1035 | lisp_seconds_argument (Lisp_Object specified_time) | 1017 | lisp_seconds_argument (Lisp_Object specified_time) |
| 1036 | { | 1018 | { |
| 1037 | int flags = WARN_OBSOLETE_TIMESTAMPS | DECODE_SECS_ONLY; | ||
| 1038 | struct lisp_time lt; | 1019 | struct lisp_time lt; |
| 1039 | decode_lisp_time (specified_time, flags, <, 0); | 1020 | decode_lisp_time (specified_time, true, <, 0); |
| 1040 | struct timespec t = lisp_to_timespec (lt); | 1021 | struct timespec t = lisp_to_timespec (lt); |
| 1041 | if (! timespec_valid_p (t)) | 1022 | if (! timespec_valid_p (t)) |
| 1042 | time_overflow (); | 1023 | time_overflow (); |
| @@ -1138,24 +1119,6 @@ time_arith (Lisp_Object a, Lisp_Object b, bool subtract) | |||
| 1138 | mpz_t *ihz = &mpz[0]; | 1119 | mpz_t *ihz = &mpz[0]; |
| 1139 | mpz_mul (*ihz, *fa, *db); | 1120 | mpz_mul (*ihz, *fa, *db); |
| 1140 | 1121 | ||
| 1141 | /* When warning about obsolete timestamps, if the smaller | ||
| 1142 | denominator comes from a non-(TICKS . HZ) timestamp and could | ||
| 1143 | generate a (TICKS . HZ) timestamp that would look obsolete, | ||
| 1144 | arrange for the result to have a higher HZ to avoid a | ||
| 1145 | spurious warning by a later consumer of this function's | ||
| 1146 | returned value. */ | ||
| 1147 | verify (1 << LO_TIME_BITS <= ULONG_MAX); | ||
| 1148 | if (WARN_OBSOLETE_TIMESTAMPS | ||
| 1149 | && (da_lt_db ? aform : bform) == TIMEFORM_FLOAT | ||
| 1150 | && (da_lt_db ? bform : aform) != TIMEFORM_TICKS_HZ | ||
| 1151 | && mpz_cmp_ui (*hzmin, 1) > 0 | ||
| 1152 | && mpz_cmp_ui (*hzmin, 1 << LO_TIME_BITS) < 0) | ||
| 1153 | { | ||
| 1154 | mpz_t *hzmin1 = &mpz[2 - da_lt_db]; | ||
| 1155 | mpz_set_ui (*hzmin1, 1 << LO_TIME_BITS); | ||
| 1156 | hzmin = hzmin1; | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | /* iticks = (fb * na) OP (fa * nb), where OP is + or -. */ | 1122 | /* iticks = (fb * na) OP (fa * nb), where OP is + or -. */ |
| 1160 | mpz_t const *na = bignum_integer (iticks, ta.ticks); | 1123 | mpz_t const *na = bignum_integer (iticks, ta.ticks); |
| 1161 | mpz_mul (*iticks, *fb, *na); | 1124 | mpz_mul (*iticks, *fb, *na); |
| @@ -1303,7 +1266,7 @@ or (if you need time as a string) `format-time-string'. */) | |||
| 1303 | (Lisp_Object specified_time) | 1266 | (Lisp_Object specified_time) |
| 1304 | { | 1267 | { |
| 1305 | double t; | 1268 | double t; |
| 1306 | decode_lisp_time (specified_time, 0, 0, &t); | 1269 | decode_lisp_time (specified_time, false, 0, &t); |
| 1307 | return make_float (t); | 1270 | return make_float (t); |
| 1308 | } | 1271 | } |
| 1309 | 1272 | ||
| @@ -1702,7 +1665,7 @@ usage: (encode-time TIME &rest OBSOLESCENT-ARGUMENTS) */) | |||
| 1702 | 1665 | ||
| 1703 | /* Let SEC = floor (LT.ticks / HZ), with SUBSECTICKS the remainder. */ | 1666 | /* Let SEC = floor (LT.ticks / HZ), with SUBSECTICKS the remainder. */ |
| 1704 | struct lisp_time lt; | 1667 | struct lisp_time lt; |
| 1705 | decode_lisp_time (secarg, 0, <, 0); | 1668 | decode_lisp_time (secarg, false, <, 0); |
| 1706 | Lisp_Object hz = lt.hz, sec, subsecticks; | 1669 | Lisp_Object hz = lt.hz, sec, subsecticks; |
| 1707 | if (FASTER_TIMEFNS && EQ (hz, make_fixnum (1))) | 1670 | if (FASTER_TIMEFNS && EQ (hz, make_fixnum (1))) |
| 1708 | { | 1671 | { |
| @@ -1755,9 +1718,7 @@ Truncate the returned value toward minus infinity. | |||
| 1755 | If FORM is nil (the default), return the same form as `current-time'. | 1718 | If FORM is nil (the default), return the same form as `current-time'. |
| 1756 | If FORM is a positive integer, return a pair of integers (TICKS . FORM), | 1719 | If FORM is a positive integer, return a pair of integers (TICKS . FORM), |
| 1757 | where TICKS is the number of clock ticks and FORM is the clock frequency | 1720 | where TICKS is the number of clock ticks and FORM is the clock frequency |
| 1758 | in ticks per second. (Currently the positive integer should be at least | 1721 | in ticks per second. If FORM is t, return (TICKS . PHZ), where |
| 1759 | 65536 if the returned value is expected to be given to standard functions | ||
| 1760 | expecting Lisp timestamps.) If FORM is t, return (TICKS . PHZ), where | ||
| 1761 | PHZ is a suitable clock frequency in ticks per second. If FORM is | 1722 | PHZ is a suitable clock frequency in ticks per second. If FORM is |
| 1762 | `integer', return an integer count of seconds. If FORM is `list', | 1723 | `integer', return an integer count of seconds. If FORM is `list', |
| 1763 | return an integer list (HIGH LOW USEC PSEC), where HIGH has the most | 1724 | 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. */) | |||
| 1766 | (Lisp_Object time, Lisp_Object form) | 1727 | (Lisp_Object time, Lisp_Object form) |
| 1767 | { | 1728 | { |
| 1768 | struct lisp_time t; | 1729 | struct lisp_time t; |
| 1769 | enum timeform input_form = decode_lisp_time (time, 0, &t, 0); | 1730 | enum timeform input_form = decode_lisp_time (time, false, &t, 0); |
| 1770 | if (NILP (form)) | 1731 | if (NILP (form)) |
| 1771 | form = CURRENT_TIME_LIST ? Qlist : Qt; | 1732 | form = CURRENT_TIME_LIST ? Qlist : Qt; |
| 1772 | if (EQ (form, Qlist)) | 1733 | if (EQ (form, Qlist)) |