aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2018-01-17 23:28:46 +0100
committerPhilipp Stephani2018-01-18 20:14:36 +0100
commit694ee38f8b7bd10f1d0eae8cb251daea70b5c820 (patch)
tree53a4ebc808225e3c87bc8db48092e7f7ec8b7d92 /src
parentebc1eea87b1309544ccb1a8a3ce53698cc2355d6 (diff)
downloademacs-694ee38f8b7bd10f1d0eae8cb251daea70b5c820.tar.gz
emacs-694ee38f8b7bd10f1d0eae8cb251daea70b5c820.zip
Fix module support if threads are disabled (Bug#30106)
* src/systhread.c (sys_thread_equal): New function. * src/thread.c (in_current_thread): Move from emacs-module.c; use sys_thread_equal.
Diffstat (limited to 'src')
-rw-r--r--src/emacs-module.c12
-rw-r--r--src/systhread.c18
-rw-r--r--src/systhread.h1
-rw-r--r--src/thread.c8
-rw-r--r--src/thread.h1
5 files changed, 28 insertions, 12 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 4ee4014b4e1..3a85421e83a 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -805,18 +805,6 @@ module_function_arity (const struct Lisp_Module_Function *const function)
805 805
806/* Helper functions. */ 806/* Helper functions. */
807 807
808static bool
809in_current_thread (void)
810{
811 if (current_thread == NULL)
812 return false;
813#ifdef HAVE_PTHREAD
814 return pthread_equal (pthread_self (), current_thread->thread_id);
815#elif defined WINDOWSNT
816 return GetCurrentThreadId () == current_thread->thread_id;
817#endif
818}
819
820static void 808static void
821module_assert_thread (void) 809module_assert_thread (void)
822{ 810{
diff --git a/src/systhread.c b/src/systhread.c
index 4ffb7db143a..3f162a2bcbf 100644
--- a/src/systhread.c
+++ b/src/systhread.c
@@ -74,6 +74,12 @@ sys_thread_self (void)
74 return 0; 74 return 0;
75} 75}
76 76
77bool
78sys_thread_equal (sys_thread_t t, sys_thread_t u)
79{
80 return t == u;
81}
82
77int 83int
78sys_thread_create (sys_thread_t *t, const char *name, 84sys_thread_create (sys_thread_t *t, const char *name,
79 thread_creation_function *func, void *datum) 85 thread_creation_function *func, void *datum)
@@ -155,6 +161,12 @@ sys_thread_self (void)
155 return pthread_self (); 161 return pthread_self ();
156} 162}
157 163
164bool
165sys_thread_equal (sys_thread_t t, sys_thread_t u)
166{
167 return pthread_equal (t, u);
168}
169
158int 170int
159sys_thread_create (sys_thread_t *thread_ptr, const char *name, 171sys_thread_create (sys_thread_t *thread_ptr, const char *name,
160 thread_creation_function *func, void *arg) 172 thread_creation_function *func, void *arg)
@@ -323,6 +335,12 @@ sys_thread_self (void)
323 return (sys_thread_t) GetCurrentThreadId (); 335 return (sys_thread_t) GetCurrentThreadId ();
324} 336}
325 337
338bool
339sys_thread_equal (sys_thread_t t, sys_thread_t u)
340{
341 return t == u;
342}
343
326static thread_creation_function *thread_start_address; 344static thread_creation_function *thread_start_address;
327 345
328/* _beginthread wants a void function, while we are passed a function 346/* _beginthread wants a void function, while we are passed a function
diff --git a/src/systhread.h b/src/systhread.h
index 4745d220654..5dbb12dffb6 100644
--- a/src/systhread.h
+++ b/src/systhread.h
@@ -100,6 +100,7 @@ extern void sys_cond_broadcast (sys_cond_t *);
100extern void sys_cond_destroy (sys_cond_t *); 100extern void sys_cond_destroy (sys_cond_t *);
101 101
102extern sys_thread_t sys_thread_self (void); 102extern sys_thread_t sys_thread_self (void);
103extern bool sys_thread_equal (sys_thread_t, sys_thread_t);
103 104
104extern int sys_thread_create (sys_thread_t *, const char *, 105extern int sys_thread_create (sys_thread_t *, const char *,
105 thread_creation_function *, 106 thread_creation_function *,
diff --git a/src/thread.c b/src/thread.c
index 60902b252b4..f11e3e5addb 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -1022,6 +1022,14 @@ main_thread_p (void *ptr)
1022 return ptr == &main_thread; 1022 return ptr == &main_thread;
1023} 1023}
1024 1024
1025bool
1026in_current_thread (void)
1027{
1028 if (current_thread == NULL)
1029 return false;
1030 return sys_thread_equal (sys_thread_self (), current_thread->thread_id);
1031}
1032
1025void 1033void
1026init_threads_once (void) 1034init_threads_once (void)
1027{ 1035{
diff --git a/src/thread.h b/src/thread.h
index 5746512b799..5ab5e90c70d 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -303,6 +303,7 @@ extern void init_threads_once (void);
303extern void init_threads (void); 303extern void init_threads (void);
304extern void syms_of_threads (void); 304extern void syms_of_threads (void);
305extern bool main_thread_p (void *); 305extern bool main_thread_p (void *);
306extern bool in_current_thread (void);
306 307
307typedef int select_func (int, fd_set *, fd_set *, fd_set *, 308typedef int select_func (int, fd_set *, fd_set *, fd_set *,
308 const struct timespec *, const sigset_t *); 309 const struct timespec *, const sigset_t *);