aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Tromey2013-08-26 08:46:30 -0600
committerTom Tromey2013-08-26 08:46:30 -0600
commit2ee7755c8d35aba1d598c9baa910bd5af228f095 (patch)
tree0eb4817057fef64fb07767f8b025b4d47fb80cb6
parent793ea5055aea85ff9227e1bf0c84ab37edba7201 (diff)
downloademacs-2ee7755c8d35aba1d598c9baa910bd5af228f095.tar.gz
emacs-2ee7755c8d35aba1d598c9baa910bd5af228f095.zip
implement --enable-threads and a thread-less mode
-rw-r--r--configure.ac13
-rw-r--r--src/systhread.c77
-rw-r--r--src/systhread.h17
-rw-r--r--src/thread.c41
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])
237OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support]) 237OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
238OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support]) 238OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
239OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support]) 239OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
240OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support])
240 241
241AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB], 242AC_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
1949AC_CHECK_LIB(pthreads, cma_open) 1950AC_CHECK_LIB(pthreads, cma_open)
1950 1951
1952AC_MSG_CHECKING([for thread support])
1953threads_enabled=no
1954if 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
1960fi
1961AC_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}"
4843echo " Does Emacs directly use zlib? ${HAVE_ZLIB}" 4855echo " Does Emacs directly use zlib? ${HAVE_ZLIB}"
4844 4856
4845echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}" 4857echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}"
4858echo " Does Emacs have threading support in elisp? ${threads_enabled}"
4846echo 4859echo
4847 4860
4848if test -n "${EMACSDATA}"; then 4861if 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
4This file is part of GNU Emacs. 4This 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
25void
26sys_mutex_init (sys_mutex_t *m)
27{
28 *m = 0;
29}
30
31void
32sys_mutex_lock (sys_mutex_t *m)
33{
34}
35
36void
37sys_mutex_unlock (sys_mutex_t *m)
38{
39}
40
41void
42sys_mutex_destroy (sys_mutex_t *m)
43{
44}
45
46void
47sys_cond_init (sys_cond_t *c)
48{
49 *c = 0;
50}
51
52void
53sys_cond_wait (sys_cond_t *c, sys_mutex_t *m)
54{
55}
56
57void
58sys_cond_signal (sys_cond_t *c)
59{
60}
61
62void
63sys_cond_broadcast (sys_cond_t *c)
64{
65}
66
67void
68sys_cond_destroy (sys_cond_t *c)
69{
70}
71
72sys_thread_t
73sys_thread_self (void)
74{
75 return 0;
76}
77
78int
79sys_thread_equal (sys_thread_t x, sys_thread_t y)
80{
81 return x == y;
82}
83
84int
85sys_thread_create (sys_thread_t *t, const char *name,
86 thread_creation_function *func, void *datum)
87{
88 return 0;
89}
90
91void
92sys_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
4This file is part of GNU Emacs. 4This 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. */
33typedef pthread_t sys_thread_t; 35typedef 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. */
46typedef int sys_mutex_t;
47typedef int sys_cond_t;
48typedef int sys_thread_t;
49
50#endif /* THREADS_ENABLED */
40 51
41typedef void *(thread_creation_function) (void *); 52typedef 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)
937void 937void
938syms_of_threads (void) 938syms_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);