1. 27 Nov, 2020 1 commit
    • Philipp Stephani's avatar
      Fix incorrect handling of module runtime and environment pointers. · 23974cfa
      Philipp Stephani authored
      We used to store module runtime and environment pointers in the static
      lists Vmodule_runtimes and Vmodule_environments.  However, this is
      incorrect because these objects have to be kept per-thread.  With this
      naive approach, interleaving module function calls in separate threads
      leads to environments being removed in the wrong order, which in turn
      can cause local module values to be incorrectly garbage-collected.
      The fix isn't completely trivial: specbinding the lists wouldn't work
      either, because then the garbage collector wouldn't find the
      environments in other threads than the current ones, again leading to
      objects being garbage-collected incorrectly.  While introducing custom
      pseudovector types would fix this, it's simpler to put the runtime and
      environment pointers into the specbinding list as new specbinding
      kinds.  This works since we need to unwind them anyway, and we only
      ever treat the lists as a stack.  The thread switching machinery
      ensures that the specbinding lists are thread-local, and that all
      elements of the specbinding lists in all threads are marked during
      garbage collection.
      
      Module assertions now have to walk the specbinding list for the
      current thread, which is more correct since they now only find
      environments for the current thread.  As a result, we can now remove
      the faulty Vmodule_runtimes and Vmodule_environments variables
      entirely.
      
      Also add a unit test that exemplifies the problem.  It interleaves two
      module calls in two threads so that the first call ends while the
      second one is still active.  Without this change, this test triggers
      an assertion failure.
      
      * src/lisp.h (enum specbind_tag): Add new tags for module runtimes and
      environments.
      
      * src/eval.c (record_unwind_protect_module): New function to record a
      module object in the specpdl list.
      (do_one_unbind): Unwind module objects.
      (backtrace_eval_unrewind, default_toplevel_binding, lexbound_p)
      (Fbacktrace__locals): Deal with new specbinding types.
      (mark_specpdl): Mark module environments as needed.
      
      * src/alloc.c (garbage_collect): Remove call to 'mark-modules'.
      Garbage collection of module values is now handled as part of marking
      the specpdl of each thread.
      
      * src/emacs-module.c (Fmodule_load, funcall_module): Use specpdl to
      record module runtimes and environments.
      (module_assert_runtime, module_assert_env, value_to_lisp): Walk
      through specpdl list instead of list variables.
      (mark_module_environment): Rename from 'mark_modules'.  Don't attempt
      to walk though current thread's environments only, since that would
      miss other threads.
      (initialize_environment, finalize_environment): Don't change
      Vmodule_environments variable; environments are now in the specpdl
      list.
      (finalize_environment_unwind, finalize_runtime_unwind): Make 'extern'
      since do_one_unbind now calls them.
      (finalize_runtime_unwind): Don't change Vmodule_runtimes variable;
      runtimes are now in the specpdl list.
      (syms_of_module): Remove Vmodule_runtimes and Vmodule_environments.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_funcall): New test
      function.
      (emacs_module_init): Bind it.
      
      * test/src/emacs-module-tests.el (emacs-module-tests--variable): New
      helper type to guard access to state in a thread-safe way.
      (emacs-module-tests--wait-for-variable)
      (emacs-module-tests--change-variable): New helper functions.
      (emacs-module-tests/interleaved-threads): New unit test.
      23974cfa
  2. 23 Oct, 2020 1 commit
    • Stefan Kangas's avatar
      Move some test data to follow our conventions · 49bc8586
      Stefan Kangas authored
      * test/data/emacs-module/mod-test.c: Move from here...
      * test/src/emacs-module-resources/mod-test.c: ...to here.
      * test/src/emacs-module-tests.el (ert-x): Require.
      (mod-test-file, module/describe-function-1):
      * test/Makefile.in (test_module_dir): Adjust for move.
      
      * test/data/files-bug18141.el.gz: Move from here...
      * test/lisp/files-resources/files-bug18141.el.gz: ... to here.
      * test/lisp/files-tests.el (ert-x): Require.
      (files-test-bug-18141-file): Use ert-resource-file.
      
      * test/data/mailcap/mime.types: Move from here...
      * test/lisp/net/mailcap-resources/mime.types: ...to here.
      * test/lisp/net/mailcap-tests.el (ert-x): Require.
      (mailcap-tests-path): Use ert-resource-file.
      
      * test/data/somelib.el:
      * test/data/somelib2.el: Move from here...
      * test/src/lread-resources/somelib.el:
      * test/src/lread-resources/somelib2.el: ...to here.
      * test/src/lread-tests.el (ert, ert-x): Require.
      (lread-test-bug26837): Use ert-resource-directory.
      
      * test/data/syntax-comments.txt: Move from here....
      * test/src/syntax-resources/syntax-comments.txt: ...to here.
      * test/src/syntax-tests.el (ert-x): Require.
      (syntax-comments, syntax-br-comments, syntax-pps-comments):
      Use ert-resource-file.
      
      * test/data/xref/file1.txt:
      * test/data/xref/file2.txt: Move from here...
      * test/lisp/progmodes/xref-resources/file1.txt:
      * test/lisp/progmodes/xref-resources/file2.txt: ...to here.
      * test/lisp/progmodes/xref-tests.el (ert, ert-x): Require.
      (xref-tests-data-dir): Use ert-resource-directory.
      49bc8586
  3. 13 Oct, 2020 1 commit
    • Lars Ingebrigtsen's avatar
      Allow creating unibyte strings from Emacs modules · 12175a33
      Lars Ingebrigtsen authored
      * doc/lispref/internals.texi (Module Values): Document
      make_unibyte_string (bug#34873).
      
      * src/emacs-module.c (module_make_unibyte_string): New function.
      (initialize_environment): Export it.
      
      * src/module-env-25.h: Define it.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_return_unibyte):
      Test it.
      
      * test/src/emacs-module-tests.el (module/unibyte): Test it.
      12175a33
  4. 25 Sep, 2020 1 commit
  5. 13 Sep, 2020 1 commit
    • Philipp Stephani's avatar
      Add facility to make module functions interactive (Bug#23486). · da0e75e7
      Philipp Stephani authored
      * src/module-env-28.h: Add field for 'make_interactive' function.
      
      * src/emacs-module.c (Lisp_Module_Function): Add new field holding the
      interactive form.
      (allocate_module_function): Adapt to structure layout change.
      (module_make_interactive, module_function_interactive_form): New
      functions.
      (initialize_environment): Use them.
      
      * src/eval.c (Fcommandp):
      * src/data.c (Finteractive_form): Also handle interactive module
      functions.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_identity): New test
      function.
      (emacs_module_init): Create two interactive module test functions.
      
      * test/src/emacs-module-tests.el (module/interactive/return-t)
      (module/interactive/return-t-int, module/interactive/identity):
      New unit tests.
      
      * doc/lispref/internals.texi (Module Functions): Document new
      function.  Rework paragraph about wrapping module functions, as the
      example no longer applies.
      
      * etc/NEWS: Document new facility.
      da0e75e7
  6. 12 Sep, 2020 1 commit
    • Glenn Morris's avatar
      Adapt some tests for Emacs's excitingly variable quoting format · 3e073520
      Glenn Morris authored
      * test/lisp/subr-tests.el (subr-test-version-parsing):
      * test/lisp/emacs-lisp/gv-tests.el (gv-dont-define-expander-other-file):
      * test/src/callint-tests.el (call-interactively/incomplete-multibyte-sequence):
      * test/src/emacs-module-tests.el (module/describe-function-1):
      Don't fail if curly quotes are in use, as they can be if LC_ALL != C.
      3e073520
  7. 13 Aug, 2020 1 commit
  8. 26 Jul, 2020 3 commits
    • Philipp Stephani's avatar
      Add another test for global module references · 73a2f510
      Philipp Stephani authored
      * test/src/emacs-module-tests.el (mod-test-globref-reordered): New
      unit test.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_globref_reordered): New
      test module function.
      (emacs_module_init): Export it.
      73a2f510
    • Philipp Stephani's avatar
      Backport: add another test case for module assertions. · 3838aeb7
      Philipp Stephani authored
      This backports commit 9f01ce63 from master.  Since the bug isn’t
      present on emacs-27, just backport the new test case.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_globref_invalid_free):
      New test module function.
      (emacs_module_init): Export it.
      
      * test/src/emacs-module-tests.el
      (module--test-assertions--globref-invalid-free): New unit test.
      3838aeb7
    • Philipp Stephani's avatar
      Backport: Add module test for edge case. · bde5f5f8
      Philipp Stephani authored
      This backports commit 6355a3ec from master.  Since the bug isn’t
      present in emacs-27, just backport the test case.
      
      * test/data/emacs-module/mod-test.c
      (Fmod_test_invalid_store_copy): New test module function.
      (emacs_module_init): Export it.
      
      * test/src/emacs-module-tests.el
      (module--test-assertions--load-non-live-object-with-global-copy):
      New unit test.
      bde5f5f8
  9. 25 Jul, 2020 2 commits
    • Philipp Stephani's avatar
      Make checking for liveness of global values more precise. · 9f01ce63
      Philipp Stephani authored
      We can't just use a hash lookup because a global and a local reference
      might refer to the same Lisp object.
      
      * src/emacs-module.c (module_free_global_ref): More precise check for
      global liveness.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_globref_invalid_free):
      New test module function.
      (emacs_module_init): Export it.
      
      * test/src/emacs-module-tests.el
      (module--test-assertions--globref-invalid-free): New unit test.
      9f01ce63
    • Philipp Stephani's avatar
      Fix subtle bug when checking liveness of module values. · 6355a3ec
      Philipp Stephani authored
      We can't simply look up the Lisp object in the global reference table
      because an invalid local and a valid global reference might refer to
      the same object.  Instead, we have to test the address of the global
      reference against the stored references.
      
      * src/emacs-module.c (module_global_reference_p): New helper function.
      (value_to_lisp): Use it.
      
      * test/data/emacs-module/mod-test.c
      (Fmod_test_invalid_store_copy): New test module function.
      (emacs_module_init): Export it.
      
      * test/src/emacs-module-tests.el
      (module--test-assertions--load-non-live-object-with-global-copy):
      New unit test.
      6355a3ec
  10. 09 Jul, 2020 1 commit
  11. 27 Mar, 2020 1 commit
    • Eli Zaretskii's avatar
      Port the 'module/async-pipe' test to MS-Windows · f98ee21c
      Eli Zaretskii authored
      These changes let the code compile and produce a valid DLL, but the
      test hangs.  It looks like the hang is in Fdelete_process, when it
      closes one of the descriptors of the pipe process.
      In addition, this use of the pipe process cannot currently work
      on MS-Windows, since make-pipe-process doesn't set up the reader
      thread to read from the Emacs's side of the pipe, so the select
      emulation doesn't know there's stuff to read from that pipe.
      * test/data/emacs-module/mod-test.c [WINDOWSNT]: Include
      windows.h.
      (ALIGN_STACK) [!__x86_64__]: Define for 32-bit builds.
      (sleep_for_half_second): New function.
      (write_to_pipe): Declare return type differently for WINDOWSNT.
      Call sleep_for_half_second.
      (Fmod_test_async_pipe) [WINDOWSNT]: Use _beginthread as substitute
      for pthread_create.
      (invalid_finalizer): Replace non_ASCII character in a comment.
      
      * test/src/emacs-module-tests.el (module/async-pipe): Skip on
      MS-Windows, as the test fails and then hangs.
      f98ee21c
  12. 26 Mar, 2020 1 commit
    • Philipp Stephani's avatar
      Add a module function to open a file descriptor connected to a pipe. · d28b0047
      Philipp Stephani authored
      A common complaint about the module API is that modules can't
      communicate asynchronously with Emacs.  While it isn't possible to
      call arbitrary Emacs functions asynchronously, writing to a pipe
      should always be fine and is a pretty low-hanging fruit.
      
      This patch implements a function that adapts an existing pipe
      process.  That way, users can use familiar tools like process filters
      or 'accept-process-output'.
      
      * src/module-env-28.h: Add 'open_channel' module function.
      
      * src/emacs-module.c (module_open_channel): Provide definition for
      'open_channel'.
      (initialize_environment): Use it.
      
      * src/process.c (open_channel_for_module): New helper function.
      (syms_of_process): Define necessary symbol.
      
      * test/src/emacs-module-tests.el (module/async-pipe): New unit test.
      
      * test/data/emacs-module/mod-test.c (signal_system_error): New helper
      function.
      (signal_errno): Use it.
      (write_to_pipe): New function running in the background.
      (Fmod_test_async_pipe): New test module function.
      (emacs_module_init): Export it.
      
      * doc/lispref/internals.texi (Module Misc): Document new module
      function.
      
      * doc/lispref/processes.texi (Asynchronous Processes): New anchor
      for pipe processes.
      
      * etc/NEWS: Document 'open_channel' function.
      d28b0047
  13. 05 Jan, 2020 1 commit
    • Philipp Stephani's avatar
      Also print function data when printing module functions. · fc92c2d8
      Philipp Stephani authored
      This is especially useful in cases where modules only use a single
      entry point and use the data to dispatch to the actual function.  Such
      a design is common for languages such as Go and C++.
      
      * src/emacs-module.c (module_function_data): New function.
      
      * src/print.c (print_vectorlike): Use it to print module function data
      if not NULL.
      (print_object): Adapt size of buffer.
      
      * test/data/emacs-module/mod-test.c (emacs_module_init): Pass some
      non-NULL data to ‘mod-test-sum’.
      (Fmod_test_sum): Check that correct data is passed through.
      
      * test/src/emacs-module-tests.el (mod-test-sum-test)
      (module-function-object): Adapt unit tests.
      fc92c2d8
  14. 04 Jan, 2020 1 commit
  15. 03 Jan, 2020 1 commit
    • Philipp Stephani's avatar
      Implement finalizers for module functions (Bug#30373) · 48ffef5e
      Philipp Stephani authored
      * src/module-env-28.h: Add new module environment functions to
      module environment for Emacs 28.
      
      * src/emacs-module.h.in: Document that 'emacs_finalizer' also works
      for function finalizers.
      
      * src/emacs-module.c (CHECK_MODULE_FUNCTION): New function.
      (struct Lisp_Module_Function): Add finalizer data member.
      (module_make_function): Initialize finalizer.
      (module_get_function_finalizer)
      (module_set_function_finalizer): New module environment functions.
      (module_finalize_function): New function.
      (initialize_environment): Initialize new environment functions.
      
      * src/alloc.c (cleanup_vector): Call potential module function
      finalizer during garbage collection.
      
      * test/data/emacs-module/mod-test.c (signal_error): New helper
      function.
      (memory_full): Use it.
      (finalizer): New example function finalizer.
      (Fmod_test_make_function_with_finalizer)
      (Fmod_test_function_finalizer_calls): New test module functions.
      (emacs_module_init): Define them.
      
      * test/src/emacs-module-tests.el (module/function-finalizer): New unit
      test.
      
      * doc/lispref/internals.texi (Module Functions): Document new
      functionality.
      (Module Misc): Move description of 'emacs_finalizer' type to 'Module
      Functions' node, and add a reference to it.
      
      * etc/NEWS: Mention new functionality.
      48ffef5e
  16. 01 Jan, 2020 1 commit
  17. 25 Dec, 2019 1 commit
    • Philipp Stephani's avatar
      Support .dylib suffix for modules on macOS (Bug#36226). · 28268e47
      Philipp Stephani authored
      On macOS, shared libraries typically have the suffix .dylib.  This
      commit switches the module suffix to .dylib on Darwin to account for
      that.  To also support the .so suffix, introduce the concept of a
      secondary module suffix.
      
      * configure.ac: Switch MODULES_SUFFIX to .dylib for Darwin, introduce
      MODULES_SECONDARY_SUFFIX.
      
      * src/lread.c (Fload, syms_of_lread): Also use
      MODULES_SECONDARY_SUFFIX if defined.
      
      * test/src/emacs-module-tests.el (module-darwin-secondary-suffix): New
      unit test.
      28268e47
  18. 05 Dec, 2019 1 commit
    • Eli Zaretskii's avatar
      Fix recent modifications in emacs-module-tests · 85f8aa10
      Eli Zaretskii authored
      * test/data/emacs-module/mod-test.c (extract_big_integer): Fix
      calculation of size of 'magnitude' when 'emacs_limb_t' is wider
      than 'unsigned long'.
      
      * test/src/emacs-module-tests.el
      (module--test-assertions--load-non-live-object)
      (module--test-assertions--call-emacs-from-gc): On MS-Windows,
      check also mod-test-emacs with ".exe" appended, before
      skipping the tests.
      85f8aa10
  19. 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
  20. 15 Aug, 2019 1 commit
  21. 06 Jul, 2019 1 commit
    • Konstantin Kharlamov's avatar
      Replace manually crafted hex regexes with [:xdigit:] · dfc322d7
      Konstantin Kharlamov authored
      * admin/charsets/mapconv:
      * build-aux/gitlog-to-changelog (parse_amend_file, git_dir_option):
      * lisp/progmodes/verilog-mode.el (verilog-delay-re):
      (verilog-type-font-keywords, verilog-read-always-signals-recurse):
      (verilog-is-number):
      * lisp/progmodes/vera-mode.el (vera-font-lock-keywords):
      * test/src/emacs-module-tests.el (mod-test-sum-test):
      * lisp/xml.el: (xml--entity-replacement-text):
      * lisp/version.el (emacs-repository-version-git):
      * lisp/textmodes/sgml-mode.el (sgml-quote):
      * lisp/textmodes/css-mode.el (css-escapes-re)
      (css--colors-regexp):
      * lisp/progmodes/prolog.el (prolog-syntax-propertize-function):
      * lisp/progmodes/hideif.el (hif-token-regexp, hif-tokenize):
      * lisp/progmodes/ebnf-dtd.el: (ebnf-dtd-attlistdecl)
      (ebnf-dtd-entitydecl, ebnf-dtd-lex):
      * lisp/progmodes/ebnf-ebx.el (ebnf-ebx-hex-character):
      * lisp/progmodes/ebnf-abn.el (ebnf-abn-character):
      * lisp/progmodes/cperl-mode.el (cperl-highlight-charclass)
      (cperl-find-pods-heres):
      * lisp/progmodes/cc-mode.el (c-maybe-quoted-number-head)
      (c-maybe-quoted-number, c-parse-quotes-before-change)
      (c-parse-quotes-after-change, c-quoted-number-head-before-point)
      (c-quoted-number-straddling-point):
      * lisp/progmodes/ada-mode.el (featurep, ada-in-numeric-literal-p)
      (ada-font-lock-keywords):
      * lisp/org/org-mobile.el (org-mobile-copy-agenda-files)
      * lisp/org/org-table.el (org-table-number-regexp):
      (org-mobile-update-checksum-for-capture-file):
      * lisp/nxml/xsd-regexp.el (xsdre-gen-categories):
      * lisp/nxml/xmltok.el (let*):
      * lisp/nxml/rng-xsd.el (rng-xsd-convert-hex-binary)
      (rng-xsd-convert-any-uri):
      * lisp/nxml/rng-uri.el (rng-uri-file-name-1)
      (rng-uri-unescape-multibyte, rng-uri-unescape-unibyte)
      (rng-uri-unescape-unibyte-match)
      (rng-uri-unescape-unibyte-replace):
      * lisp/nxml/rng-cmpct.el (rng-c-process-escapes):
      * lisp/nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
      * lisp/net/shr-color.el (shr-color->hexadecimal):
      * lisp/mail/rfc2231.el (rfc2231-decode-encoded-string):
      * lisp/international/mule-cmds.el (read-char-by-name):
      * lisp/htmlfontify.el (hfy-hex-regex):
      * lisp/gnus/nneething.el (nneething-decode-file-name):
      * lisp/gnus/mml-sec.el (mml-secure-find-usable-keys):
      * lisp/gnus/gnus-art.el (gnus-button-mid-or-mail-heuristic-alist):
      * lisp/faces.el (read-color):
      * lisp/epg.el (epg--status-ERRSIG, epg--status-VALIDSIG)
      (epg--status-SIG_CREATED, epg--decode-percent-escape)
      (epg--decode-hexstring, epg--decode-quotedstring)
      (epg-dn-from-string):
      * lisp/emulation/cua-rect.el (cua-incr-rectangle):
      * lisp/dnd.el (dnd-unescape-uri):
      * lisp/cedet/semantic/lex.el (semantic-lex-number-expression):
      * lisp/cedet/semantic/java.el (semantic-java-number-regexp):
      * lisp/calc/calc-lang.el (pascal):
      * lisp/calc/calc-ext.el (math-read-number-fancy):
      * lisp/calc/calc-aent.el (math-read-token):
      Replace various combinations of [0-9a-fA-F] with [[:xdigit:]].
      (Bug#36167)
      dfc322d7
  22. 04 May, 2019 1 commit
    • Philipp Stephani's avatar
      Use extract_time in test module. · e95ecbe1
      Philipp Stephani authored
      * test/data/emacs-module/mod-test.c (Fmod_test_sleep_until): Use
      extract_time for time argument.
      (signal_wrong_type_argument): Remove unused function.
      
      * test/src/emacs-module-tests.el (mod-test-sleep-until): Remove
      unnecessary ‘float-time’.
      e95ecbe1
  23. 28 Apr, 2019 3 commits
  24. 24 Apr, 2019 4 commits
    • Philipp Stephani's avatar
      Clarify rounding mode when converting to struct timespec. · c4bacb12
      Philipp Stephani authored
      * doc/lispref/internals.texi (Module Values): Clarify that the
      truncation is towards negative infinity.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_nanoseconds): Add test
      function.
      (emacs_module_init): Define it.
      
      * test/src/emacs-module-tests.el (mod-test-nanoseconds): New unit test.
      c4bacb12
    • 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
    • Philipp Stephani's avatar
      Add module functions to convert from and to big integers. · e290a7d1
      Philipp Stephani authored
      * src/module-env-27.h: Add new module functions to convert big
      integers.
      
      * src/emacs-module.h.in (emacs_mpz): Define if GMP is available.
      
      * src/emacs-module.c (module_extract_big_integer)
      (module_make_big_integer): New functions.
      (initialize_environment): Use them.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_double): New test
      function.
      (emacs_module_init): Define it.
      
      * test/src/emacs-module-tests.el (mod-test-double): New unit test.
      
      * doc/lispref/internals.texi (Module Values): Document new functions.
      e290a7d1
    • Philipp Stephani's avatar
      Add conversions to and from struct timespec to module interface. · bffceab6
      Philipp Stephani authored
      Time values are a fundamental data type, and such conversions are hard
      to implement within modules because of the various forms of time
      values in Emacs Lisp.  Adding dedicated conversion functions can
      significantly simplify module code dealing with times.
      
      This approach uses nanosecond precision.  While Emacs in theory has
      support for higher-precision time values, in practice most languages
      and standards, such as POSIX, C, Java, and Go, have settled on
      nanosecond-precision integers to represent time.
      
      * src/emacs-module.h.in: Add header for struct timespec.
      
      * src/module-env-27.h: Add module functions for time conversion.
      
      * src/emacs-module.c (module_extract_time, module_make_time): New
      functions.
      (initialize_environment): Use them.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_add_nanosecond): New
      test function.
      (emacs_module_init): Define it.
      
      * test/src/emacs-module-tests.el (mod-test-add-nanosecond/valid)
      (mod-test-add-nanosecond/nil, mod-test-add-nanosecond/invalid): New
      unit tests.
      
      * doc/lispref/internals.texi (Module Values): Document time
      conversion functions.
      bffceab6
  25. 22 Mar, 2019 1 commit
  26. 21 Mar, 2019 2 commits
  27. 24 Feb, 2019 1 commit
    • Philipp Stephani's avatar
      Ignore pending_signals when checking for quits. · 72ec233f
      Philipp Stephani authored
      pending_signals is often set if no quit is pending.  This results in
      bugs in module code if the module returns but no quit is actually
      pending.
      
      As a better alternative, add a new process_input environment function
      for Emacs 27.  That function processes signals (like maybe_quit).
      
      * configure.ac: Add module snippet for Emacs 27.
      
      * src/module-env-27.h: New file.
      
      * src/emacs-module.h.in: Add process_input function to environment
      interface.
      
      * src/emacs-module.c (module_should_quit): Use QUITP macro to check
      whether the caller should quit.
      (module_process_input): New function.
      (initialize_environment): Use it.
      
      * src/eval.c: Remove obsolete comment.
      
      * test/data/emacs-module/mod-test.c (signal_wrong_type_argument)
      (signal_errno): New helper functions.
      (Fmod_test_sleep_until): New test module function.
      
      * test/src/emacs-module-tests.el (mod-test-sleep-until): New unit
      test.
      
      * doc/lispref/internals.texi (Module Misc): Document process_input.
      72ec233f
  28. 01 Jan, 2019 1 commit
  29. 25 Aug, 2018 1 commit
    • Sergey Vinokurov's avatar
      Fix detection of freed emacs_values (Bug#32479) · 54fb383a
      Sergey Vinokurov authored
      * src/emacs-module.c (module_free_global_ref): Compare a value to be
      freed with all entries of the list.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_globref_free): New
      function.
      (emacs_module_init): Make it accessible from Lisp.
      * test/src/emacs-module-tests.el (mod-test-globref-free-test): New
      test which uses it.
      54fb383a
  30. 08 Aug, 2018 1 commit
  31. 28 Apr, 2018 1 commit
    • Juri Linkov's avatar
      * lisp/subr.el (dotimes): Deprecate RESULT field. (Bug#16206) · f4eeb0f5
      Juri Linkov authored
      * doc/lispref/control.texi (Iteration):
      * doc/misc/cl.texi (Iteration): Document deprecation of its use.
      * doc/lispintro/emacs-lisp-intro.texi (dotimes):
      * test/src/emacs-module-tests.el (multiply-string):
      * test/lisp/filenotify-tests.el (file-notify-test07-many-events):
      Place RESULT field after the form.
      f4eeb0f5