implement --enable-threads and a thread-less mode

This commit is contained in:
Tom Tromey 2013-08-26 08:46:30 -06:00
parent 793ea5055a
commit 2ee7755c8d
4 changed files with 125 additions and 23 deletions

View file

@ -237,6 +237,7 @@ OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support])
AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
[use a file notification library (LIB one of: yes, gfile, inotify, w32, no)])],
@ -1948,6 +1949,17 @@ AC_SUBST([LIB_PTHREAD])
AC_CHECK_LIB(pthreads, cma_open)
AC_MSG_CHECKING([for thread support])
threads_enabled=no
if test "$with_threads" = yes; then
if test "$HAVE_PTHREAD" = yes; then
AC_DEFINE(THREADS_ENABLED, 1,
[Define to 1 if you want elisp thread support.])
threads_enabled=yes
fi
fi
AC_MSG_RESULT([$threads_enabled])
## Note: when using cpp in s/aix4.2.h, this definition depended on
## HAVE_LIBPTHREADS. That was not defined earlier in configure when
## the system file was sourced. Hence the value of LIBS_SYSTEM
@ -4843,6 +4855,7 @@ echo " Does Emacs use -lxft? ${HAVE_XFT}"
echo " Does Emacs directly use zlib? ${HAVE_ZLIB}"
echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}"
echo " Does Emacs have threading support in elisp? ${threads_enabled}"
echo
if test -n "${EMACSDATA}"; then

View file

@ -1,5 +1,5 @@
/* System thread definitions
Copyright (C) 2012 Free Software Foundation, Inc.
Copyright (C) 2012, 2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@ -20,7 +20,80 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
#ifdef HAVE_PTHREAD
#ifndef THREADS_ENABLED
void
sys_mutex_init (sys_mutex_t *m)
{
*m = 0;
}
void
sys_mutex_lock (sys_mutex_t *m)
{
}
void
sys_mutex_unlock (sys_mutex_t *m)
{
}
void
sys_mutex_destroy (sys_mutex_t *m)
{
}
void
sys_cond_init (sys_cond_t *c)
{
*c = 0;
}
void
sys_cond_wait (sys_cond_t *c, sys_mutex_t *m)
{
}
void
sys_cond_signal (sys_cond_t *c)
{
}
void
sys_cond_broadcast (sys_cond_t *c)
{
}
void
sys_cond_destroy (sys_cond_t *c)
{
}
sys_thread_t
sys_thread_self (void)
{
return 0;
}
int
sys_thread_equal (sys_thread_t x, sys_thread_t y)
{
return x == y;
}
int
sys_thread_create (sys_thread_t *t, const char *name,
thread_creation_function *func, void *datum)
{
return 0;
}
void
sys_thread_yield (void)
{
}
#elif defined (HAVE_PTHREAD)
#include <sched.h>

View file

@ -1,5 +1,5 @@
/* System thread definitions
Copyright (C) 2012 Free Software Foundation, Inc.
Copyright (C) 2012, 2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifndef SYSTHREAD_H
#define SYSTHREAD_H
#ifdef THREADS_ENABLED
#ifdef HAVE_PTHREAD
#include <pthread.h>
@ -32,11 +34,20 @@ typedef pthread_cond_t sys_cond_t;
/* A system thread. */
typedef pthread_t sys_thread_t;
#else
#else /* HAVE_PTHREAD */
#error port me
#endif
#endif /* HAVE_PTHREAD */
#else /* THREADS_ENABLED */
/* For the no-threads case we can simply use dummy definitions. */
typedef int sys_mutex_t;
typedef int sys_cond_t;
typedef int sys_thread_t;
#endif /* THREADS_ENABLED */
typedef void *(thread_creation_function) (void *);

View file

@ -937,24 +937,29 @@ init_threads (void)
void
syms_of_threads (void)
{
defsubr (&Sthread_yield);
defsubr (&Smake_thread);
defsubr (&Scurrent_thread);
defsubr (&Sthread_name);
defsubr (&Sthread_signal);
defsubr (&Sthread_alive_p);
defsubr (&Sthread_join);
defsubr (&Sthread_blocker);
defsubr (&Sall_threads);
defsubr (&Smake_mutex);
defsubr (&Smutex_lock);
defsubr (&Smutex_unlock);
defsubr (&Smutex_name);
defsubr (&Smake_condition_variable);
defsubr (&Scondition_wait);
defsubr (&Scondition_notify);
defsubr (&Scondition_mutex);
defsubr (&Scondition_name);
#ifndef THREADS_ENABLED
if (0)
#endif
{
defsubr (&Sthread_yield);
defsubr (&Smake_thread);
defsubr (&Scurrent_thread);
defsubr (&Sthread_name);
defsubr (&Sthread_signal);
defsubr (&Sthread_alive_p);
defsubr (&Sthread_join);
defsubr (&Sthread_blocker);
defsubr (&Sall_threads);
defsubr (&Smake_mutex);
defsubr (&Smutex_lock);
defsubr (&Smutex_unlock);
defsubr (&Smutex_name);
defsubr (&Smake_condition_variable);
defsubr (&Scondition_wait);
defsubr (&Scondition_notify);
defsubr (&Scondition_mutex);
defsubr (&Scondition_name);
}
Qthreadp = intern_c_string ("threadp");
staticpro (&Qthreadp);