diff options
| author | Eli Zaretskii | 2019-12-20 20:59:07 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-12-20 20:59:07 +0200 |
| commit | 0e19b5d757d88eedd23709a4ea40aa1512a1ff21 (patch) | |
| tree | 5ab479668337f979c29e41e9254fa609d463391c /src/thread.c | |
| parent | 85a60da92d4db5c87ecfa152501d246425550fc3 (diff) | |
| download | emacs-0e19b5d757d88eedd23709a4ea40aa1512a1ff21.tar.gz emacs-0e19b5d757d88eedd23709a4ea40aa1512a1ff21.zip | |
Support setting OS names of threads on MS-Windows
* 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.
Diffstat (limited to 'src/thread.c')
| -rw-r--r-- | src/thread.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c index e2deadd7a83..42c2bf52d28 100644 --- a/src/thread.c +++ b/src/thread.c | |||
| @@ -756,6 +756,8 @@ run_thread (void *state) | |||
| 756 | } | 756 | } |
| 757 | } | 757 | } |
| 758 | 758 | ||
| 759 | xfree (self->thread_name); | ||
| 760 | |||
| 759 | current_thread = NULL; | 761 | current_thread = NULL; |
| 760 | sys_cond_broadcast (&self->thread_condvar); | 762 | sys_cond_broadcast (&self->thread_condvar); |
| 761 | 763 | ||
| @@ -825,6 +827,10 @@ If NAME is given, it must be a string; it names the new thread. */) | |||
| 825 | all_threads = new_thread; | 827 | all_threads = new_thread; |
| 826 | 828 | ||
| 827 | char const *c_name = !NILP (name) ? SSDATA (ENCODE_UTF_8 (name)) : NULL; | 829 | char const *c_name = !NILP (name) ? SSDATA (ENCODE_UTF_8 (name)) : NULL; |
| 830 | if (c_name) | ||
| 831 | new_thread->thread_name = xstrdup (c_name); | ||
| 832 | else | ||
| 833 | new_thread->thread_name = NULL; | ||
| 828 | sys_thread_t thr; | 834 | sys_thread_t thr; |
| 829 | if (! sys_thread_create (&thr, c_name, run_thread, new_thread)) | 835 | if (! sys_thread_create (&thr, c_name, run_thread, new_thread)) |
| 830 | { | 836 | { |