1. 08 Apr, 2019 1 commit
  2. 28 Mar, 2019 1 commit
  3. 19 Mar, 2019 1 commit
    • Paul Eggert's avatar
      Use ‘const’ to clarify GC marking · 53914a10
      Paul Eggert authored
      Add ‘const’ to make the GC marking code a bit clearer.
      This can also help the compiler in some cases, I think because
      GCC can now determine more often that the value of a static C
      variable can be cached when its address is now converted to
      ‘Lisp Object const *’ before escaping.
      * src/alloc.c (staticvec, mark_maybe_objects, mark_memory)
      (mark_stack, staticpro, mark_object_root_visitor)
      (garbage_collect_1):
      * src/pdumper.c (dump_ptr_referrer, dump_emacs_reloc_to_lv)
      (dump_emacs_reloc_to_emacs_ptr_raw, dump_root_visitor):
      * src/lisp.h (vcopy, struct gc_root_visitor):
      * src/sysdep.c (stack_overflow):
      * src/thread.c (mark_one_thread):
      * src/thread.h (struct thread_state):
      Use pointer-to-const instead of plain pointer in some
      GC-related places where either will do.
      53914a10
  4. 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
  5. 01 Jan, 2019 1 commit
  6. 19 Oct, 2018 1 commit
    • Paul Eggert's avatar
      Fix struct thread alignment on FreeBSD x86 · d2a07b9a
      Paul Eggert authored
      Problem reported by Joseph Mingrone in:
      https://lists.gnu.org/r/emacs-devel/2018-10/msg00238.html
      While we’re at it, apply a similar fix to struct Lisp_Subr; this
      removes the need for GCALIGNED_STRUCT_MEMBER and thus can shrink
      struct Lisp_Subr a bit.
      * configure.ac (HAVE_STRUCT_ATTRIBUTE_ALIGNED): Bring back this macro.
      Although used only for performance (not to actually align
      structures), we might as well take advantage of it.
      * src/lisp.h (GCALIGNED_STRUCT_MEMBER): Remove; all uses removed.
      (union Aligned_Lisp_Subr): New type, like struct Lisp_Subr but aligned.
      * src/lisp.h (XSUBR, DEFUN):
      * src/lread.c (defsubr): Use it.  All callers changed.
      * src/thread.c (union aligned_thread_state): New type.
      (main_thread): Now of this type, so it’s aligned.
      All uses changed.
      * src/xmenu.c (syms_of_xmenu) [USE_GTK || USE_X_TOOLKIT]:
      Adjust to union Aligned_Lisp_Subr change.
      d2a07b9a
  7. 17 Oct, 2018 1 commit
  8. 31 Aug, 2018 2 commits
    • Michael Albinus's avatar
      Rename thread-alive-p to thread-live-p · ac7936cb
      Michael Albinus authored
      * doc/lispref/threads.texi (Basic Thread Functions): Use thread-live-p.
      
      * etc/NEWS: 'thread-alive-p' has been renamed to 'thread-live-p'.
      
      * src/thread.c (thread_live_p): Rename from thread_alive_p.  Adapt
      all callees.
      (Fthread_live_p): Rename from Fthread_alive_p.
      (syms_of_threads): Make thread-alive-p an alias of thread-live-p.
      
      * test/src/thread-tests.el (all): Replace `thread-alive-p' by
      `thread-live-p'.
      (threads-live): Rename from `threads-alive'.
      ac7936cb
    • Michael Albinus's avatar
      Construct a thread_event only if THREADS_ENABLED · 76978462
      Michael Albinus authored
      * src/thread.c (Fthread_signal): Construct a thread_event only if
      THREADS_ENABLED.
      76978462
  9. 30 Aug, 2018 1 commit
    • Michael Albinus's avatar
      Handle thread-signal towards the main thread (Bug#32502) · 54b92132
      Michael Albinus authored
      * doc/lispref/threads.texi (Basic Thread Functions):
      * etc/NEWS: Document thread-signal towards the main thread.
      
      * lisp/emacs-lisp/thread.el: New package.
      
      * src/keyboard.c (read_char): Check for Qthread_event.
      (kbd_buffer_get_event, make_lispy_event): Handle THREAD_EVENT.
      (syms_of_keyboard): Declare Qthread_event.
      (keys_of_keyboard): Add thread-handle-event to special-event-map.
      
      * src/termhooks.h (enum event_kind): Add THREAD_EVENT.
      
      * src/thread.c: Include "keyboard.h".
      (poll_suppress_count) Don't declare extern.
      (Fthread_signal): Raise event if THREAD is the main thread.  (Bug#32502)
      
      * test/src/thread-tests.el (thread): Require it.
      (threads-signal-main-thread): New test.
      54b92132
  10. 22 Jul, 2018 1 commit
    • Michael Albinus's avatar
      thread-join returns the result of finished thread · e2372797
      Michael Albinus authored
      * doc/lispref/threads.texi (Basic Thread Functions):
      * etc/NEWS: Document return value of `thread-join'.
      
      * src/thread.c (invoke_thread_function, Fmake_thread)
      (init_main_thread): Set result.
      (Fthread_join): Propagate signals, and return result.
      (Vmain_thread): New defvar.
      
      * src/thread.h (struct thread_state): Add `result' field.
      
      * test/src/thread-tests.el (threads-join): Test also return value.
      (threads-join-error): New test.
      (threads-mutex-signal): Check for propagation of `quit' signal.
      e2372797
  11. 17 Jul, 2018 1 commit
    • Michael Albinus's avatar
      Add variable main-thread, fix Bug#32169 · 798cbac1
      Michael Albinus authored
      * doc/lispref/threads.texi (Basic Thread Functions): Add example,
      how to propagate signals to the main thread.  Describe variable
      `main-thread'.  Document optional argument CLEANUP of
      `thread-last-error'.
      
      * src/thread.c (Fthread_last_error): Add optional argument
      CLEANUP.  (Bug#32169)
      (main-thread): New defvar.
      
      * test/src/thread-tests.el (thread-last-error): Adapt declaration.
      (main-thread): Declare.
      (threads-main-thread): New test.
      (threads-errors): Extend test.
      798cbac1
  12. 12 Jul, 2018 1 commit
    • Michael Albinus's avatar
      Provide feature 'threads · 3744fda5
      Michael Albinus authored
      * src/thread.c (syms_of_threads): Provide feature "threads".
      
      * test/src/thread-tests.el (top): Declare the functions.
      (all): Use (featurep 'threads) check.
      3744fda5
  13. 18 Jan, 2018 1 commit
  14. 01 Jan, 2018 1 commit
  15. 24 Nov, 2017 3 commits
  16. 13 Nov, 2017 1 commit
    • Paul Eggert's avatar
      Use alignas to fix GCALIGN-related bugs · b1573a97
      Paul Eggert authored
      Use alignas and unions to specify alignments of objects needing
      addresses that are at least a multiple of GCALIGNMENT.  Using
      these standard C facilities should be safer than relying on ad hoc
      and poorly-understood features like GCC’s __attribute__
      ((aligned (N))), the root cause for recent porting bugs like
      Bug#29040.  The alignas macro was standardized by C11 and Gnulib
      supports alignas for pre-C11 platforms.  I have tested this on Sun
      Studio 12 sparc (2007) and GCC 4.4.7 x86-64 (2012) as well as on
      more recent platforms like GCC 7.2.1 (2017) on Fedora 26 (both
      x86-64 and x86).
      * lib-src/make-docfile.c (close_emacs_globals): lispsym is now
      just an array of struct Lisp_Symbol, since struct Lisp_Symbol is
      now properly aligned.  All uses changed.
      * src/alloc.c (NEXT_FREE_LISP_STRING): Just use the new u.next
      member; this is simpler and safer than casting a pointer that
      might not be aligned properly.
      (aligned_Lisp_Symbol): Remove.  No longer needed, now that struct
      Lisp_Symbol is aligned properly.  All uses replaced with struct
      Lisp_Symbol.
      * src/lisp.h (GCALIGNED): Remove, as it does not work as expected:
      it can cause the natural alignment to be ignored.  All uses
      replaced by unions with a ‘char alignas (GCALIGNMENT)’ member as
      described below.
      (struct Lisp_Symbol, struct Lisp_Cons, struct Lisp_String):
      Change definition from ‘struct TAG { MEMBERS };’ to
      ‘struct TAG { union { struct { MEMBERS } s; char alignas
      (GCALIGNMENT) gcaligned; } u; };’.  This guarantees ‘struct TAG’
      to have an alignment that at least max (GCALIGNMENT, N) where N is
      its old alignment.  All uses like ‘PTR->MEMBER’ changed to
      ‘PTR->u.s.MEMBER’; these uses were supposed to be mostly private
      anyway.  Verify that the resulting ‘struct TAG’ is properly
      aligned for Emacs.
      (union vectorlike_header): New member ‘gcaligned’ to guarantee
      that this type, and its containing types like ‘struct Lisp_Subr’,
      ‘struct buffer’ and ‘struct thread_state’, are all properly
      aligned for Emacs.
      (struct Lisp_String): New union member ‘next’, for the benefit
      of NEXT_FREE_LISP_STRING.
      (union Aligned_Cons, union Aligned_String): Remove.  All uses
      replaced by struct Lisp_Cons and struct Lisp_String, since they
      are now properly aligned.
      (USE_STACK_CONS, USE_STACK_STRING): Simplify now that we can
      assume struct Lisp_Cons and struct Lisp_String are properly
      aligned.
      b1573a97
  17. 09 Nov, 2017 1 commit
    • Paul Eggert's avatar
      Use GCALIGNED properly for GCC · 9e59de94
      Paul Eggert authored
      Apparently GCC requires that ‘__attribute__ ((aligned (8)))’ must
      immediately follow the ‘struct’ keyword when aligning a structure.
      The attribute silently does not work if it follows a tag after the
      ‘struct’ keyword.  Who knew?  Anyway, this patch is designed to
      fix a SIGSEGV problem reported by John Mastro (Bug#29183).
      * lib-src/make-docfile.c (close_emacs_globals):
      * src/buffer.c (buffer_defaults, buffer_local_symbols):
      * src/lisp.h (DEFUN):
      * src/thread.c (main_thread):
      Put 'GCALIGNED' immediately after 'struct'.
      9e59de94
  18. 02 Nov, 2017 1 commit
    • Paul Eggert's avatar
      Fix alignment portability problems · 6b08ad52
      Paul Eggert authored
      Do not assume that the natural alignment of Lisp objects is a
      multiple of GCALIGNMENT.  This improves on the portability of the
      recent fix for Bug#29040.
      * lib-src/make-docfile.c (close_emacs_globals):
      * src/buffer.c (buffer_defaults, buffer_local_symbols):
      * src/lisp.h (DEFUN):
      * src/thread.c (main_thread):
      Use GCALIGNED, not alignas (GCALIGNMENT).
      * src/alloc.c (COMMON_MULTIPLE):
      Move back here from lisp.h, since it is no longer used elsewhere.
      * src/lisp.h (GCALIGNMENT): No longer a macro, since we need not
      worry about MSVC.  Omit no-longer-needed consistency check.
      * src/thread.c (THREAD_ALIGNMENT): Remove.
      6b08ad52
  19. 28 Oct, 2017 1 commit
    • Eli Zaretskii's avatar
      Avoid segfaults in 64-bit Windows builds · 00c3c6d8
      Eli Zaretskii authored
      * src/lisp.h (COMMON_MULTIPLE): Move here from alloc.c.
      * src/thread.c (THREAD_ALIGNMENT): New macro.
      (main_thread): Use THREAD_ALIGNMENT to align propertly.  (Bug#29040)
      00c3c6d8
  20. 27 Oct, 2017 1 commit
    • Paul Eggert's avatar
      Port thread.c to OpenBSD ARM · 015f0bb2
      Paul Eggert authored
      Problem reported by Jeremie Courreges-Anglas (Bug#29005).
      * src/thread.c (main_thread): Align to GCALIGNMENT.
      015f0bb2
  21. 18 Oct, 2017 1 commit
    • Eli Zaretskii's avatar
      Fix the MSDOS build. · 2f7163fb
      Eli Zaretskii authored
      * msdos/sed1v2.inp (GETADDRINFO_A_LIBS, LIBLCMS2, XDBE_LIBS)
      (XDBE_FLAGS, HYBRID_MALLOC, LIBSYSTEMD_CFLAGS)
      (LIBSYSTEMD_LIBS): Edit to empty.
      (LIBRESOLV, DEPFLAGS, MKDEPDIR, YMF_PASS_LDFLAGS)
      (PRE_EDIT_LDFLAGS, POST_EDIT_LDFLAGS): Remove editing.
      Remove editing of lines that are no longer present in
      src/Makefile.in.
      * msdos/sed2v2.inp (NEED_MKTIME_INTERNAL)
      (NEED_MKTIME_WORKING): Define to 1.
      (HAVE_STRUCT_DIRENT_D_TYPE): Define to 1 for
      DJGPP >= 2.05.
      (HAVE_STRUCT_ATTRIBUTE_ALIGNED): Define to 1.
      Define PACKAGE_VERSION, not VERSION.
      (FLEXIBLE_ARRAY_MEMBER): Define to empty.
      (HAVE_DECL_*_UNLOCKED): Define to 0.
      (HAVE___BUILTIN_FRAME_ADDRESS): Define to 1.
      (PENDING_*): Don't define, as Gnulib no longer supports that.
      Instead, define _IOERR as it is in libc/file.h.
      * msdos/sed3v2.inp: Use $(CURDIR) instead of $(shell cd) to
      determine the current directory.
      (UPDATE_MANIFEST, UTILITIES): Don't edit.
      * msdos/sedlisp.inp (FIND_DELETE): Edit to "-delete".
      * msdos/sedlibmk.inp (AUTO_DEPEND): Define to yes.
      (HYBRID_MALLOC): Edit to empty.
      (am__cd): Don't edit.
      (../config.status): Replaces $(top_builddir)/config.status.
      Define OMIT_GNULIB_MODULE_foo = true for modules not built for
      MS-DOS.  Convert GL_GENERATE_xxx_H_TRUE and
      GL_GENERATE_xxx_H_FALSE into values of GL_GENERATE_xxx_H.
      * msdos/mainmake.v2 (src): Use 'compile-one-process', and make
      the command line shorter to fit into 126-char limit of
      command.com.
      * config.bat: Generate src/deps/*.d files.  Rename more files
      like djtar on plain DOS would.
      Don't rename src/dir.h: it is long gone.  Edit
      lib/gnulib.mk.in using the same scripts as for
      lib/Makefile.in.
      * msdos/depfiles.bat: Create *.d files, not *.Po.
      
      * src/thread.c (Fmake_thread) [!THREADS_ENABLED]: Improve the
      error message.
      * src/thread.h [MSDOS]: Include <signal.h>.
      * src/sysselect.h (select) [MSDOS]: Undefine, to avoid
      compilation errors.
      * src/sysdep.c (block_interrupt_signal, restore_signal_mask):
      Expose to MSDOS build.
      * src/process.c (update_processes_for_thread_death)
      [!subprocess]: No-op implementation.
      [HAVE_SETRLIMIT]: Move inclusion of sys/resource.h and
      declaration of nofile_limit outside "#ifdef subprocesses", as
      it's needed for MSDOS.
      * src/msdos.c (faccessat): Declare fullname[].
      * src/msdos.h (ENOTSUP): Define to be identical to ENOSYS.
      Include termhooks.h.
      * src/conf_post.h [WINDOWSNT]: Include ms-w32.h only on
      WINDOWSNT, not DOS_NT.
      
      * admin/admin.el (set-version): Set version on PACKAGE_VERSION.
      2f7163fb
  22. 04 Oct, 2017 1 commit
    • Eli Zaretskii's avatar
      Avoid crashes on C-g when several threads wait for input · ea39d470
      Eli Zaretskii authored
      * src/thread.h (m_getcjmp): New member of 'struct thread_state'.
      (getcjmp): Define to current thread's 'm_getcjmp'.
      * src/thread.c (maybe_reacquire_global_lock): Switch to main
      thread, since this is called from a SIGINT handler, which always
      runs in the context of the main thread.
      * src/lisp.h (sys_jmp_buf, sys_setjmp, sys_longjmp): Move the
      definitions before thread.h is included, as thread.h now uses
      sys_jmp_buf.
      * src/keyboard.c (getcjmp): Remove declaration.
      (read_char): Don't call maybe_reacquire_global_lock here.
      (handle_interrupt): Call maybe_reacquire_global_lock here, if
      invoked from the SIGINT handler, to make sure
      quit_throw_to_read_char runs with main thread's Lisp bindings and
      uses the main thread's jmp_buf buffer.  (Bug#28630)
      ea39d470
  23. 13 Sep, 2017 1 commit
    • Paul Eggert's avatar
      Prefer HTTPS to FTP and HTTP in documentation · bc511a64
      Paul Eggert authored
      Most of this change is to boilerplate commentary such as license URLs.
      This change was prompted by ftp://ftp.gnu.org's going-away party,
      planned for November.  Change these FTP URLs to https://ftp.gnu.org
      instead.  Make similar changes for URLs to other organizations moving
      away from FTP.  Also, change HTTP to HTTPS for URLs to gnu.org and
      fsf.org when this works, as this will further help defend against
      man-in-the-middle attacks (for this part I omitted the MS-DOS and
      MS-Windows sources and the test tarballs to keep the workload down).
      HTTPS is not fully working to lists.gnu.org so I left those URLs alone
      for now.
      bc511a64
  24. 14 Jul, 2017 1 commit
    • Paul Eggert's avatar
      Improve stack-overflow heuristic on GNU/Linux · 9dee1c88
      Paul Eggert authored
      Problem reported by Steve Kemp (Bug#27585).
      * src/eval.c (near_C_stack_top): Remove.  All uses replaced
      by current_thread->stack_top.
      (record_in_backtrace): Set current_thread->stack_top.
      This is for when the Lisp interpreter calls itself.
      * src/lread.c (read1): Set current_thread->stack_top.
      This is for recursive s-expression reads.
      * src/print.c (print_object): Set current_thread->stack_top.
      This is for recursive s-expression printing.
      * src/thread.c (mark_one_thread): Get stack top first.
      * src/thread.h (struct thread_state.stack_top): Now void *, not char *.
      9dee1c88
  25. 02 May, 2017 1 commit
  26. 18 Jan, 2017 2 commits
    • Eli Zaretskii's avatar
      Fix a bug with signaling a thread that waits for condvar · 5fefaaa8
      Eli Zaretskii authored
      * src/thread.c (lisp_mutex_lock_for_thread): New function,
      with all the guts of lisp_mutex_lock.
      (lisp_mutex_lock): Call lisp_mutex_lock_for_thread.
      (condition_wait_callback): Don't call post_acquire_global_lock
      before locking the mutex, as that could cause a signaled thread to
      exit prematurely, because the condvar's mutex is recorded to be
      not owned by any thread, and with-mutex wants to unlock it as part
      of unwinding the stack in response to the signal.
      5fefaaa8
    • Eli Zaretskii's avatar
      Rudimentary error handling for non-main threads · 57153260
      Eli Zaretskii authored
      * src/thread.c (last_thread_error): New static variable.
      (syms_of_threads): Staticpro it.
      (record_thread_error, Fthread_last_error): New functions.
      (syms_of_threads): Defsubr Fthread_last_error.
      
      * doc/lispref/threads.texi (Basic Thread Functions): Document
      thread-last-error.
      
      * test/src/thread-tests.el (thread-errors, thread-signal-early)
      (threads-condvar-wait): Test the values returned by
      thread-last-error.
      57153260
  27. 13 Jan, 2017 1 commit
    • Eli Zaretskii's avatar
      Fix a bug in waiting for condition variable · 03e4ab0d
      Eli Zaretskii authored
      * src/thread.c (lisp_mutex_lock, lisp_mutex_unlock)
      (lisp_mutex_unlock_for_wait, condition_wait_callback)
      (condition_notify_callback): Improve commentary.
      (condition_wait_callback): Call post_acquire_global_lock before
      attempting to lock the mutex, to make sure the lock's owner is
      recorded correctly.
      
      * test/src/thread-tests.el (threads-condvar-wait): New test.
      03e4ab0d
  28. 01 Jan, 2017 1 commit
  29. 30 Dec, 2016 1 commit
    • Paul Eggert's avatar
      Rename primary_thread to main_thread · 108ef803
      Paul Eggert authored
      This avoids the confusion of using two different phrases "main thread"
      and "primary thread" internally to mean the same thing.  See:
      http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg01142.html
      * src/thread.c (main_thread): Rename from primary_thread,
      since the new name no longer clashes with main_thread_id
      and Emacs internals normally call this the "main thread".
      (init_main_thread): Rename from init_primary_thread.
      (main_thread_p): Rename from primary_thread_p.
      All uses changed.
      108ef803
  30. 24 Dec, 2016 2 commits
    • Paul Eggert's avatar
      Remove interpreter’s byte stack · a815e5f1
      Paul Eggert authored
      This improves performance overall on my benchmark on x86-64,
      since the interpreted program-counter resides in a machine
      register rather than in RAM.
      * etc/DEBUG, src/.gdbinit: Remove xbytecode GDB command, as there
      is no longer a byte stack to decode.
      * src/bytecode.c (struct byte_stack, byte_stack_list)
      (relocate_byte_stack): Remove.  All uses removed.
      (FETCH): Simplify now that pc is now local (typically, in a
      register) and no longer needs to be relocated.
      (CHECK_RANGE): Remove.  All uses now done inline, in a different way.
      (BYTE_CODE_QUIT): Remove; now done by op_relative_branch.
      (exec_byte_code): Allocate a copy of the function’s bytecode,
      so that there is no problem if GC moves it.
      * src/lisp.h (struct handler): Remove byte_stack member.
      All uses removed.
      * src/thread.c (unmark_threads): Remove.  All uses removed.
      * src/thread.h (struct thread_state): Remove m_byte_stack_list member.
      All uses removed.  m_stack_bottom is now the first non-Lisp field.
      a815e5f1
    • Paul Eggert's avatar
      Use max_align_t instead of void * · e2767bd0
      Paul Eggert authored
      * src/thread.c (run_thread): Don’t assume void * is aligned enough.
      e2767bd0
  31. 23 Dec, 2016 1 commit
  32. 22 Dec, 2016 2 commits
  33. 19 Dec, 2016 1 commit
    • Eli Zaretskii's avatar
      Fix crashes upon C-g on Posix TTY frames · fe3188b1
      Eli Zaretskii authored
      * src/thread.h (struct thread_state): New member not_holding_lock.
      (maybe_reacquire_global_lock): Add prototype.
      * src/thread.c: Include syssignal.h.
      (maybe_reacquire_global_lock): New function.
      (really_call_select): Set the not_holding_lock member of the
      thread state before releasing the lock, and rest it after
      re-acquiring the lock when the select function returns.  Block
      SIGINT while doing this to make sure we are not interrupted on TTY
      frames.
      * src/sysdep.c (block_interrupt_signal, restore_signal_mask): New
      functions.
      * src/syssignal.h (block_interrupt_signal, restore_signal_mask):
      Add prototypes.
      * src/keyboard.c (read_char) [THREADS_ENABLED]: Call
      maybe_reacquire_global_lock.  (Bug#25178)
      fe3188b1
  34. 12 Dec, 2016 1 commit
    • Eli Zaretskii's avatar
      Avoid crashing if a new thread is signaled right away · 825f4dd4
      Eli Zaretskii authored
      * src/thread.c (post_acquire_global_lock): Don't raise the pending
      signal if the thread's handlers were not yet set up, as that will
      cause Emacs to exit with a fatal error.  This can happen if a
      thread is signaled as soon as make-thread returns, before the new
      thread had an opportunity to acquire the global lock, set up the
      handlers, and call the thread function.
      
      * test/src/thread-tests.el (thread-signal-early): New test.
      825f4dd4