1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 08:43:40 -07:00

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.
This commit is contained in:
Philipp Stephani 2018-01-17 23:28:46 +01:00 committed by Philipp Stephani
parent ebc1eea87b
commit 694ee38f8b
5 changed files with 28 additions and 12 deletions

View file

@ -805,18 +805,6 @@ module_function_arity (const struct Lisp_Module_Function *const function)
/* 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)
{

View 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

View 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 *,

View 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)
{

View 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 *);