aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread.h
diff options
context:
space:
mode:
authorTom Tromey2012-08-15 12:56:38 -0600
committerTom Tromey2012-08-15 12:56:38 -0600
commit68b32482437e05f0994c4dd0ab5b0c27d39f0f6d (patch)
treefe01584b00d03559210438ebc608a1d170ee00b3 /src/thread.h
parent5190da91e6ca41287190693a8999a6919a9cd8e6 (diff)
downloademacs-68b32482437e05f0994c4dd0ab5b0c27d39f0f6d.tar.gz
emacs-68b32482437e05f0994c4dd0ab5b0c27d39f0f6d.zip
This introduces a thread-state object and moves various C globals
there. It also introduces #defines for these globals to avoid a monster patch. The #defines mean that this patch also has to rename a few fields whose names clash with the defines. There is currently just a single "thread"; so this patch does not impact Emacs behavior in any significant way.
Diffstat (limited to 'src/thread.h')
-rw-r--r--src/thread.h140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/thread.h b/src/thread.h
new file mode 100644
index 00000000000..b2eb04d42e8
--- /dev/null
+++ b/src/thread.h
@@ -0,0 +1,140 @@
1/* Thread definitions
2 Copyright (C) 2012 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef THREAD_H
20#define THREAD_H
21
22#include "regex.h"
23
24struct thread_state
25{
26 /* The buffer in which the last search was performed, or
27 Qt if the last search was done in a string;
28 Qnil if no searching has been done yet. */
29 Lisp_Object m_last_thing_searched;
30#define last_thing_searched (current_thread->m_last_thing_searched)
31
32 Lisp_Object m_saved_last_thing_searched;
33#define saved_last_thing_searched (current_thread->m_saved_last_thing_searched)
34
35 /* m_gcprolist must be the first non-lisp field. */
36 /* Recording what needs to be marked for gc. */
37 struct gcpro *m_gcprolist;
38#define gcprolist (current_thread->m_gcprolist)
39
40 /* A list of currently active byte-code execution value stacks.
41 Fbyte_code adds an entry to the head of this list before it starts
42 processing byte-code, and it removed the entry again when it is
43 done. Signalling an error truncates the list analoguous to
44 gcprolist. */
45 struct byte_stack *m_byte_stack_list;
46#define byte_stack_list (current_thread->m_byte_stack_list)
47
48 /* An address near the bottom of the stack.
49 Tells GC how to save a copy of the stack. */
50 char *m_stack_bottom;
51#define stack_bottom (current_thread->m_stack_bottom)
52
53 /* An address near the top of the stack. */
54 char *stack_top;
55
56 struct backtrace *m_backtrace_list;
57#define backtrace_list (current_thread->m_backtrace_list)
58
59 struct catchtag *m_catchlist;
60#define catchlist (current_thread->m_catchlist)
61
62 /* Chain of condition handlers currently in effect.
63 The elements of this chain are contained in the stack frames
64 of Fcondition_case and internal_condition_case.
65 When an error is signaled (by calling Fsignal, below),
66 this chain is searched for an element that applies. */
67 struct handler *m_handlerlist;
68#define handlerlist (current_thread->m_handlerlist)
69
70 /* Count levels of GCPRO to detect failure to UNGCPRO. */
71 int m_gcpro_level;
72#define gcpro_level (current_thread->m_gcpro_level)
73
74 /* Current number of specbindings allocated in specpdl. */
75 ptrdiff_t m_specpdl_size;
76#define specpdl_size (current_thread->m_specpdl_size)
77
78 /* Pointer to beginning of specpdl. */
79 struct specbinding *m_specpdl;
80#define specpdl (current_thread->m_specpdl)
81
82 /* Pointer to first unused element in specpdl. */
83 struct specbinding *m_specpdl_ptr;
84#define specpdl_ptr (current_thread->m_specpdl_ptr)
85
86 /* Depth in Lisp evaluations and function calls. */
87 EMACS_INT m_lisp_eval_depth;
88#define lisp_eval_depth (current_thread->m_lisp_eval_depth)
89
90 /* This points to the current buffer. */
91 struct buffer *m_current_buffer;
92#define current_buffer (current_thread->m_current_buffer)
93
94 /* Every call to re_match, etc., must pass &search_regs as the regs
95 argument unless you can show it is unnecessary (i.e., if re_match
96 is certainly going to be called again before region-around-match
97 can be called).
98
99 Since the registers are now dynamically allocated, we need to make
100 sure not to refer to the Nth register before checking that it has
101 been allocated by checking search_regs.num_regs.
102
103 The regex code keeps track of whether it has allocated the search
104 buffer using bits in the re_pattern_buffer. This means that whenever
105 you compile a new pattern, it completely forgets whether it has
106 allocated any registers, and will allocate new registers the next
107 time you call a searching or matching function. Therefore, we need
108 to call re_set_registers after compiling a new pattern or after
109 setting the match registers, so that the regex functions will be
110 able to free or re-allocate it properly. */
111 struct re_registers m_search_regs;
112#define search_regs (current_thread->m_search_regs)
113
114 /* If non-zero the match data have been saved in saved_search_regs
115 during the execution of a sentinel or filter. */
116 int m_search_regs_saved;
117#define search_regs_saved (current_thread->m_search_regs_saved)
118
119 struct re_registers m_saved_search_regs;
120#define saved_search_regs (current_thread->m_saved_search_regs)
121
122 /* This is the string or buffer in which we
123 are matching. It is used for looking up syntax properties. */
124 Lisp_Object m_re_match_object;
125#define re_match_object (current_thread->m_re_match_object)
126
127 /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
128 also be assigned to arbitrarily: each pattern buffer stores its own
129 syntax, so it can be changed between regex compilations. */
130 reg_syntax_t m_re_syntax_options;
131#define re_syntax_options (current_thread->m_re_syntax_options)
132
133 /* Regexp to use to replace spaces, or NULL meaning don't. */
134 /*re_char*/ unsigned char *m_whitespace_regexp;
135#define whitespace_regexp (current_thread->m_whitespace_regexp)
136};
137
138extern struct thread_state *current_thread;
139
140#endif /* THREAD_H */