diff options
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | src/systhread.c | 77 | ||||
-rw-r--r-- | src/systhread.h | 17 | ||||
-rw-r--r-- | src/thread.c | 41 |
4 files changed, 125 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac index bbd799cadee..6b22cd0cfab 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/systhread.c b/src/systhread.c index ab647528452..8c9ec438d96 100644 --- a/src/systhread.c +++ b/src/systhread.c @@ -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> diff --git a/src/systhread.h b/src/systhread.h index bbd242ab93c..eb9cde78b61 100644 --- a/src/systhread.h +++ b/src/systhread.h @@ -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 *); diff --git a/src/thread.c b/src/thread.c index 4c6b6543c84..59845b6524f 100644 --- a/src/thread.c +++ b/src/thread.c @@ -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); |