summaryrefslogtreecommitdiff
path: root/src/systhread.c
AgeCommit message (Collapse)Author
2026-01-01; Add 2026 to copyright years.Sean Whitton
2025-12-02Port to GNU/Linux HPPA mallocPaul Eggert
On this platform, you cannot reliably malloc objects containing values of type pthread_mutex_t or pthread_cond_t, since malloc guarantees only 8-byte alignment but these two types require 16-byte alignment. See GCC bug 115750 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115750> reported by Sam James and Emacs bug 79936 <https://bugs.gnu.org/79936> reported by John Paul Adrian Glaubitz. * configure.ac (ALIGNOF_MAX_ALIGN_T, ALIGNOF_PTHREAD_COND_T) (ALIGNOF_PTHREAD_MUTEX_T) [HAVE_PTHREAD]: New C macros. * src/systhread.c (sys_mutex_init, sys_mutex_lock) (sys_mutex_unlock, sys_cond_init, sys_cond_wait) (sys_cond_signal, sys_cond_broadcast, sys_cond_destroy): Use SYTHREAD_ALIGN_PTR to convert sys_mutex_t and sys_cond_t to pthread_mutex_t and pthread_cond_t, since runtime conversion is needed on GNU/Linux HPPA. * src/systhread.h (SYSTHREAD_ALIGN_ROOM, SYSTHREAD_ALIGN_PTR): New macros, which affect the generated code only on unusual platforms like GNU/Linux HPPA. (sys_mutex_t, sys_cond_t) [HAVE_PTHREAD]: Use them.
2025-01-01Update copyright year to 2025Paul Eggert
Run "TZ=UTC0 admin/update-copyright".
2024-01-02; Add 2024 to copyright yearsPo Lu
2023-01-01; Add 2023 to copyright years.Eli Zaretskii
2022-01-01; Add 2022 to copyright years.Eli Zaretskii
2021-01-01Update copyright year to 2021Paul Eggert
Run "TZ=UTC0 admin/update-copyright".
2020-06-28Add thread-naming support for OpenBSDTimo Myyrä
OpenBSD has pthread_set_name_np; FreeBSD appears to have both this call and pthread_setname_np (the latter call is used in preference). * configure.ac: Detect pthread_set_name_np. * sys/systhread.c: Include <pthread_np.h> and call pthread_set_name_np if available.
2020-02-03Cater for 3-argument version of pthread_setname_npRobert Pluim
Fixes Bug#39363. * configure.ac: Add check for 3-argument version of pthread_setname_np. * src/systhread.c (sys_thread_set_name) [HAVE_PTHREAD_SETNAME_NP_3ARG]: Call pthread_setname_np with 3 arguments.
2020-01-08Fix another compilation problem in a build without threadsEli Zaretskii
* src/systhread.c (sys_thread_set_name) [!THREADS_ENABLED]: Add a trivial implementation.
2020-01-08Fix build without threadsEli Zaretskii
* src/systhread.c (sys_thread_create) [!THREADS_ENABLED]: Update the function's signature to match prototype. Reported by Glenn Morris <rgm@gnu.org>. (Bug#38632)
2020-01-07Fix BSD and macOS builds w.r.t. pthread_setname_np (bug#38632)Mattias Engdegård
pthread_setname_np takes only a single argument on BSD and macOS, and affects the current thread only. * configure.ac: Add check for single-argument pthread_setname_np * src/systhread.c (sys_thread_set_name): New (w32 and pthread versions). (sys_thread_create): Remove name argument and name-setting. (w32_beginthread_wrapper): Remove name-setting. * src/systhread.h (sys_thread_create, sys_thread_set_name): Update prototypes. * src/thread.c (run_thread): Call sys_thread_set_name. (Fmake_thread): Adapt call to sys_thread_create. * src/thread.h (struct thread_state): Adjust comment.
2020-01-06Use pthread_setname_np to set thread nameRobert Pluim
* configure.ac: Remove check for sys/prctl.h and prctl, check for pthread_setname_np instead. * systhread.c: Remove sys/prctl.h include. (sys_thread_create) [HAVE_PTHREAD_SETNAME_NP]: Use pthread_setname_np to set the name of the newly created thread (Bug#38632). * thread.c (Fmake_thread): Use ENCODE_SYSTEM instead of ENCODE_UTF_8 on the thread name.
2020-01-01Update copyright year to 2020Paul Eggert
Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
2019-12-20Support setting OS names of threads on MS-WindowsEli Zaretskii
* src/w32fns.c (setup_w32_kbdhook): Don't initialize is_debugger_present here... (globals_of_w32fns): ...initialize it here. Also initialize the new global variable set_thread_description. * src/systhread.c: [WINDOWSNT] Include mbctype.h (w32_set_thread_name): New function. (MS_VC_EXCEPTION): New macro. (THREADNAME_INFO, IsDebuggerPresent_Proc) (SetThreadDescription_Proc): New typedefs. (w32_beginthread_wrapper): Call w32_set_thread_name to set the name of the new thread. * src/thread.h (struct thread_state): New member thread_name. * src/thread.c (Fmake_thread): Set the thread_name field of the new thread object. (run_thread): Free the thread_name member after the thread exits.
2018-12-31Merge from origin/emacs-26Paul Eggert
2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
2019-01-01Update copyright year to 2019Paul Eggert
Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
2018-06-09Make error checking for thread functions stricter.Philipp Stephani
* src/systhread.c (sys_thread_create): Change return type to bool. Check for errors returned by pthread_attr_setstacksize and pthread_attr_destroy. (sys_mutex_init): Abort on errors. Enable mutex checks when checking is enabled. (sys_cond_init): Abort on errors. (sys_mutex_lock, sys_mutex_unlock, sys_cond_wait) (sys_cond_signal, sys_cond_broadcast, sys_cond_destroy): Check for errors in debug mode.
2018-02-28Require a larger stack size for threads on macOS (bug#30364)Paul Eggert
* src/systhread.c (sys_thread_create) [THREADS_ENABLED && HAVE_PTHREAD && DARWIN_OS]: Require at least 8MB stack size for x64 and 4MB for x86 on macOS. Do not merge to master.
2018-02-27Require a larger stack size for threads (bug#30364)Aaron Jensen
* src/systhread.c (sys_thread_create) [THREADS_ENABLED && HAVE_PTHREAD]: Require at least 8MB stack size for x64 and 4MB for x86.
2018-01-18Fix module support if threads are disabled (Bug#30106)Philipp Stephani
* src/systhread.c (sys_thread_equal): New function. * src/thread.c (in_current_thread): Move from emacs-module.c; use sys_thread_equal.
2018-01-01Update copyright year to 2018Paul Eggert
Run admin/update-copyright.
2017-10-14Make sure thread stack is properly aligned on MS-WindowsEli Zaretskii
* src/systhread.c: Include w32term.h instead of windows.h. (w32_beginthread_wrapper): Add ALIGN_STACK attribute, to ensure the thread's stack is correctly aligned. * src/w32term.h (ALIGN_STACK): Update commentary.
2017-09-13Prefer HTTPS to FTP and HTTP in documentationPaul Eggert
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.
2017-07-01Fix threads on NS (bug#25265)Alan Third
src/nsterm.h (ns_select): Compiler doesn't like sigmask being const. (ns_run_loop_break) [HAVE_PTHREAD]: New function. src/nsterm.m (ns_select): Call thread_select from within ns_select. (ns_run_loop_break) [HAVE_PTHREAD]: New function. (ns_send_appdefined): Don't wait for main thread when sending app defined event. src/process.c (wait_reading_process_output): Call thread_select from within ns_select. src/systhread.c (sys_cond_broadcast) [HAVE_NS]: Break ns_select out of its event loop using ns_run_loop_break.
2017-02-26Remove a few unused C functionsPaul Eggert
* src/eval.c (let_shadows_global_binding_p): * src/print.c (write_string): * src/systhread.c (sys_mutex_destroy, sys_thread_equal): Remove. * src/print.c (write_string): Rename from write_string_1. All uses changed.
2017-01-01Update copyright year to 2017 in masterPaul Eggert
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.
2016-12-22; Spelling fixesPaul Eggert
2016-12-10; Fix copyright years in new filesGlenn Morris
2015-11-03; * src/systhread.c [WINDOWSNT]: Fix typos in comments.Eli Zaretskii
2013-08-31Improve MS-Windows implementation of threads.Eli Zaretskii
src/systhread.c (sys_cond_init): Set the 'initialized' member to true only if initialization is successful. Initialize wait_count and wait_count_lock. (sys_cond_wait, sys_cond_signal, sys_cond_broadcast): If 'initialized' is false, do nothing. (sys_cond_wait): Fix the implementation to avoid the "missed wakeup" bug: count the waiting threads, and reset the broadcast event once the last thread was released. (sys_cond_signal, sys_cond_broadcast): Use SetEvent instead of PulseEvent. Don't signal the event if no threads are waiting. (sys_cond_destroy): Only close non-NULL handles. (sys_thread_create): Return zero if unsuccessful, 1 if successful. src/systhread.h (w32thread_cond_t): New member 'initialized'. Rename waiters_count and waiters_count_lock to wait_count and wait_count_lock, respectively.
2013-08-30Enable thread support in the MS-Windows build.Eli Zaretskii
src/systhread.h (w32thread_critsect, w32thread_cond_t, sys_mutex_t) (sys_cond_t, sys_thread_t) [WINDOWSNT]: New data types. src/systhread.c (sys_mutex_init, sys_mutex_lock, sys_mutex_unlock) (sys_mutex_destroy, sys_cond_init, sys_cond_wait) (sys_cond_signal, sys_cond_broadcast, sys_cond_destroy) (sys_thread_self, sys_thread_equal, w32_beginthread_wrapper) (sys_thread_create, sys_thread_yield) [WINDOWSNT]: New functions. configure.ac (THREADS_ENABLED): Enable threads for MinGW, even if pthreads is not available.
2013-08-26implement --enable-threads and a thread-less modeTom Tromey
2012-08-20pass the thread name to the OS if possibleTom Tromey
use prctl to pass the thread name to the OS, if possible
2012-08-18refactor systhread.hTom Tromey
This refactors systhread.h to move the notion of a "lisp mutex" into thread.c. This lets us make make the global lock and post_acquire_global_lock static.
2012-08-15This adds most of the thread features visible to emacs lisp.Tom Tromey
I roughly followed the Bordeaux threads API: http://trac.common-lisp.net/bordeaux-threads/wiki/ApiDocumentation ... but not identically. In particular I chose not to implement interrupt-thread or destroy-thread, but instead a thread-signalling approach. I'm still undecided about *default-special-bindings* (which I did not implement). I think it would be more emacs-like to capture the let bindings at make-thread time, but IIRC Stefan didn't like this idea the first time around. There are one or two semantics issues pointed out in the patch where I could use some advice.
2012-08-15This introduces the low-level system threading support. It also addsTom Tromey
the global lock. The low-level support is a bit over-eager, in that even at the end of the present series, it will not all be used. I think thiat is ok since I plan to use it all eventually -- in particular for the emacs lisp mutex implementation. I've only implemented the pthreads-based version. I think it should be relatively clear how to port this to other systems, though. I'd also like to do a "no threads" port that will turn most things into no-ops, and have thread-creation fail. I was thinking perhaps I'd make a future (provide 'threads) conditional on threads actually working. One other minor enhancement available here is to make it possible to set the name of the new thread at the OS layer. That way gdb, e.g., could display thread names.