Use ALLOCATE_PSEUDOVECTOR.
[emacs.git] / src / thread.h
blob556fad2f200bc51eb71f8100a232d561029f753a
1 #include "regex.h"
3 struct thread_state
5 EMACS_UINT size;
6 struct Lisp_Vector *next;
8 /* The function we are evaluating, or 0 in the main thread. */
9 Lisp_Object func;
11 /* An alias of symbols and values that we use to populate the
12 initial specpdl. */
13 Lisp_Object initial_specpdl;
15 /* The buffer in which the last search was performed, or
16 Qt if the last search was done in a string;
17 Qnil if no searching has been done yet. */
18 Lisp_Object m_last_thing_searched;
19 #define last_thing_searched (current_thread->m_last_thing_searched)
21 Lisp_Object m_saved_last_thing_searched;
22 #define saved_last_thing_searched (current_thread->m_saved_last_thing_searched)
24 /* m_gcprolist must be the first non-lisp field. */
25 /* Recording what needs to be marked for gc. */
26 struct gcpro *m_gcprolist;
27 #define gcprolist (current_thread->m_gcprolist)
29 /* A list of currently active byte-code execution value stacks.
30 Fbyte_code adds an entry to the head of this list before it starts
31 processing byte-code, and it removed the entry again when it is
32 done. Signalling an error truncates the list analoguous to
33 gcprolist. */
34 struct byte_stack *m_byte_stack_list;
35 #define byte_stack_list (current_thread->m_byte_stack_list)
37 /* An address near the bottom of the stack.
38 Tells GC how to save a copy of the stack. */
39 char *stack_bottom;
41 /* An address near the top of the stack. */
42 char *stack_top;
44 struct backtrace *m_backtrace_list;
45 #define backtrace_list (current_thread->m_backtrace_list)
47 struct catchtag *m_catchlist;
48 #define catchlist (current_thread->m_catchlist)
50 /* Chain of condition handlers currently in effect.
51 The elements of this chain are contained in the stack frames
52 of Fcondition_case and internal_condition_case.
53 When an error is signaled (by calling Fsignal, below),
54 this chain is searched for an element that applies. */
55 struct handler *m_handlerlist;
56 #define handlerlist (current_thread->m_handlerlist)
58 /* Count levels of GCPRO to detect failure to UNGCPRO. */
59 int m_gcpro_level;
60 #define gcpro_level (current_thread->m_gcpro_level)
62 /* Current number of specbindings allocated in specpdl. */
63 int m_specpdl_size;
64 #define specpdl_size (current_thread->m_specpdl_size)
66 /* Pointer to beginning of specpdl. */
67 struct specbinding *m_specpdl;
68 #define specpdl (current_thread->m_specpdl)
70 /* Pointer to first unused element in specpdl. */
71 struct specbinding *m_specpdl_ptr;
72 #define specpdl_ptr (current_thread->m_specpdl_ptr)
74 /* Depth in Lisp evaluations and function calls. */
75 int m_lisp_eval_depth;
76 #define lisp_eval_depth (current_thread->m_lisp_eval_depth)
78 /* This points to the current buffer. */
79 struct buffer *m_current_buffer;
80 #define current_buffer (current_thread->m_current_buffer)
82 /* Every call to re_match, etc., must pass &search_regs as the regs
83 argument unless you can show it is unnecessary (i.e., if re_match
84 is certainly going to be called again before region-around-match
85 can be called).
87 Since the registers are now dynamically allocated, we need to make
88 sure not to refer to the Nth register before checking that it has
89 been allocated by checking search_regs.num_regs.
91 The regex code keeps track of whether it has allocated the search
92 buffer using bits in the re_pattern_buffer. This means that whenever
93 you compile a new pattern, it completely forgets whether it has
94 allocated any registers, and will allocate new registers the next
95 time you call a searching or matching function. Therefore, we need
96 to call re_set_registers after compiling a new pattern or after
97 setting the match registers, so that the regex functions will be
98 able to free or re-allocate it properly. */
99 struct re_registers m_search_regs;
100 #define search_regs (current_thread->m_search_regs)
102 /* If non-zero the match data have been saved in saved_search_regs
103 during the execution of a sentinel or filter. */
104 int m_search_regs_saved;
105 #define search_regs_saved (current_thread->m_search_regs_saved)
107 struct re_registers m_saved_search_regs;
108 #define saved_search_regs (current_thread->m_saved_search_regs)
110 struct thread_state *next_thread;
112 pthread_t pthread_id;
114 /* If nonzero the thread access a buffer without lock it. */
115 int nolock;
117 /* Used internally by the scheduler, the buffer that the thread wants a lock
118 for. */
119 struct buffer *desired_buffer;
121 /* If nonzero the thread is blocked on a wait so it is not schedulable. */
122 int blocked;
125 extern __thread struct thread_state *current_thread;
127 extern void init_threads P_ ((void));
129 extern void thread_yield P_ ((void));
131 extern void syms_of_threads P_ ((void));
133 extern Lisp_Object get_current_thread P_ ((void));
135 extern Lisp_Object get_main_thread P_ ((void));
137 extern pthread_mutex_t global_lock;
139 extern int other_threads_p P_ ((void));
141 extern int user_thread_p P_ ((void));
143 EXFUN (Finhibit_yield, 1);
145 extern int thread_inhibit_yield_p P_ ((void));
147 extern void thread_acquire_buffer (char *, void *);