2 #if !defined(_INCLUDE_THREAD_H_)
3 #define _INCLUDE_THREAD_H_
10 #include "interrupt.h"
11 #ifdef LISP_FEATURE_GENCGC
12 #include "gencgc-alloc-region.h"
14 struct alloc_region { };
16 #include "genesis/symbol.h"
17 #include "genesis/static-symbols.h"
18 #include "genesis/thread.h"
20 #define THREAD_SLOT_OFFSET_WORDS(c) \
21 (offsetof(struct thread,c)/(sizeof (struct thread *)))
23 union per_thread_data {
25 lispobj dynamic_values[1]; /* actually more like 4000 or so */
28 extern struct thread *all_threads;
29 extern int dynamic_values_bytes;
30 extern struct thread *find_thread_by_pid(pid_t pid);
32 #ifdef LISP_FEATURE_SB_THREAD
33 #define for_each_thread(th) for(th=all_threads;th;th=th->next)
35 /* there's some possibility a SSC could notice this never actually
37 #define for_each_thread(th) for(th=all_threads;th;th=0)
40 static inline lispobj SymbolValue(u32 tagged_symbol_pointer, void *thread) {
41 struct symbol *sym= (struct symbol *)
42 (pointer_sized_uint_t)(tagged_symbol_pointer-OTHER_POINTER_LOWTAG);
43 #ifdef LISP_FEATURE_SB_THREAD
44 if(thread && sym->tls_index) {
46 ((union per_thread_data *)thread)
47 ->dynamic_values[fixnum_value(sym->tls_index)];
48 if(r!=UNBOUND_MARKER_WIDETAG) return r;
53 static inline lispobj SymbolTlValue(u32 tagged_symbol_pointer, void *thread) {
54 struct symbol *sym= (struct symbol *)
55 (pointer_sized_uint_t)(tagged_symbol_pointer-OTHER_POINTER_LOWTAG);
56 #ifdef LISP_FEATURE_SB_THREAD
57 return ((union per_thread_data *)thread)
58 ->dynamic_values[fixnum_value(sym->tls_index)];
64 static inline void SetSymbolValue(u32 tagged_symbol_pointer,lispobj val, void *thread) {
65 struct symbol *sym= (struct symbol *)
66 (pointer_sized_uint_t)(tagged_symbol_pointer-OTHER_POINTER_LOWTAG);
67 #ifdef LISP_FEATURE_SB_THREAD
68 if(thread && sym->tls_index) {
69 lispobj *pr= &(((union per_thread_data *)thread)
70 ->dynamic_values[fixnum_value(sym->tls_index)]);
71 if(*pr!= UNBOUND_MARKER_WIDETAG) {
79 static inline void SetTlSymbolValue(u32 tagged_symbol_pointer,lispobj val, void *thread) {
80 #ifdef LISP_FEATURE_SB_THREAD
81 struct symbol *sym= (struct symbol *)
82 (pointer_sized_uint_t)(tagged_symbol_pointer-OTHER_POINTER_LOWTAG);
83 ((union per_thread_data *)thread)
84 ->dynamic_values[fixnum_value(sym->tls_index)]
87 SetSymbolValue(tagged_symbol_pointer,val,thread) ;
91 static inline os_context_t *get_interrupt_context_for_thread(struct thread *th)
93 return th->interrupt_contexts
94 [fixnum_value(SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX,th)-1)];
98 int arch_os_thread_init(struct thread *thread);
99 extern struct thread *arch_os_get_current_thread();
101 #endif /* _INCLUDE_THREAD_H_ */