This source file includes following definitions.
- THREADP
- CHECK_THREAD
- XTHREAD
- MUTEXP
- CHECK_MUTEX
- XMUTEX
- CONDVARP
- CHECK_CONDVAR
- XCONDVAR
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef THREAD_H
20 #define THREAD_H
21
22 #include "regex-emacs.h"
23
24 #ifdef WINDOWSNT
25 #include <sys/socket.h>
26 #endif
27
28 #ifdef MSDOS
29 #include <time.h>
30 #include <signal.h>
31 #endif
32
33 #include "sysselect.h"
34 #include "systhread.h"
35
36 INLINE_HEADER_BEGIN
37
38
39 struct bc_thread_state {
40 struct bc_frame *fp;
41
42
43 char *stack;
44 char *stack_end;
45 };
46
47 struct thread_state
48 {
49 union vectorlike_header header;
50
51
52
53
54 Lisp_Object m_last_thing_searched;
55 #define last_thing_searched (current_thread->m_last_thing_searched)
56
57 Lisp_Object m_saved_last_thing_searched;
58 #define saved_last_thing_searched (current_thread->m_saved_last_thing_searched)
59
60
61 Lisp_Object name;
62
63
64 Lisp_Object function;
65
66
67 Lisp_Object result;
68
69
70 Lisp_Object error_symbol;
71 Lisp_Object error_data;
72
73
74
75 Lisp_Object event_object;
76
77
78
79
80 char const *m_stack_bottom;
81 #define stack_bottom (current_thread->m_stack_bottom)
82
83
84
85
86
87
88
89
90 void const *stack_top;
91
92 struct catchtag *m_catchlist;
93 #define catchlist (current_thread->m_catchlist)
94
95
96
97
98
99
100 struct handler *m_handlerlist;
101 #define handlerlist (current_thread->m_handlerlist)
102
103 struct handler *m_handlerlist_sentinel;
104 #define handlerlist_sentinel (current_thread->m_handlerlist_sentinel)
105
106
107 union specbinding *m_specpdl;
108 #define specpdl (current_thread->m_specpdl)
109
110
111 union specbinding *m_specpdl_end;
112 #define specpdl_end (current_thread->m_specpdl_end)
113
114
115 union specbinding *m_specpdl_ptr;
116 #define specpdl_ptr (current_thread->m_specpdl_ptr)
117
118
119 intmax_t m_lisp_eval_depth;
120 #define lisp_eval_depth (current_thread->m_lisp_eval_depth)
121
122
123 struct buffer *m_current_buffer;
124 #define current_buffer (current_thread->m_current_buffer)
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143 struct re_registers m_search_regs;
144 #define search_regs (current_thread->m_search_regs)
145
146 struct re_registers m_saved_search_regs;
147 #define saved_search_regs (current_thread->m_saved_search_regs)
148
149
150
151
152
153
154
155
156
157 int m_waiting_for_user_input_p;
158 #define waiting_for_user_input_p (current_thread->m_waiting_for_user_input_p)
159
160
161 bool m_waiting_for_input;
162 #define waiting_for_input (current_thread->m_waiting_for_input)
163
164
165
166
167
168 sys_jmp_buf m_getcjmp;
169 #define getcjmp (current_thread->m_getcjmp)
170
171
172 sys_thread_t thread_id;
173
174
175
176 sys_cond_t thread_condvar;
177
178
179
180
181 sys_cond_t *wait_condvar;
182
183
184 char *thread_name;
185
186
187
188
189
190
191 int not_holding_lock;
192
193
194 struct thread_state *next_thread;
195
196 struct bc_thread_state bc;
197 } GCALIGNED_STRUCT;
198
199 INLINE bool
200 THREADP (Lisp_Object a)
201 {
202 return PSEUDOVECTORP (a, PVEC_THREAD);
203 }
204
205 INLINE void
206 CHECK_THREAD (Lisp_Object x)
207 {
208 CHECK_TYPE (THREADP (x), Qthreadp, x);
209 }
210
211 INLINE struct thread_state *
212 XTHREAD (Lisp_Object a)
213 {
214 eassert (THREADP (a));
215 return XUNTAG (a, Lisp_Vectorlike, struct thread_state);
216 }
217
218
219
220
221
222
223
224 typedef struct
225 {
226
227 struct thread_state *owner;
228
229 unsigned int count;
230
231 sys_cond_t condition;
232 } lisp_mutex_t;
233
234
235 struct Lisp_Mutex
236 {
237 union vectorlike_header header;
238
239
240 Lisp_Object name;
241
242
243 lisp_mutex_t mutex;
244 } GCALIGNED_STRUCT;
245
246 INLINE bool
247 MUTEXP (Lisp_Object a)
248 {
249 return PSEUDOVECTORP (a, PVEC_MUTEX);
250 }
251
252 INLINE void
253 CHECK_MUTEX (Lisp_Object x)
254 {
255 CHECK_TYPE (MUTEXP (x), Qmutexp, x);
256 }
257
258 INLINE struct Lisp_Mutex *
259 XMUTEX (Lisp_Object a)
260 {
261 eassert (MUTEXP (a));
262 return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Mutex);
263 }
264
265
266 struct Lisp_CondVar
267 {
268 union vectorlike_header header;
269
270
271 Lisp_Object mutex;
272
273
274 Lisp_Object name;
275
276
277 sys_cond_t cond;
278 } GCALIGNED_STRUCT;
279
280 INLINE bool
281 CONDVARP (Lisp_Object a)
282 {
283 return PSEUDOVECTORP (a, PVEC_CONDVAR);
284 }
285
286 INLINE void
287 CHECK_CONDVAR (Lisp_Object x)
288 {
289 CHECK_TYPE (CONDVARP (x), Qcondition_variable_p, x);
290 }
291
292 INLINE struct Lisp_CondVar *
293 XCONDVAR (Lisp_Object a)
294 {
295 eassert (CONDVARP (a));
296 return XUNTAG (a, Lisp_Vectorlike, struct Lisp_CondVar);
297 }
298
299 extern struct thread_state *current_thread;
300
301 extern void finalize_one_thread (struct thread_state *state);
302 extern void finalize_one_mutex (struct Lisp_Mutex *);
303 extern void finalize_one_condvar (struct Lisp_CondVar *);
304 extern void maybe_reacquire_global_lock (void);
305
306 extern void init_threads (void);
307 extern void syms_of_threads (void);
308 extern bool main_thread_p (const void *);
309 extern bool in_current_thread (void);
310
311 typedef int select_func (int, fd_set *, fd_set *, fd_set *,
312 const struct timespec *, const sigset_t *);
313
314 int thread_select (select_func *func, int max_fds, fd_set *rfds,
315 fd_set *wfds, fd_set *efds, struct timespec *timeout,
316 sigset_t *sigmask);
317
318 bool thread_check_current_buffer (struct buffer *);
319
320 INLINE_HEADER_END
321
322 #endif