]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix module support if threads are disabled (Bug#30106)
authorPhilipp Stephani <p.stephani2@gmail.com>
Wed, 17 Jan 2018 22:28:46 +0000 (23:28 +0100)
committerPhilipp Stephani <phst@google.com>
Thu, 18 Jan 2018 19:14:36 +0000 (20:14 +0100)
* src/systhread.c (sys_thread_equal): New function.
* src/thread.c (in_current_thread): Move from emacs-module.c; use
sys_thread_equal.

src/emacs-module.c
src/systhread.c
src/systhread.h
src/thread.c
src/thread.h

index 4ee4014b4e19eaa9353d6bc7bb726eba0b18d396..3a85421e83a9487cc7b954d822f71b7dcdbc9409 100644 (file)
@@ -805,18 +805,6 @@ module_function_arity (const struct Lisp_Module_Function *const function)
 \f
 /* Helper functions.  */
 
-static bool
-in_current_thread (void)
-{
-  if (current_thread == NULL)
-    return false;
-#ifdef HAVE_PTHREAD
-  return pthread_equal (pthread_self (), current_thread->thread_id);
-#elif defined WINDOWSNT
-  return GetCurrentThreadId () == current_thread->thread_id;
-#endif
-}
-
 static void
 module_assert_thread (void)
 {
index 4ffb7db143a052aced0e672919f1735c5e91f5f2..3f162a2bcbfde5942d33eb09ca671507bb52845f 100644 (file)
@@ -74,6 +74,12 @@ sys_thread_self (void)
   return 0;
 }
 
+bool
+sys_thread_equal (sys_thread_t t, sys_thread_t u)
+{
+  return t == u;
+}
+
 int
 sys_thread_create (sys_thread_t *t, const char *name,
                   thread_creation_function *func, void *datum)
@@ -155,6 +161,12 @@ sys_thread_self (void)
   return pthread_self ();
 }
 
+bool
+sys_thread_equal (sys_thread_t t, sys_thread_t u)
+{
+  return pthread_equal (t, u);
+}
+
 int
 sys_thread_create (sys_thread_t *thread_ptr, const char *name,
                   thread_creation_function *func, void *arg)
@@ -323,6 +335,12 @@ sys_thread_self (void)
   return (sys_thread_t) GetCurrentThreadId ();
 }
 
+bool
+sys_thread_equal (sys_thread_t t, sys_thread_t u)
+{
+  return t == u;
+}
+
 static thread_creation_function *thread_start_address;
 
 /* _beginthread wants a void function, while we are passed a function
index 4745d22065421732ecde4fe1444f422a0cd5fa08..5dbb12dffb620e95e4b84266d980405361d00550 100644 (file)
@@ -100,6 +100,7 @@ extern void sys_cond_broadcast (sys_cond_t *);
 extern void sys_cond_destroy (sys_cond_t *);
 
 extern sys_thread_t sys_thread_self (void);
+extern bool sys_thread_equal (sys_thread_t, sys_thread_t);
 
 extern int sys_thread_create (sys_thread_t *, const char *,
                              thread_creation_function *,
index 60902b252b424b73cf773bd113a45c2f1574209b..f11e3e5addb13a10fd43d05615d419a5325ff645 100644 (file)
@@ -1022,6 +1022,14 @@ main_thread_p (void *ptr)
   return ptr == &main_thread;
 }
 
+bool
+in_current_thread (void)
+{
+  if (current_thread == NULL)
+    return false;
+  return sys_thread_equal (sys_thread_self (), current_thread->thread_id);
+}
+
 void
 init_threads_once (void)
 {
index 5746512b799a7e4e8ff7cd9e8937dd45a159608f..5ab5e90c70d17e4baa2ff7ef683500259779b438 100644 (file)
@@ -303,6 +303,7 @@ extern void init_threads_once (void);
 extern void init_threads (void);
 extern void syms_of_threads (void);
 extern bool main_thread_p (void *);
+extern bool in_current_thread (void);
 
 typedef int select_func (int, fd_set *, fd_set *, fd_set *,
                         const struct timespec *, const sigset_t *);