aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Use GCALIGNED properly for GCCPaul Eggert2017-11-081-1/+1
| | | | | | | | | | | | | 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'.
* Fix alignment portability problemsPaul Eggert2017-11-021-3/+1
| | | | | | | | | | | | | | | | 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.
* Avoid segfaults in 64-bit Windows buildsEli Zaretskii2017-10-281-1/+3
| | | | | | * 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)
* Port thread.c to OpenBSD ARMPaul Eggert2017-10-261-1/+1
| | | | | Problem reported by Jeremie Courreges-Anglas (Bug#29005). * src/thread.c (main_thread): Align to GCALIGNMENT.
* Fix the MSDOS build.Eli Zaretskii2017-10-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Avoid crashes on C-g when several threads wait for inputEli Zaretskii2017-10-041-5/+11
| | | | | | | | | | | | | | | | | * 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)
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-1/+1
| | | | | | | | | | | | | 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.
* Improve stack-overflow heuristic on GNU/LinuxPaul Eggert2017-07-141-4/+6
| | | | | | | | | | | | | | 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 *.
* Use ptrdiff_t, not int, for stack sizesPaul Eggert2017-05-021-1/+1
| | | | | | * src/thread.c (invoke_thread_function): * src/xterm.c (x_cr_export_frames): Don’t assume SPECPDL_INDEX fits in ‘int’.
* Fix a bug with signaling a thread that waits for condvarEli Zaretskii2017-01-181-17/+24
| | | | | | | | | | | * 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.
* Rudimentary error handling for non-main threadsEli Zaretskii2017-01-181-3/+17
| | | | | | | | | | | | | | * 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.
* Fix a bug in waiting for condition variableEli Zaretskii2017-01-131-2/+41
| | | | | | | | | | | * 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.
* Update copyright year to 2017 in masterPaul Eggert2017-01-011-1/+1
| | | | | | Run admin/update-copyright in the master branch. This fixes files that were not already fixed in the emacs-25 branch before it was merged here.
* Rename primary_thread to main_threadPaul Eggert2016-12-301-20/+20
| | | | | | | | | | | | 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.
* Remove interpreter’s byte stackPaul Eggert2016-12-231-13/+3
| | | | | | | | | | | | | | | | | | | | | 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.
* Use max_align_t instead of void *Paul Eggert2016-12-231-7/+2
| | | | * src/thread.c (run_thread): Don’t assume void * is aligned enough.
* Avoid aborts due to unaligned byte stack of threadsEli Zaretskii2016-12-231-3/+10
| | | | | * src/thread.c (run_thread): Make sure the pointers to thread byte stack are properly aligned. (Bug#25247)
* ; Spelling fixesPaul Eggert2016-12-221-6/+5
|
* Fix last change with thread marking under GC_CHECK_MARKED_OBJECTSEli Zaretskii2016-12-221-0/+6
| | | | | | | * src/thread.c (primary_thread_p): New function. * src/alloc.c (mark_object): Use 'primary_thread_p' to bypass tests meant for thread objects allocated dynamically. * src/thread.h (primary_thread_p): Add prototype.
* Fix crashes upon C-g on Posix TTY framesEli Zaretskii2016-12-191-0/+27
| | | | | | | | | | | | | | | | | | * 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)
* Avoid crashing if a new thread is signaled right awayEli Zaretskii2016-12-121-11/+15
| | | | | | | | | | | * 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.
* Fix point motion in cloned buffersEli Zaretskii2016-12-121-6/+5
| | | | | | | | | | | | | | | | | | * src/thread.c (post_acquire_global_lock): Call set_buffer_internal_2 instead of tricking set_buffer_internal_1 into resetting the current buffer even if it didn't change. This avoids bug#25165, caused by failing to record the modified values of point and mark, because current_buffer was set to NULL. Also, don't bother re-setting the buffer if there was no thread switch, as that just wastes cycles. * src/buffer.c (set_buffer_internal_2): New function, with most of the body of set_buffer_internal_1, but without the test for B being identical to the current buffer. (set_buffer_internal_1): Call set_buffer_internal_2 if B is not identical to the current buffer. * src/buffer.h (set_buffer_internal_2): Add prototype. * test/src/thread-tests.el (thread-sticky-point): New test.
* ; Fix copyright years in new filesGlenn Morris2016-12-101-1/+1
|
* Fix error messages in thread.cEli Zaretskii2016-12-101-4/+4
| | | | | * src/thread.c (lisp_mutex_unlock, Fcondition_wait) (Fcondition_notify, Fthread_join): Fix error messages.
* Improve doc strings in thread.cEli Zaretskii2016-12-101-30/+31
| | | | | | * src/thread.c (Fmake_condition_variable, Fcondition_wait) (Fcondition_notify, Fcondition_mutex, Fcondition_name, Fmake_thread) (Fthread_join, Fall_threads): Doc fixes.
* Fix building with check-lisp-object-typeEli Zaretskii2016-12-101-1/+1
| | | | | | * src/thread.c (mark_one_thread): Use NILP to compare with m_saved_last_thing_searched, which is a Lisp object. Reported by Andreas Politz <politza@hochschule-trier.de>.
* Fix compilation warningsEli Zaretskii2016-12-081-1/+1
| | | | | * src/thread.c (Fmake_thread): Call emacs_abort, to avoid compilation warning.
* Fix compilation problems.Eli Zaretskii2016-12-051-6/+0
|
* Merge branch 'concurrency'Eli Zaretskii2016-12-041-2/+1
| | | | | | | | | | | | | | Conflicts (resolved): configure.ac src/Makefile.in src/alloc.c src/bytecode.c src/emacs.c src/eval.c src/lisp.h src/process.c src/regex.c src/regex.h
* merge from trunkKen Raeburn2015-11-011-39/+41
|
* change condition-variablep to condition-variable-pTom Tromey2013-10-171-3/+3
|
* Fix crashes when unbind_for_thread_switch signals an error.Eli Zaretskii2013-09-011-5/+10
| | | | | | | | | src/eval.c (unbind_for_thread_switch): Accept a 'struct thread_state *' argument and use specpdl_ptr and specpdl of that thread. Fixes crashes if find_symbol_value signals an error. src/thread.c (post_acquire_global_lock): Update current_thread before calling unbind_for_thread_switch. Pass the previous thread to unbind_for_thread_switch.
* rename thread-blocker to thread--blockerTom Tromey2013-08-271-1/+1
|
* make thread_check_current_buffer return boolTom Tromey2013-08-271-3/+3
|
* use record_unwind_protect_void, avoid warningTom Tromey2013-08-261-4/+3
|
* implement --enable-threads and a thread-less modeTom Tromey2013-08-261-18/+23
|
* Use thread_alive_p in a couple more spotsTom Tromey2013-07-111-2/+2
|
* fix xfree bug in run_threadTom Tromey2013-07-071-1/+1
| | | | | this fixes run_thread to account for the dummy slot in specpdl
* merge from trunkTom Tromey2013-07-061-2/+4
| | | | | | this merges frmo trunk and fixes various build issues. this needed a few ugly tweaks. this hangs in "make check" now
* call init_primary_thread from init_threadsTom Tromey2013-07-061-0/+1
|
* avoid current_thread sometimesTom Tromey2013-07-041-2/+3
| | | | | this tweaks thread.c to use 'self' instead of current_thread in a couple spots. this is clearer and more robust
* unlink thread laterTom Tromey2013-07-031-11/+8
| | | | | unlink thread from global list later also remove some unnecessary destruction code
* introduce thread_alive_p macroTom Tromey2013-07-031-6/+13
| | | | | | This introduces the thread_alive_p macro and changes thread-alive-p to use it. This is a minor cleanup. It also changes all-threads to ignore dead threads.
* Don't call unbind_for_thread_switch in run_threadTom Tromey2013-07-031-2/+0
| | | | | This removes the call to unbind_for_thread_switch from run_thread. This isn't necessary because acquire_global_lock does it properly.
* fix a few latent issues in the thread patchTom Tromey2013-06-061-6/+10
| | | | | | | | | | | | * we called unbind_for_thread_switch unconditionally, but this is wrong if the previous thread exited * likewise, exiting a thread should clear current_thread * redundant assignment in run_thread * clean up init_threads - no need to re-init the primary thread This patch still sometimes causes weird hangs in "make check". However, I think that is a kernel bug, since Emacs enters the zombie state but its parent process hangs in wait. This shouldn't happen.
* merge from trunk; clean up some issuesTom Tromey2013-06-031-10/+2
|
* don't let kill-buffer kill a buffer if it is current in any threadTom Tromey2013-03-181-0/+19
|
* cannot thread-join the current threadTom Tromey2012-08-271-0/+3
|
* pass the thread name to the OS if possibleTom Tromey2012-08-201-1/+6
| | | | use prctl to pass the thread name to the OS, if possible
* another docstring fixletTom Tromey2012-08-191-1/+2
|