diff options
| author | Tom Tromey | 2013-08-26 08:46:30 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-08-26 08:46:30 -0600 |
| commit | 2ee7755c8d35aba1d598c9baa910bd5af228f095 (patch) | |
| tree | 0eb4817057fef64fb07767f8b025b4d47fb80cb6 | |
| parent | 793ea5055aea85ff9227e1bf0c84ab37edba7201 (diff) | |
| download | emacs-2ee7755c8d35aba1d598c9baa910bd5af228f095.tar.gz emacs-2ee7755c8d35aba1d598c9baa910bd5af228f095.zip | |
implement --enable-threads and a thread-less mode
| -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]) | |||
| 237 | OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support]) | 237 | OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support]) |
| 238 | OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support]) | 238 | OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support]) |
| 239 | OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support]) | 239 | OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support]) |
| 240 | OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support]) | ||
| 240 | 241 | ||
| 241 | AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB], | 242 | AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB], |
| 242 | [use a file notification library (LIB one of: yes, gfile, inotify, w32, no)])], | 243 | [use a file notification library (LIB one of: yes, gfile, inotify, w32, no)])], |
| @@ -1948,6 +1949,17 @@ AC_SUBST([LIB_PTHREAD]) | |||
| 1948 | 1949 | ||
| 1949 | AC_CHECK_LIB(pthreads, cma_open) | 1950 | AC_CHECK_LIB(pthreads, cma_open) |
| 1950 | 1951 | ||
| 1952 | AC_MSG_CHECKING([for thread support]) | ||
| 1953 | threads_enabled=no | ||
| 1954 | if test "$with_threads" = yes; then | ||
| 1955 | if test "$HAVE_PTHREAD" = yes; then | ||
| 1956 | AC_DEFINE(THREADS_ENABLED, 1, | ||
| 1957 | [Define to 1 if you want elisp thread support.]) | ||
| 1958 | threads_enabled=yes | ||
| 1959 | fi | ||
| 1960 | fi | ||
| 1961 | AC_MSG_RESULT([$threads_enabled]) | ||
| 1962 | |||
| 1951 | ## Note: when using cpp in s/aix4.2.h, this definition depended on | 1963 | ## Note: when using cpp in s/aix4.2.h, this definition depended on |
| 1952 | ## HAVE_LIBPTHREADS. That was not defined earlier in configure when | 1964 | ## HAVE_LIBPTHREADS. That was not defined earlier in configure when |
| 1953 | ## the system file was sourced. Hence the value of LIBS_SYSTEM | 1965 | ## the system file was sourced. Hence the value of LIBS_SYSTEM |
| @@ -4843,6 +4855,7 @@ echo " Does Emacs use -lxft? ${HAVE_XFT}" | |||
| 4843 | echo " Does Emacs directly use zlib? ${HAVE_ZLIB}" | 4855 | echo " Does Emacs directly use zlib? ${HAVE_ZLIB}" |
| 4844 | 4856 | ||
| 4845 | echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}" | 4857 | echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}" |
| 4858 | echo " Does Emacs have threading support in elisp? ${threads_enabled}" | ||
| 4846 | echo | 4859 | echo |
| 4847 | 4860 | ||
| 4848 | if test -n "${EMACSDATA}"; then | 4861 | 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 @@ | |||
| 1 | /* System thread definitions | 1 | /* System thread definitions |
| 2 | Copyright (C) 2012 Free Software Foundation, Inc. | 2 | Copyright (C) 2012, 2013 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -20,7 +20,80 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 20 | #include <setjmp.h> | 20 | #include <setjmp.h> |
| 21 | #include "lisp.h" | 21 | #include "lisp.h" |
| 22 | 22 | ||
| 23 | #ifdef HAVE_PTHREAD | 23 | #ifndef THREADS_ENABLED |
| 24 | |||
| 25 | void | ||
| 26 | sys_mutex_init (sys_mutex_t *m) | ||
| 27 | { | ||
| 28 | *m = 0; | ||
| 29 | } | ||
| 30 | |||
| 31 | void | ||
| 32 | sys_mutex_lock (sys_mutex_t *m) | ||
| 33 | { | ||
| 34 | } | ||
| 35 | |||
| 36 | void | ||
| 37 | sys_mutex_unlock (sys_mutex_t *m) | ||
| 38 | { | ||
| 39 | } | ||
| 40 | |||
| 41 | void | ||
| 42 | sys_mutex_destroy (sys_mutex_t *m) | ||
| 43 | { | ||
| 44 | } | ||
| 45 | |||
| 46 | void | ||
| 47 | sys_cond_init (sys_cond_t *c) | ||
| 48 | { | ||
| 49 | *c = 0; | ||
| 50 | } | ||
| 51 | |||
| 52 | void | ||
| 53 | sys_cond_wait (sys_cond_t *c, sys_mutex_t *m) | ||
| 54 | { | ||
| 55 | } | ||
| 56 | |||
| 57 | void | ||
| 58 | sys_cond_signal (sys_cond_t *c) | ||
| 59 | { | ||
| 60 | } | ||
| 61 | |||
| 62 | void | ||
| 63 | sys_cond_broadcast (sys_cond_t *c) | ||
| 64 | { | ||
| 65 | } | ||
| 66 | |||
| 67 | void | ||
| 68 | sys_cond_destroy (sys_cond_t *c) | ||
| 69 | { | ||
| 70 | } | ||
| 71 | |||
| 72 | sys_thread_t | ||
| 73 | sys_thread_self (void) | ||
| 74 | { | ||
| 75 | return 0; | ||
| 76 | } | ||
| 77 | |||
| 78 | int | ||
| 79 | sys_thread_equal (sys_thread_t x, sys_thread_t y) | ||
| 80 | { | ||
| 81 | return x == y; | ||
| 82 | } | ||
| 83 | |||
| 84 | int | ||
| 85 | sys_thread_create (sys_thread_t *t, const char *name, | ||
| 86 | thread_creation_function *func, void *datum) | ||
| 87 | { | ||
| 88 | return 0; | ||
| 89 | } | ||
| 90 | |||
| 91 | void | ||
| 92 | sys_thread_yield (void) | ||
| 93 | { | ||
| 94 | } | ||
| 95 | |||
| 96 | #elif defined (HAVE_PTHREAD) | ||
| 24 | 97 | ||
| 25 | #include <sched.h> | 98 | #include <sched.h> |
| 26 | 99 | ||
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 @@ | |||
| 1 | /* System thread definitions | 1 | /* System thread definitions |
| 2 | Copyright (C) 2012 Free Software Foundation, Inc. | 2 | Copyright (C) 2012, 2013 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 19 | #ifndef SYSTHREAD_H | 19 | #ifndef SYSTHREAD_H |
| 20 | #define SYSTHREAD_H | 20 | #define SYSTHREAD_H |
| 21 | 21 | ||
| 22 | #ifdef THREADS_ENABLED | ||
| 23 | |||
| 22 | #ifdef HAVE_PTHREAD | 24 | #ifdef HAVE_PTHREAD |
| 23 | 25 | ||
| 24 | #include <pthread.h> | 26 | #include <pthread.h> |
| @@ -32,11 +34,20 @@ typedef pthread_cond_t sys_cond_t; | |||
| 32 | /* A system thread. */ | 34 | /* A system thread. */ |
| 33 | typedef pthread_t sys_thread_t; | 35 | typedef pthread_t sys_thread_t; |
| 34 | 36 | ||
| 35 | #else | 37 | #else /* HAVE_PTHREAD */ |
| 36 | 38 | ||
| 37 | #error port me | 39 | #error port me |
| 38 | 40 | ||
| 39 | #endif | 41 | #endif /* HAVE_PTHREAD */ |
| 42 | |||
| 43 | #else /* THREADS_ENABLED */ | ||
| 44 | |||
| 45 | /* For the no-threads case we can simply use dummy definitions. */ | ||
| 46 | typedef int sys_mutex_t; | ||
| 47 | typedef int sys_cond_t; | ||
| 48 | typedef int sys_thread_t; | ||
| 49 | |||
| 50 | #endif /* THREADS_ENABLED */ | ||
| 40 | 51 | ||
| 41 | typedef void *(thread_creation_function) (void *); | 52 | typedef void *(thread_creation_function) (void *); |
| 42 | 53 | ||
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) | |||
| 937 | void | 937 | void |
| 938 | syms_of_threads (void) | 938 | syms_of_threads (void) |
| 939 | { | 939 | { |
| 940 | defsubr (&Sthread_yield); | 940 | #ifndef THREADS_ENABLED |
| 941 | defsubr (&Smake_thread); | 941 | if (0) |
| 942 | defsubr (&Scurrent_thread); | 942 | #endif |
| 943 | defsubr (&Sthread_name); | 943 | { |
| 944 | defsubr (&Sthread_signal); | 944 | defsubr (&Sthread_yield); |
| 945 | defsubr (&Sthread_alive_p); | 945 | defsubr (&Smake_thread); |
| 946 | defsubr (&Sthread_join); | 946 | defsubr (&Scurrent_thread); |
| 947 | defsubr (&Sthread_blocker); | 947 | defsubr (&Sthread_name); |
| 948 | defsubr (&Sall_threads); | 948 | defsubr (&Sthread_signal); |
| 949 | defsubr (&Smake_mutex); | 949 | defsubr (&Sthread_alive_p); |
| 950 | defsubr (&Smutex_lock); | 950 | defsubr (&Sthread_join); |
| 951 | defsubr (&Smutex_unlock); | 951 | defsubr (&Sthread_blocker); |
| 952 | defsubr (&Smutex_name); | 952 | defsubr (&Sall_threads); |
| 953 | defsubr (&Smake_condition_variable); | 953 | defsubr (&Smake_mutex); |
| 954 | defsubr (&Scondition_wait); | 954 | defsubr (&Smutex_lock); |
| 955 | defsubr (&Scondition_notify); | 955 | defsubr (&Smutex_unlock); |
| 956 | defsubr (&Scondition_mutex); | 956 | defsubr (&Smutex_name); |
| 957 | defsubr (&Scondition_name); | 957 | defsubr (&Smake_condition_variable); |
| 958 | defsubr (&Scondition_wait); | ||
| 959 | defsubr (&Scondition_notify); | ||
| 960 | defsubr (&Scondition_mutex); | ||
| 961 | defsubr (&Scondition_name); | ||
| 962 | } | ||
| 958 | 963 | ||
| 959 | Qthreadp = intern_c_string ("threadp"); | 964 | Qthreadp = intern_c_string ("threadp"); |
| 960 | staticpro (&Qthreadp); | 965 | staticpro (&Qthreadp); |