diff options
| author | Tom Tromey | 2012-08-15 13:07:04 -0600 |
|---|---|---|
| committer | Tom Tromey | 2012-08-15 13:07:04 -0600 |
| commit | 60a9d2a7728895c1a5bfbc37c3bfa8fde35abe61 (patch) | |
| tree | 8cecdc7d91f6eb803ce132c4667052de465f9177 /src | |
| parent | e160922c665ba65e1dba5b87a924927e61be43b9 (diff) | |
| download | emacs-60a9d2a7728895c1a5bfbc37c3bfa8fde35abe61.tar.gz emacs-60a9d2a7728895c1a5bfbc37c3bfa8fde35abe61.zip | |
This turns thread_state into a pseudovector and updates various bits
of Emacs to cope.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 1 | ||||
| -rw-r--r-- | src/lisp.h | 3 | ||||
| -rw-r--r-- | src/print.c | 12 | ||||
| -rw-r--r-- | src/thread.c | 22 | ||||
| -rw-r--r-- | src/thread.h | 3 |
5 files changed, 38 insertions, 3 deletions
diff --git a/src/emacs.c b/src/emacs.c index 443fe594795..ca9f201e8f5 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1226,6 +1226,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1226 | if (!initialized) | 1226 | if (!initialized) |
| 1227 | { | 1227 | { |
| 1228 | init_alloc_once (); | 1228 | init_alloc_once (); |
| 1229 | init_threads_once (); | ||
| 1229 | init_obarray (); | 1230 | init_obarray (); |
| 1230 | init_eval_once (); | 1231 | init_eval_once (); |
| 1231 | init_charset_once (); | 1232 | init_charset_once (); |
diff --git a/src/lisp.h b/src/lisp.h index cbb5b51c783..2b3d40d3b29 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -365,6 +365,7 @@ enum pvec_type | |||
| 365 | PVEC_WINDOW_CONFIGURATION, | 365 | PVEC_WINDOW_CONFIGURATION, |
| 366 | PVEC_SUBR, | 366 | PVEC_SUBR, |
| 367 | PVEC_OTHER, | 367 | PVEC_OTHER, |
| 368 | PVEC_THREAD, | ||
| 368 | /* These last 4 are special because we OR them in fns.c:internal_equal, | 369 | /* These last 4 are special because we OR them in fns.c:internal_equal, |
| 369 | so they have to use a disjoint bit pattern: | 370 | so they have to use a disjoint bit pattern: |
| 370 | if (!(size & (PVEC_COMPILED | PVEC_CHAR_TABLE | 371 | if (!(size & (PVEC_COMPILED | PVEC_CHAR_TABLE |
| @@ -603,6 +604,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 603 | #define XSETCHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_CHAR_TABLE)) | 604 | #define XSETCHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_CHAR_TABLE)) |
| 604 | #define XSETBOOL_VECTOR(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_BOOL_VECTOR)) | 605 | #define XSETBOOL_VECTOR(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_BOOL_VECTOR)) |
| 605 | #define XSETSUB_CHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_SUB_CHAR_TABLE)) | 606 | #define XSETSUB_CHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_SUB_CHAR_TABLE)) |
| 607 | #define XSETTHREAD(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_THREAD)) | ||
| 606 | 608 | ||
| 607 | /* Convenience macros for dealing with Lisp arrays. */ | 609 | /* Convenience macros for dealing with Lisp arrays. */ |
| 608 | 610 | ||
| @@ -1701,6 +1703,7 @@ typedef struct { | |||
| 1701 | #define SUB_CHAR_TABLE_P(x) PSEUDOVECTORP (x, PVEC_SUB_CHAR_TABLE) | 1703 | #define SUB_CHAR_TABLE_P(x) PSEUDOVECTORP (x, PVEC_SUB_CHAR_TABLE) |
| 1702 | #define BOOL_VECTOR_P(x) PSEUDOVECTORP (x, PVEC_BOOL_VECTOR) | 1704 | #define BOOL_VECTOR_P(x) PSEUDOVECTORP (x, PVEC_BOOL_VECTOR) |
| 1703 | #define FRAMEP(x) PSEUDOVECTORP (x, PVEC_FRAME) | 1705 | #define FRAMEP(x) PSEUDOVECTORP (x, PVEC_FRAME) |
| 1706 | #define THREADP(x) PSEUDOVECTORP (x, PVEC_THREAD) | ||
| 1704 | 1707 | ||
| 1705 | /* Test for image (image . spec) */ | 1708 | /* Test for image (image . spec) */ |
| 1706 | #define IMAGEP(x) (CONSP (x) && EQ (XCAR (x), Qimage)) | 1709 | #define IMAGEP(x) (CONSP (x) && EQ (XCAR (x), Qimage)) |
diff --git a/src/print.c b/src/print.c index 23ad6c0a256..4537521b9fa 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1943,6 +1943,18 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1943 | } | 1943 | } |
| 1944 | PRINTCHAR ('>'); | 1944 | PRINTCHAR ('>'); |
| 1945 | } | 1945 | } |
| 1946 | else if (THREADP (obj)) | ||
| 1947 | { | ||
| 1948 | strout ("#<thread ", -1, -1, printcharfun); | ||
| 1949 | if (STRINGP (XTHREAD (obj)->name)) | ||
| 1950 | print_string (XTHREAD (obj)->name, printcharfun); | ||
| 1951 | else | ||
| 1952 | { | ||
| 1953 | int len = sprintf (buf, "%p", XTHREAD (obj)); | ||
| 1954 | strout (buf, len, len, printcharfun); | ||
| 1955 | } | ||
| 1956 | PRINTCHAR ('>'); | ||
| 1957 | } | ||
| 1946 | else | 1958 | else |
| 1947 | { | 1959 | { |
| 1948 | ptrdiff_t size = ASIZE (obj); | 1960 | ptrdiff_t size = ASIZE (obj); |
diff --git a/src/thread.c b/src/thread.c index 605a52cb2f9..7d2f81ec9ce 100644 --- a/src/thread.c +++ b/src/thread.c | |||
| @@ -32,7 +32,7 @@ sys_mutex_t global_lock; | |||
| 32 | static void | 32 | static void |
| 33 | mark_one_thread (struct thread_state *thread) | 33 | mark_one_thread (struct thread_state *thread) |
| 34 | { | 34 | { |
| 35 | register struct specbinding *bind; | 35 | struct specbinding *bind; |
| 36 | struct handler *handler; | 36 | struct handler *handler; |
| 37 | Lisp_Object tem; | 37 | Lisp_Object tem; |
| 38 | 38 | ||
| @@ -48,7 +48,7 @@ mark_one_thread (struct thread_state *thread) | |||
| 48 | mark_stack (thread->m_stack_bottom, thread->stack_top); | 48 | mark_stack (thread->m_stack_bottom, thread->stack_top); |
| 49 | #else | 49 | #else |
| 50 | { | 50 | { |
| 51 | register struct gcpro *tail; | 51 | struct gcpro *tail; |
| 52 | for (tail = thread->m_gcprolist; tail; tail = tail->next) | 52 | for (tail = thread->m_gcprolist; tail; tail = tail->next) |
| 53 | for (i = 0; i < tail->nvars; i++) | 53 | for (i = 0; i < tail->nvars; i++) |
| 54 | mark_object (tail->var[i]); | 54 | mark_object (tail->var[i]); |
| @@ -88,7 +88,13 @@ mark_threads_callback (void *ignore) | |||
| 88 | struct thread_state *iter; | 88 | struct thread_state *iter; |
| 89 | 89 | ||
| 90 | for (iter = all_threads; iter; iter = iter->next_thread) | 90 | for (iter = all_threads; iter; iter = iter->next_thread) |
| 91 | mark_one_thread (iter); | 91 | { |
| 92 | Lisp_Object thread_obj; | ||
| 93 | |||
| 94 | XSETTHREAD (thread_obj, iter); | ||
| 95 | mark_object (thread_obj); | ||
| 96 | mark_one_thread (iter); | ||
| 97 | } | ||
| 92 | } | 98 | } |
| 93 | 99 | ||
| 94 | void | 100 | void |
| @@ -108,6 +114,16 @@ unmark_threads (void) | |||
| 108 | } | 114 | } |
| 109 | 115 | ||
| 110 | void | 116 | void |
| 117 | init_threads_once (void) | ||
| 118 | { | ||
| 119 | the_only_thread.header.size | ||
| 120 | = PSEUDOVECSIZE (struct thread_state, m_gcprolist); | ||
| 121 | XSETPVECTYPE (&the_only_thread, PVEC_THREAD); | ||
| 122 | the_only_thread.m_last_thing_searched = Qnil; | ||
| 123 | the_only_thread.m_saved_last_thing_searched = Qnil; | ||
| 124 | } | ||
| 125 | |||
| 126 | void | ||
| 111 | init_threads (void) | 127 | init_threads (void) |
| 112 | { | 128 | { |
| 113 | sys_mutex_init (&global_lock); | 129 | sys_mutex_init (&global_lock); |
diff --git a/src/thread.h b/src/thread.h index def05fdaec9..df26b887d1f 100644 --- a/src/thread.h +++ b/src/thread.h | |||
| @@ -23,6 +23,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 23 | 23 | ||
| 24 | struct thread_state | 24 | struct thread_state |
| 25 | { | 25 | { |
| 26 | struct vectorlike_header header; | ||
| 27 | |||
| 26 | /* The buffer in which the last search was performed, or | 28 | /* The buffer in which the last search was performed, or |
| 27 | Qt if the last search was done in a string; | 29 | Qt if the last search was done in a string; |
| 28 | Qnil if no searching has been done yet. */ | 30 | Qnil if no searching has been done yet. */ |
| @@ -150,6 +152,7 @@ extern sys_mutex_t global_lock; | |||
| 150 | 152 | ||
| 151 | extern void unmark_threads (void); | 153 | extern void unmark_threads (void); |
| 152 | 154 | ||
| 155 | extern void init_threads_once (void); | ||
| 153 | extern void init_threads (void); | 156 | extern void init_threads (void); |
| 154 | 157 | ||
| 155 | #endif /* THREAD_H */ | 158 | #endif /* THREAD_H */ |