make the minibuffer mutex recursive.
[emacs.git] / src / thread.h
blob573d1ecd1da1fa9e5918be4fcd9133afe58fdb50
1 #include "regex.h"
3 struct Lisp_Mutex
5 EMACS_UINT size;
7 struct Lisp_Vector *v_next;
9 /* Is the mutex recursive? */
10 Lisp_Object recursive;
12 /* Thread that owns the mutex. */
13 pthread_t owner;
15 /* Number of times it was recursively owned. */
16 unsigned int rec_counter;
19 struct thread_state
21 EMACS_UINT size;
22 struct Lisp_Vector *next;
24 /* The function we are evaluating, or 0 in the main thread. */
25 Lisp_Object func;
27 /* An alias of symbols and values that we use to populate the
28 initial specpdl. */
29 Lisp_Object initial_specpdl;
31 /* The buffer in which the last search was performed, or
32 Qt if the last search was done in a string;
33 Qnil if no searching has been done yet. */
34 Lisp_Object m_last_thing_searched;
35 #define last_thing_searched (current_thread->m_last_thing_searched)
37 Lisp_Object m_saved_last_thing_searched;
38 #define saved_last_thing_searched (current_thread->m_saved_last_thing_searched)
40 /* m_gcprolist must be the first non-lisp field. */
41 /* Recording what needs to be marked for gc. */
42 struct gcpro *m_gcprolist;
43 #define gcprolist (current_thread->m_gcprolist)
45 /* A list of currently active byte-code execution value stacks.
46 Fbyte_code adds an entry to the head of this list before it starts
47 processing byte-code, and it removed the entry again when it is
48 done. Signalling an error truncates the list analoguous to
49 gcprolist. */
50 struct byte_stack *m_byte_stack_list;
51 #define byte_stack_list (current_thread->m_byte_stack_list)
53 /* An address near the bottom of the stack.
54 Tells GC how to save a copy of the stack. */
55 char *stack_bottom;
57 /* An address near the top of the stack. */
58 char *stack_top;
60 struct backtrace *m_backtrace_list;
61 #define backtrace_list (current_thread->m_backtrace_list)
63 struct catchtag *m_catchlist;
64 #define catchlist (current_thread->m_catchlist)
66 /* Chain of condition handlers currently in effect.
67 The elements of this chain are contained in the stack frames
68 of Fcondition_case and internal_condition_case.
69 When an error is signaled (by calling Fsignal, below),
70 this chain is searched for an element that applies. */
71 struct handler *m_handlerlist;
72 #define handlerlist (current_thread->m_handlerlist)
74 /* Count levels of GCPRO to detect failure to UNGCPRO. */
75 int m_gcpro_level;
76 #define gcpro_level (current_thread->m_gcpro_level)
78 /* Current number of specbindings allocated in specpdl. */
79 int m_specpdl_size;
80 #define specpdl_size (current_thread->m_specpdl_size)
82 /* Pointer to beginning of specpdl. */
83 struct specbinding *m_specpdl;
84 #define specpdl (current_thread->m_specpdl)
86 /* Pointer to first unused element in specpdl. */
87 struct specbinding *m_specpdl_ptr;
88 #define specpdl_ptr (current_thread->m_specpdl_ptr)
90 /* Depth in Lisp evaluations and function calls. */
91 int m_lisp_eval_depth;
92 #define lisp_eval_depth (current_thread->m_lisp_eval_depth)
94 /* This points to the current buffer. */
95 struct buffer *m_current_buffer;
96 #define current_buffer (current_thread->m_current_buffer)
98 /* Every call to re_match, etc., must pass &search_regs as the regs
99 argument unless you can show it is unnecessary (i.e., if re_match
100 is certainly going to be called again before region-around-match
101 can be called).
103 Since the registers are now dynamically allocated, we need to make
104 sure not to refer to the Nth register before checking that it has
105 been allocated by checking search_regs.num_regs.
107 The regex code keeps track of whether it has allocated the search
108 buffer using bits in the re_pattern_buffer. This means that whenever
109 you compile a new pattern, it completely forgets whether it has
110 allocated any registers, and will allocate new registers the next
111 time you call a searching or matching function. Therefore, we need
112 to call re_set_registers after compiling a new pattern or after
113 setting the match registers, so that the regex functions will be
114 able to free or re-allocate it properly. */
115 struct re_registers m_search_regs;
116 #define search_regs (current_thread->m_search_regs)
118 /* If non-zero the match data have been saved in saved_search_regs
119 during the execution of a sentinel or filter. */
120 int m_search_regs_saved;
121 #define search_regs_saved (current_thread->m_search_regs_saved)
123 struct re_registers m_saved_search_regs;
124 #define saved_search_regs (current_thread->m_saved_search_regs)
126 struct thread_state *next_thread;
128 pthread_t pthread_id;
130 /* If nonzero the thread is blocked on a wait so it is not schedulable. */
131 int blocked;
134 extern __thread struct thread_state *current_thread;
136 extern void init_threads P_ ((void));
138 extern void init_threads_once P_ ((void));
140 extern void thread_yield P_ ((void));
142 extern void syms_of_threads P_ ((void));
144 extern Lisp_Object get_current_thread P_ ((void));
146 extern Lisp_Object get_main_thread P_ ((void));
148 extern pthread_mutex_t global_lock;
150 extern int other_threads_p P_ ((void));
152 extern int user_thread_p P_ ((void));
154 extern Lisp_Object thread_notify_kill_buffer (register struct buffer *b);