1. 19 Mar, 2020 2 commits
  2. 08 Mar, 2020 3 commits
  3. 03 Mar, 2020 2 commits
    • Paul Eggert's avatar
      Time division speedups · b48142ba
      Paul Eggert authored
      * src/timefns.c (frac_to_double) [FASTER_TIMEFNS]: Prefer intmax_t
      division or double division to mpz division if they also yield the
      correctly rounded result.
      b48142ba
    • Paul Eggert's avatar
      Fix rounding errors in time conversion · 5e229f88
      Paul Eggert authored
      * src/timefns.c (frac_to_double): Pass FLT_RADIX to mpz_sizeinbase
      instead of doing the radix calculation ourselves, not always
      correctly.  Fix off-by-one error in scale, which caused
      double-rounding.
      (decode_time_components): Use frac_to_double (via decode_ticks_hz)
      to fix double-rounding error that can occur even though
      intermediate results are long double.
      * test/src/timefns-tests.el (float-time-precision):
      Test the above fixes.
      5e229f88
  4. 02 Mar, 2020 1 commit
  5. 28 Feb, 2020 1 commit
  6. 01 Jan, 2020 1 commit
  7. 13 Nov, 2019 2 commits
    • Paul Eggert's avatar
      Fix double-rounding bug in ceiling etc. · bede5984
      Paul Eggert authored
      This is doable now that we have bignums.
      * src/floatfns.c (integer_value): Remove; no longer used.
      (rescale_for_division): New function.
      (rounding_driver): Use it to divide properly (by using bignums)
      even when arguments are float, fixing a double-rounding FIXME.
      * src/lisp.h (LOG2_FLT_RADIX): Move here ...
      * src/timefns.c (frac_to_double): ... from here.
      * test/src/floatfns-tests.el (big-round):
      Add a test to catch the double-rounding bug.
      bede5984
    • Paul Eggert's avatar
      Refactor double integer scaling · ff10e951
      Paul Eggert authored
      This doesn’t alter behavior, and simplifies a future commit.
      * src/floatfns.c (double_integer_scale): New function,
      with body adapted from the old timefns.c.
      * src/timefns.c (decode_float_time): Use it.
      ff10e951
  8. 15 Oct, 2019 1 commit
    • Robert Pluim's avatar
      Fix duplicated words in comments · eda38526
      Robert Pluim authored
      * src/coding.c (encode_string_utf_8):
      * src/keyboard.c (syms_of_keyboard):
      * src/mini-gmp.c (gmp_lucas_mod, mpz_export):
      * src/pdumper.c (dump_set_referrer, dump_queue_compute_score):
      * src/timefns.c (Ftime_convert): Remove duplicated words.
      eda38526
  9. 06 Oct, 2019 1 commit
    • Paul Eggert's avatar
      Improve documentation for year-zero issues · aadf7216
      Paul Eggert authored
      * doc/emacs/calendar.texi (Calendar Systems)
      * doc/lispref/os.texi (Time Conversion):
      Prefer "BC" to "B.C." since the documentation generally uses "BC".
      * doc/misc/emacs-mime.texi (time-date):
      * lisp/calendar/time-date.el (date-to-day, time-to-days):
      In the doc string, state the day origin more clearly, and more
      consistently with the rest of the documentation.
      * src/timefns.c (Fdecode_time): State the year origin in
      the doc string.
      aadf7216
  10. 30 Sep, 2019 1 commit
  11. 29 Sep, 2019 1 commit
  12. 24 Aug, 2019 1 commit
  13. 21 Aug, 2019 2 commits
    • Paul Eggert's avatar
      Be more careful about pointers to bignum vals · 39fee209
      Paul Eggert authored
      This uses ‘const’ to be better at catching bugs that
      mistakenly attempt to modify a bignum value.
      Lisp bignums are supposed to be immutable.
      * src/alloc.c (make_pure_bignum):
      * src/fns.c (sxhash_bignum):
      Accept Lisp_Object instead of struct Lisp_Bignum *, as that’s
      simpler now.  Caller changed.
      * src/bignum.h (bignum_val, xbignum_val): New inline functions.
      Prefer them to &i->value and XBIGNUM (i)->value, since they
      apply ‘const’ to the result.
      * src/timefns.c (lisp_to_timespec): Use mpz_t const *
      to point to a bignum value.
      39fee209
    • Paul Eggert's avatar
      Avoid some excess precision in time arithmetic · 396ed88a
      Paul Eggert authored
      * doc/misc/emacs-mime.texi (time-date):
      Adjust example to match new behavior.
      * etc/NEWS: Mention this.
      * lisp/calendar/time-date.el (decoded-time-add)
      (decoded-time--alter-second):
      Don’t lose underestimate precision of seconds component.
      * src/bignum.c (mpz): Grow by 1.
      * src/timefns.c (trillion_factor): New function.
      (timeform_sub_ps_p): Remove.
      (time_arith): Avoid unnecessarily-large hz, by reducing the hz
      to a value no worse than the worse hz of the two arguments.
      The result is always exact unless an error is signaled.
      * test/src/timefns-tests.el (timefns-tests--decode-time):
      New function.
      (format-time-string-with-zone): Test (decode-time LOOK ZONE t)
      resolution as well as its numeric value.
      396ed88a
  14. 20 Aug, 2019 2 commits
    • Paul Eggert's avatar
      Support larger TIMEs in (time-convert TIME t) · 5a955212
      Paul Eggert authored
      Also, improve the doc to match current behavior.
      * doc/lispref/os.texi (Time Conversion): Document that
      time-convert signals an error for infinite or NaN args,
      and that (time-convert TIME t) is exact otherwise.
      Mention float-time as an alternative to time-convert.
      (Time Calculations): Document that time-add and time-subtract
      are exact and do not decrease HZ below the minimum of their args.
      * src/timefns.c (decode_float_time): Don’t signal an error for
      floating-point arguments whose base-FLT_RADIX exponent is not less
      than DBL_MANT_DIG.  Instead, convert them to (TICKS . 1) values.
      Use two (instead of three) integer exponent comparisons in the
      typical case.
      * test/src/timefns-tests.el (time-arith-tests):
      Add more floating-point tests, including some tests
      that the old code fails.
      5a955212
    • Paul Eggert's avatar
      Fix time-add/time-sub validity checking · 2197ea89
      Paul Eggert authored
      * src/timefns.c (time_arith): Check the first arg for
      validity even if the second arg is not finite.
      * test/src/timefns-tests.el (time-arith-tests): Test this.
      2197ea89
  15. 18 Aug, 2019 1 commit
    • Paul Eggert's avatar
      Improve bignum_integer static checking · 780509f2
      Paul Eggert authored
      * src/bignum.h (bignum_integer): Now returns pointer-to-const,
      to catch trivial mistakes where the caller might try to modify
      a Lisp bignum.  Lisp bignums are supposed to be immutable.
      All callers changed.
      780509f2
  16. 17 Aug, 2019 3 commits
    • Paul Eggert's avatar
      Have time-add etc. respect CURRENT_TIME_LIST too · 743cc86a
      Paul Eggert authored
      * src/timefns.c (time_arith) [!CURRENT_TIME_LIST]:
      Don’t generate a list, since CURRENT_TIME_LIST is false.
      743cc86a
    • Paul Eggert's avatar
      More-compatible subsecond calendrical timestamps · 37257d6a
      Paul Eggert authored
      Instead of appending a subseconds member to the result of
      ‘decode-time’, this keeps the format unchanged unless you give
      a new optional argument to ‘decode-time’.  Also, the augmented
      format now puts the subsecond info in the SECONDS element, so
      the total number of elements is unchanged; this is more
      compatible with code that expects the traditional 9 elements,
      such as ‘(pcase decoded-time (`(,SEC ,MIN ,HOUR ,DAY ,MON
      ,YEAR ,DOW ,DST ,ZONE) ...) ...)’.
      * doc/lispref/os.texi, doc/misc/emacs-mime.texi, etc/NEWS:
      * lisp/net/soap-client.el (soap-decode-date-time):
      * lisp/simple.el (decoded-time):
      Document the new behavior.
      * lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
      * lisp/calendar/iso8601.el (iso8601-parse)
      (iso8601-parse-time, iso8601-parse-duration)
      (iso8601--decoded-time):
      * lisp/calendar/parse-time.el (parse-time-string):
      * lisp/calendar/time-date.el (decoded-time-add)
      (decoded-time--alter-second):
      * lisp/org/org.el (org-parse-time-string):
      * lisp/simple.el (decoded-time):
      * src/timefns.c (Fdecode_time, Fencode_time):
      * test/lisp/calendar/icalendar-tests.el:
      (icalendar--decode-isodatetime):
      * test/lisp/calendar/iso8601-tests.el (test-iso8601-date-years)
      (test-iso8601-date-dates, test-iso8601-date-obsolete)
      (test-iso8601-date-weeks, test-iso8601-date-ordinals)
      (test-iso8601-time, test-iso8601-combined)
      (test-iso8601-duration, test-iso8601-intervals)
      (standard-test-dates, standard-test-time-of-day-fractions)
      (standard-test-time-of-day-beginning-of-day)
      (standard-test-time-of-day-utc)
      (standard-test-time-of-day-zone)
      (standard-test-date-and-time-of-day, standard-test-interval):
      * test/lisp/calendar/parse-time-tests.el (parse-time-tests):
      * test/src/timefns-tests.el (format-time-string-with-zone)
      (encode-time-dst-numeric-zone):
      Revert recent changes that added a SUBSECS member to
      calendrical timestamps, since that component is no longer
      present (the info, if any, is now in the SECONDS member).
      * lisp/calendar/time-date.el (decoded-time-add)
      (decoded-time--alter-second):
      Support fractional seconds in the new form.  Simplify.
      * src/timefns.c (Fdecode_time): Support new arg FORM.
      (Fencode_time): Support subsecond resolution.
      * test/src/timefns-tests.el (format-time-string-with-zone)
      (decode-then-encode-time): Test subsecond calendrical timestamps.
      37257d6a
    • Paul Eggert's avatar
      Subtracting “now” from “now” should yield zero · f6dd46cb
      Paul Eggert authored
      * src/timefns.c (time_arith): Arrange for (time-subtract nil
      nil) to yield 0, to be consistent with (time-equal-p nil nil).
      * test/lisp/calendar/time-date-tests.el (test-time-since): New test.
      f6dd46cb
  17. 16 Aug, 2019 1 commit
    • Paul Eggert's avatar
      Fix time-add rounding bug · f9fd12a3
      Paul Eggert authored
      Without this fix, time arithmetic yielded results that were not
      mathematically accurate, even though the exact results were
      representable; for example, (time-add 0 1e-13) yielded a timestamp
      equal to 0 instead of to 1e-13.
      * lisp/timezone.el (timezone-time-from-absolute):
      Let time-add do its thing rather than using floating point
      internally, which has rounding errors.  We now have bignums and so
      don’t need floating point to avoid overflow issues.
      * src/timefns.c (timeform_sub_ps_p): New function.
      (time_arith): If either argument is a float, represent the
      result exactly instead of discarding sub-ps info.
      * test/lisp/timezone-tests.el (timezone-tests-time-from-absolute):
      Don’t assume (HI LO US PS) timestamp format.
      * test/src/emacs-module-tests.el (mod-test-add-nanosecond/valid):
      Don’t assume that time-add discards sub-ns info.
      * test/src/timefns-tests.el (time-rounding-tests):
      Add regression test to detect time-add rounding bug.
      f9fd12a3
  18. 15 Aug, 2019 1 commit
    • Paul Eggert's avatar
      Fix rounding errors with float timestamps · af82a624
      Paul Eggert authored
      When converting from float to (TICKS . HZ) form, do the
      conversion exactly.  When converting from (TICKS . HZ) form to
      float, round to even precisely.  This way, successfully
      converting a float to (TICKS . HZ) and back yields a value
      numerically equal to the original.
      * src/timefns.c (flt_radix_power_size): New constant.
      (flt_radix_power): New static var.
      (decode_float_time): Convert the exact numeric value rather
      than guessing TIMESPEC_HZ resolution.
      (s_ns_to_double): Remove; no longer needed.
      (frac_to_double): New function.
      (decode_ticks_hz): It is now the caller’s responsibility to
      pass a valid TICKS and HZ.  All callers changed.
      Use frac_to_double to round (TICKS . HZ) precisely.
      (decode_time_components): When decoding nil, use
      decode_ticks_hz since it rounds precisely.
      (syms_of_timefns): Initialize flt_radix_power.
      * test/src/timefns-tests.el (float-time-precision): New test.
      af82a624
  19. 06 Aug, 2019 2 commits
    • Paul Eggert's avatar
      decode-time now returns subsec too · b06917a4
      Paul Eggert authored
      The list that decode-time returns now contains an extra
      trailing component that counts the subseconds part of the
      original timestamp (Bug#36549).
      This builds on a suggestion by Lars Ingebrigtsen in:
      https://lists.gnu.org/r/emacs-devel/2019-07/msg00734.html
      * doc/lispref/os.texi (Time Conversion):
      * doc/misc/emacs-mime.texi (time-date):
      * etc/NEWS: Document this.
      * lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
      * lisp/calendar/iso8601.el (iso8601-parse)
      (iso8601-parse-time, iso8601-parse-duration)
      (iso8601--decoded-time):
      * lisp/calendar/parse-time.el (parse-time-string):
      * lisp/calendar/time-date.el (make-decoded-time)
      (decoded-time-set-defaults):
      * lisp/org/org.el (org-fix-decoded-time)
      (org-parse-time-string):
      * src/timefns.c (Fdecode_time):
      Generate subsec member for decoded time.
      * lisp/calendar/time-date.el (decoded-time-add)
      Add the decoded subsec too.
      * lisp/simple.el (decoded-time): New subsec member.
      * src/data.c (Frem): Simplify zero-check to match that of new Fmod.
      (integer_mod): New function, with most of the guts of the old Fmod.
      Remove redundant zero-check.
      (Fmod): Use it.
      * src/timefns.c (Fencode_time): Handle new subsec member
      or (with the obsolescent calling convention) subsec arg.
      It defaults to 0.
      * test/lisp/calendar/icalendar-tests.el:
      (icalendar--decode-isodatetime):
      * test/lisp/calendar/iso8601-tests.el (test-iso8601-date-years)
      (test-iso8601-date-dates, test-iso8601-date-obsolete)
      (test-iso8601-date-weeks, test-iso8601-date-ordinals)
      (test-iso8601-time, test-iso8601-combined)
      (test-iso8601-duration, test-iso8601-intervals)
      (standard-test-dates, standard-test-time-of-day-fractions)
      (standard-test-time-of-day-beginning-of-day)
      (standard-test-time-of-day-utc)
      (standard-test-time-of-day-zone)
      (standard-test-date-and-time-of-day, standard-test-interval):
      * test/lisp/calendar/parse-time-tests.el (parse-time-tests):
      * test/src/timefns-tests.el (format-time-string-with-zone)
      (encode-time-dst-numeric-zone):
      Adjust to match new behavior.
      b06917a4
    • Paul Eggert's avatar
      New function time-convert · 89c63b35
      Paul Eggert authored
      This replaces the awkward reuse of encode-time to both convert
      calendrical timestamps to Lisp timestamps, and to convert Lisp
      timestamps to other forms.  Now, encode-time does just the
      former and the new function does just the latter.
      The new function builds on a suggestion by Lars Ingebrigtsen in:
      https://lists.gnu.org/r/emacs-devel/2019-07/msg00801.html
      and refined by Stefan Monnier in:
      https://lists.gnu.org/r/emacs-devel/2019-07/msg00803.html
      * doc/lispref/os.texi (Time of Day, Time Conversion):
      * doc/misc/emacs-mime.texi (time-date):
      * etc/NEWS: Update documentation.
      * lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
      * lisp/calendar/time-date.el (seconds-to-time, days-to-time):
      * lisp/calendar/timeclock.el (timeclock-seconds-to-time):
      * lisp/cedet/ede/detect.el (ede-detect-qtest):
      * lisp/completion.el (cmpl-hours-since-origin):
      * lisp/ecomplete.el (ecomplete-add-item):
      * lisp/emacs-lisp/cl-extra.el (cl--random-time):
      * lisp/emacs-lisp/timer.el (timer--time-setter)
      (timer-next-integral-multiple-of-time):
      * lisp/find-lisp.el (find-lisp-format-time):
      * lisp/gnus/gnus-diary.el (gnus-user-format-function-d):
      * lisp/gnus/gnus-group.el (gnus-group-set-timestamp):
      * lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda):
      * lisp/gnus/nnrss.el (nnrss-normalize-date):
      * lisp/gnus/nnspool.el (nnspool-request-newgroups):
      * lisp/net/ntlm.el (ntlm-compute-timestamp):
      * lisp/net/pop3.el (pop3-uidl-dele):
      * lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
      * lisp/org/org-clock.el (org-clock-get-clocked-time)
      (org-clock-resolve, org-resolve-clocks, org-clock-in)
      (org-clock-out, org-clock-sum):
      * lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
      * lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
      * lisp/proced.el (proced-format-time):
      * lisp/progmodes/cc-cmds.el (c-progress-init)
      (c-progress-update):
      * lisp/progmodes/cperl-mode.el (cperl-time-fontification):
      * lisp/progmodes/flymake.el (flymake--schedule-timer-maybe):
      * lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
      (vhdl-fix-case-region-1):
      * lisp/tar-mode.el (tar-octal-time):
      * lisp/time.el (emacs-uptime):
      * lisp/url/url-auth.el (url-digest-auth-make-cnonce):
      * lisp/url/url-util.el (url-lazy-message):
      * lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
      * lisp/vc/vc-hg.el (vc-hg-state-fast):
      * lisp/xt-mouse.el (xterm-mouse-event):
      * test/lisp/emacs-lisp/timer-tests.el:
      (timer-next-integral-multiple-of-time-2):
      Use time-convert, not encode-time.
      * lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
      Don’t use now-removed FORM argument for encode-time.
      It wasn’t crucial anyway.
      * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add time-convert.
      * lisp/emacs-lisp/elint.el (elint-unknown-builtin-args):
      Update encode-time signature to match current arg set.
      * lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
      Use timer-convert with t rather than doing it by hand.
      * src/timefns.c (time_hz_ticks, time_form_stamp, lisp_time_form_stamp):
      Remove; no longer needed.
      (decode_lisp_time): Rturn the form instead of having a *PFORM arg.
      All uses changed.
      (time_arith): Just return TICKS if HZ is 1.
      (Fencode_time): Remove argument FORM.  All callers changed.
      Do not attempt to encode time values; just encode
      decoded (calendrical) times.
      Unless CURRENT_TIME_LIST, just return VALUE since HZ is 1.
      (Ftime_convert): New function, which does the time value
      conversion that bleeding-edge encode-time formerly did.
      Return TIME if it is easy to see that it is already
      of the correct form.
      (Fcurrent_time): Mention in doc that the form is planned to change.
      * test/src/timefns-tests.el (decode-then-encode-time):
      Don’t use (encode-time nil).
      89c63b35
  20. 04 Aug, 2019 1 commit
    • Paul Eggert's avatar
      Tweak time arithmetic performance · 7748ef21
      Paul Eggert authored
      * src/timefns.c (lispint_arith): New function, which
      should be a bit faster if B is 0, or if A is a bignum
      and B a fixnum with absolute value in unsigned long range.
      (time_arith): Use it.
      7748ef21
  21. 29 Jul, 2019 1 commit
    • Lars Ingebrigtsen's avatar
      Add support for dealing with decoded time structures · 6cfda69d
      Lars Ingebrigtsen authored
      * doc/lispref/os.texi (Time Conversion): Document the new
      functions that work on decoded time.
      (Time Calculations): Document new date/time functions.
      
      * lisp/simple.el (decoded-time-second, decoded-time-minute)
      (decoded-time-hour, decoded-time-day, decoded-time-month)
      (decoded-time-year, decoded-time-weekday, decoded-time-dst)
      (decoded-time-zone): New accessor functions for decoded time values.
      
      * lisp/calendar/time-date.el (date-days-in-month)
      (date-ordinal-to-time): New functions.
      (decoded-time--alter-month, decoded-time--alter-day)
      (decoded-time--alter-second, make-decoded-time): New functions
      added to manipulate decoded time structures.
      
      * src/timefns.c (Fdecode_time): Mention the new accessors.
      
      * test/lisp/calendar/time-date-tests.el: New file to test the
      decoded time functions and the other new functions.
      6cfda69d
  22. 07 Jul, 2019 1 commit
    • Paul Eggert's avatar
      Remove printmax_t etc. · 8f522efe
      Paul Eggert authored
      printmax_t etc. were needed only for platforms that lacked
      support for printing intmax_t.  These platforms are now so
      obsolete that they are no longer practical porting targets.
      * src/image.c (gs_load): Fix unlikely buffer overrun
      discovered while making these changes.  It was introduced in
      2011-07-17T00:34:43!eggert@cs.ucla.edu.
      * src/lisp.h (printmax_t, uprintmax_t, pMd, pMu, pMx):
      Remove.  All uses replaced by their standard counterparts
      intmax_t, uintmax_t, PRIdMAX, PRIuMAX, PRIxMAX.
      8f522efe
  23. 30 Apr, 2019 1 commit
    • Paul Eggert's avatar
      Fix decode-time/encode-time roundtrip on macOS · 325f51c8
      Paul Eggert authored
      * src/timefns.c (Fencode_time): Ignore DST flag when the zone is
      numeric or is a cons, as the doc string says it’s ignored in that
      case, and not ignoring it causes encode-time to not invert
      decode-time on some platforms (Bug#35502).
      * test/src/timefns-tests.el (encode-time-dst-numeric-zone):
      New test.
      325f51c8
  24. 24 Apr, 2019 2 commits
    • Eli Zaretskii's avatar
      Fix a typo in a recent commit · a2e9d3e3
      Eli Zaretskii authored
      * src/timefns.c (timespec_to_lisp): Fix a typo in function
      definition.
      a2e9d3e3
    • Philipp Stephani's avatar
      Fix return type of make_time. · 534c33cf
      Philipp Stephani authored
      make_time is documented to return a (TICKS . HZ) pair, so we can’t use
      make_lisp_time.  Introduce a new conversion function instead.
      
      * src/emacs-module.c (module_make_time): Use timespec_to_lisp to
      correct return type.
      
      * src/timefns.c (timespec_to_lisp): New function.
      (make_lisp_time): Use it.
      
      * test/src/emacs-module-tests.el (mod-test-add-nanosecond/valid):
      Check return type.
      534c33cf
  25. 18 Apr, 2019 1 commit
    • Paul Eggert's avatar
      Mark _Noreturn error functions as cold · 6d6c55db
      Paul Eggert authored
      On my platform this made ‘make compile-always’ 1.3% faster.
      Suggested by Alex Gramiak in:
      https://lists.gnu.org/r/emacs-devel/2019-04/msg00684.html
      * configure.ac (nw): Don’t use -Wsuggest-attribute=cold.
      * lib-src/make-docfile.c (write_globals):
      Mark noreturn functions as cold.
      * src/callproc.c (exec_failed):
      * src/data.c (wrong_length_argument, wrong_type_argument):
      * src/emacs-module.c (module_abort):
      * src/emacs.c (terminate_due_to_signal):
      * src/eval.c (unwind_to_catch):
      * src/image.c (my_png_error, my_error_exit):
      * src/json.c (json_out_of_memory, json_parse_error):
      * src/keyboard.c (quit_throw_to_read_char, user_error):
      * src/lisp.h (die, wrong_type_argument, wrong_choice)
      (args_out_of_range, args_out_of_range_3, circular_list)
      (buffer_overflow, memory_full, buffer_memory_full)
      (string_overflow, xsignal, xsignal0, xsignal1, xsignal2)
      (xsignal3, signal_error, overflow_error, error, verror)
      (nsberror, report_file_errno, report_file_error)
      (report_file_notify_error, terminate_due_to_signal)
      (emacs_abort, fatal):
      * src/lread.c (load_error_old_style_backquotes)
      (end_of_file_error, invalid_syntax):
      * src/pdumper.c (error_unsupported_dump_object):
      * src/puresize.h (pure_write_error):
      * src/search.c (matcher_overflow):
      * src/sound.c (sound_perror, alsa_sound_perror):
      * src/sysdep.c (handle_arith_signal):
      * src/systime.h (time_overflow):
      * src/term.c (maybe_fatal, vfatal):
      * src/textprop.c (text_read_only):
      * src/timefns.c (invalid_time_zone_specification)
      (time_error, invalid_hz):
      * src/xterm.c (x_connection_closed):
      Use AVOID instead of _Noreturn void, so that it’s marked cold.
      * src/conf_post.h (__has_attribute_cold) [!__has_attribute]:
      New macro.
      (ATTRIBUTE_COLD): New macro.
      * src/frame.h (WINDOW_SYSTEM_RETURN): Add ATTRIBUTE_COLD.
      * src/lisp.h (AVOID): New macro.
      * src/xterm.c: Omit unnecessary static decls, so that we needn’t
      worry about which functions should be marked cold.
      (x_io_error_quitter): Mark as cold.
      6d6c55db
  26. 22 Mar, 2019 1 commit
    • Stefan Monnier's avatar
      Fix misuses of NULL when talking about the NUL character · 76fea1eb
      Stefan Monnier authored
      * lisp/subr.el (inhibit-null-byte-detection): Make it an obsolete alias.
      
      * src/coding.c (setup_coding_system): Use new name.
      (detect_coding): Rename null_byte_found => nul_byte_found.
      (detect_coding_system): Use new name.
      Rename null_byte_found => nul_byte_found.
      (Fdefine_coding_system_internal): Use new name.
      (syms_of_coding): Rename inhibit-null-byte-detection to
      inhibit-nul-byte-detection.
      * src/w16select.c (get_clipboard_data): null_char => nul_char.
      * src/json.c (check_string_without_embedded_nuls): Rename from
      check_string_without_embedded_nulls.
      (Fjson_parse_string): Adjust accordingly.
      * src/coding.h (enum define_coding_undecided_arg_index)
      (enum coding_attr_index): ...null_byte... => ...nul_byte....
      * lisp/info.el (info-insert-file-contents, Info-insert-dir):
      * lisp/international/mule.el (define-coding-system):
      * lisp/vc/vc-git.el (vc-git--call):
      * doc/lispref/nonascii.texi (Lisp and Coding Systems): Use the new name.
      76fea1eb
  27. 25 Feb, 2019 1 commit
  28. 01 Feb, 2019 1 commit
    • Paul Eggert's avatar
      Rename CANNOT_DUMP to HAVE_UNEXEC · 3b69e02a
      Paul Eggert authored
      * configure.ac (CANNOT_DUMP): Remove.  All uses removed,
      or changed to the negative of with_unexec.
      (HAVE_UNEXEC): New macro.  All uses of CANNOT_DUMP changed
      to the negative of this macro.
      3b69e02a
  29. 15 Jan, 2019 1 commit
    • Daniel Colascione's avatar
      Add portable dumper · d12e5d00
      Daniel Colascione authored
      Add a new portable dumper as an alternative to unexec.  Use it by default.
      
      * src/dmpstruct.awk: New file.
      * src/doc.c (get_doc_string): use will_dump_p().
      * src/editfns.c (styled_format): silence compiler warning
      with UNINIT.
      * src/emacs-module.c (syms_of_module): staticpro ltv_mark.
      * src/emacs.c (gflags): new variable.
      (init_cmdargs): unwrap
      (string_starts_with_p, find_argument, dump_error_to_string)
      (load_pdump): new functions.
      (main): detect pdumper and --temacs invocation; actually load
      portable dump when detected; set gflags as appropriate; changes to
      init functions throughout to avoid passing explicit
      'initialized' argument.
      * src/eval.c (inhibit_lisp_code): remove unused variable.
      (init_eval_once_for_pdumper): new function.
      (init_eval_once): call it.
      * src/filelock.c: CANNOT_DUMP -> will_dump_p()
      * src/fingerprint-dummy.c: new file
      * src/fingerprint.h: new file
      * src/fns.c: CANNOT_DUMP -> will_dump_p(), etc.
      (weak_hash_tables): remove
      (hashfn_equal, hashfn_eql): un-staticify
      (make_hash_table): set new 'next_weak' hash table field; drop
      global weak_hash_tables logic.
      (copy_hash_table): drop global weak_hash_tables logic.
      (hash_table_rehash): new function.
      (hash_lookup, hash_put, hash_remove_from_table, hash_clear):
      rehash if needed.
      (sweep_weak_table): un-staticify; explain logic; bool-ify.
      (sweep_weak_hash_tables): remove function.
      * src/font.c (syms_of_font): remember pdumper stuff.
      * src/fontset.c (syms_of_fontset): remember pdumper stuff.
      * src/frame.c (make_initial_frame): don't reset Vframe_list.
      (init_frame_once_for_pdumper, init_frame_once): new functions.
      (syms_of_frame): remove redundant staticpro.
      * src/fringe.c (init_fringe_once_for_pdumper): new functin.
      (init_fringe_once): call it.
      * src/ftcrfont.c (syms_of_ftcrfont_for_pdumper): new function.
      (syms_of_ftcrfont): call it.
      * src/ftfont.c (syms_of_ftfont_for_pdumper): new function.
      (syms_of_ftfont): call it.
      * src/ftxont.c (syms_of_ftxfont_for_pdumper): new function.
      (syms_of_ftxfont): call it.
      * src/gmalloc.c: adjust for pdumper througout
      (DUMPED): remove weird custom dumped indicator.
      * src/gnutls.c (syms_of_gnutls): pdumper note for
      gnutls_global_initialized.
      * src/image.c (syms_of_image): add pdumper comment,
      initializer note.
      * src/insdel.c (prepare_to_modify_buffer_1): account
      for buffer contents possibly being in dump image.
      * src/keyboard.c (syms_of_keyboard_for_pdumper): new function.
      (syms_of_keyboard): staticpro more; call pdumper syms function.
      * src/lisp.h: add comments throughout
      (gflags): declare.
      (will_dump_p, will_bootstrap_p, will_dump_with_pdumper_p)
      (dumped_with_pdumper_p, will_dump_with_unexec_p)
      (dumped_with_unexec_p, definitely_will_not_unexec_p): new
      functions.
      (POWER_OF_2, ROUNDUP): move macros.
      (PSEUDOVECTOR_TYPE, PSEUDOVECTOR_TYPEP): take vectorlike header
      pointer instead of vector; constify.
      (Lisp_Hash_Table): add comment about need to rehash on access; add
      comment for next_weak.
      (HASH_KEY, HASH_VALUE, HASH_HASH, HASH_TABLE_SIZE): const-ify.
      (hash_table_rehash): declare.
      (hash_rehash_needed_p, hash_rehash_if_needed): new functions.
      (finalizers, doomed_finalizers): declare extern.
      (SUBR_SECTION_ATTRIBUTE): new macro.
      (staticvec, staticidx): un-static-ify.
      (sweep_weak_hash_tables): remove declaration.
      (sweep_weak_table): declare.
      (hashfn_eql, hashfn_equal): declare.
      (number_finalizers_run): new variable.
      (Vdead): externify when ENABLE_CHECKING.
      (gc_root_type): new enumeration.
      (gc_root_visitor): new struct.
      (visit_static_gc_roots): declare.
      (vectorlike_nbytes): declare.
      (vector_nbytes): define as trivial inline function wrapper for
      vectorlike_nbytes.
      (init_obarray_once): change signature.
      (primary_thread): extern-ify.
      (init_buffer): change signature.
      (init_frame_once): declare.
      * src/lread.c (readevalloop): adjust for new dumped predicates.
      (init_obarray_once): new function.
      (ndefsubr): new variable.
      (defsubr): increment it.
      (load_path_check): adjust for pdumper.
      (load_path_default): use pdumper functions; adjust for
      dump search.
      * src/macfont.m (macfont_init_font_change_handler): avoid
      shadowing global.
      (syms_of_macfont_for_pdumper): new function.
      (syms_of_macfont): call it.
      * src/menu.c (syms_of_menu): staticpro more stuff.
      * src/minibuf.c (Ftry_completion): rehash if needed.
      (init_minibuf_once_for_pdumper): new function.
      (init_minibuf_once): call it.
      * src/nsfont.m (syms_of_nsfns): staticpro more.
      * src/nsfont.m (syms_of_nsfont_for_pdumper): new function.
      (syms_of_nsfont): call it.
      * src/nsterm.m (syms_of_nsfont): remember pdumper stuff.
      * src/pdumper.c: new file.
      * src/pdumper.h: new file.
      * src/process.c (init_process_emacs): use new pdumper functions
      instead of CANNOT_DUMP.
      * src/profiler.c (syms_of_profiler_for_pdumper): new function.
      (syms_of_profiler_for_pdumper): call it.
      * src/search.c (syms_of_search_for_pdumper): new function.
      (syms_of_search_for_pdumper): call it.
      * src/sheap.c (bss_sbrk_did_unexec): remove.
      * src/sheap.h (bss_sbrk_did_unexec): remove.
      * src/syntax.c (syms_of_syntax): don't redundantly staticpro
      re_match_object.
      * src/sysdep.c: use will_dump_with_unexec_p() instead of bss
      hack thing.
      * src/syssignals.h (init_sigsegv): declare.
      * src/systime.h (init_timefns): remove bool from signature.
      * src/textprop.c (syms_of_textprop): move staticpro.
      * src/thread.c (main_thread_p): constify.
      * src/thread.h (main_thread_p): constify.
      * src/timefns.c (init_timefns): remove bool from signature.
      (syms_of_timefns_for_pdumper): new function.
      (syms_of_timefns): call it.
      * src/w32.c: rearrange code.
      * src/w32.h (w32_relocate): declare.
      * src/w32fns.c (syms_of_w32fns): add pdumper note.
      * src/w32font.c (syms_of_w32font_for_pdumper): new function.
      (syms_of_w32font): call it.
      * src/w32heap.c (using_dynamic_heap): new variable.
      (init_heap): use it.
      * src/w32menu.c (syms_of_w32menu): add pdumper note.
      * src/w32proc.c
      (ctrl_c_handler, mainCRTStartup, _start, open_input_file)
      (rva_to_section, close_file_data): move here.
      * src/w32uniscribe.c (syms_of_w32uniscribe_for_pdumper):
      new function.
      (syms_of_w32uniscribe): call it.
      * src/window.c (init_window_once_for_pdumper): new function.
      (init_window_once): call it; staticpro more stuff.
      * src/xfont.c (syms_of_xfont_for_pdumper): new function.
      (syms_of_xfont): call it.
      * src/xftfont.c (syms_of_xftfont_for_pdumper): new function.
      (syms_of_xftfont): call it.
      * src/xmenu.c (syms_of_xmenu_for_pdumper): new function.
      (syms_of_xmenu): call it.
      * src/xselect.c (syms_of_xselect_for_pdumper): new function.
      (syms_of_xselect): call it.
      * src/xsettings.c (syms_of_xsettings): add more pdumper notes.
      * src/term.c (syms_of_xterm): add pdumper note.
      
      * src/dispnew.c (init_faces_initial): new function.
      (init_display_interactive): rename from init_display; use
      will_dump_p instead of !initialized.  Initialize faces early for
      pdumper if needed.
      (init_display): new function.
      (syms_of_display_for_pdumper): new function.
      (syms_of_display): call it.
      
      * src/dbusbind.c (syms_of_dbusbind): Add TODO for bus reset
      on pdumper load.
      
      * src/data.c (Fdefalias): Use will_dump_p
      instead of Vpurify_flag.
      (Fmake_variable_buffer_local): silence compiler warning with -Og
      by making valcontents UNINIT.
      (arith_driver): silence compiler warning with UNINIT.
      
      * src/conf_post.h (ATTRIBUTE_SECTION): new macro.
      
      * src/composite.c (composition_gstring_put_cache): rehash hash
      table if needed.
      
      * src/coding.c (init_coding_once, syms_of_coding): remember
      pdumper stuff.
      
      * src/charset.h (charset_table_size, charset_table_user): declare.
      
      * src/charset.c (charset_table_used, charset_table_size): un-static.
      (init_charset_oncem, syms_of_charset): remember pdumper stuff.
      
      * src/category.c (category_table_version): remove obsolete
      variable.
      
      * src/callint.c (syms_of_callint): staticpro 'preserved_fns'
      (init_callproc): use will_dump_p instead of !CANNOT_DUMP.
      
      * src/bytecode.c (exec_byte_code): rehash table tables if needed
      
      * src/buffer.c (alloc_buffer_text, free_buffer_text): account for
      pdumper
      (init_buffer_once): add TODO; remember stuff for pdumper.
      (init_buffer): don't take initialized argument; adjust
      for pdumper.
      
      * src/atimer.c (init_atimer): initialize subr only if
      !initialized.
      
      * src/alloc.c: (vector_marked_p, set_vector_marked)
      (vectorlike_marked_p, set_vectorlike_marked, cons_marked_p)
      (set_cons_marked, string_marked_p, set_string_marked)
      (symbol_marked_p, set_symbol_marked, interval_marked_p)
      (set_interval_marked): new accessor routines.  Use them
      instead of raw GC access throughout.
      (Vdead): make non-static when ENABLE_CHECKING.
      (vectorlike_nbytes): rename of 'vector_nbytes'; take a vectorlike
      header as input instead of a vector.
      (number_finalizers_run): new internal C variable.
      (mark_maybe_object): check for pdumper objects.
      (valid_pointer_p): don't be gratuitously inefficient under rr(1).
      (make_pure_c_string): add support for size_byte = -2 mode
      indicating that string data points into Emacs image rodata.
      (visit_vectorlike_root): visits GC roots embedded in
      vectorlike objects.
      (visit_buffer_root): visits GC roots embedded in
      our totally-not-a-buffer buffer global objects.
      (visit_static_gc_roots): visit GC roots in the Emacs data section.
      (mark_object_root_visitor): root callback used for conventional GC
      marking
      (weak_hash_tables): new internal variable for tracking found weak
      hash tables during GC.
      (mark_and_sweep_weak_table_contents): new weak hash table marking.
      (garbage_collect_1): use new GC root visitor machinery.
      (mark_vectorlike): accept a vectorlike_header instead of a
      Lisp_Vector.
      (mark_frame, mark_window, mark_hash_table): new functions.
      (mark_object): initialize 'm'; check for pdumper objects and use
      new mark-bit accessors throughout.  Remove some object-specific
      marking code and move to helper functions above.
      (survives_gc_p): check for pdumper objects.
      (gc-sweep): clear pdumper mark bits.
      (init_alloc_once_for_pdumper): new helper function for early init
      called both during normal init and pdumper load.
      (init_alloc_once): pdumper integration.
      
      * src/Makefile.in: Rewrite dumping for pdumper; add pdumper.o;
      invoke temacs with --temacs command line option; build dmpstruct.h
      from dmpstruct.awk; stop relying on CANNOT_DUMP; clean up pdumper
      intermediate files during build.
      
      * nextstep/Makefile.in: build emacs.pdmp into NS packages
      
      * lisp/startup.el: account for new '--temacs' and '--dump-file'
      command line option.
      
      * lisp/loadup.el: rewrite early init to account for pdumper; use
      injected 'dump-mode' variable (set via the new '--temacs' option)
      instead of parsing command line.
      
      * lisp/cus-start.el: Check 'dump-mode' instead of 'purify-flag',
      since the new 'dump-mode'
      
      * lib-src/make-fingerprint.c: new program
      
      * lib-src/Makefile.in: built make-fingerprint utility program
      
      * configure.ac: Add --with-pdumper toggle to control pdumper
      support; add --with-unexec toggle to control unexec support.
      Add --with-dumping option to control which dumping strategy we use
      by default.  Adjust for pdumper throughout.  Check for
      posix_madvise.
      
      * Makefile.in: Add @DUMPING@ substitution; add pdumper mode.
      
      * .gitignore: Add make-fingerprint, temacs.in, fingerprint.c,
      dmpstruct.h, and pdumper dump files.
      d12e5d00