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 #error "threading doesn't work with cheney gc yet"
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 #define for_each_thread(th) for(th=all_threads;th;th=th->next)
34 static inline lispobj SymbolValue(u32 tagged_symbol_pointer, void *thread) {
35 struct symbol *sym= (struct symbol *)
36 (tagged_symbol_pointer-OTHER_POINTER_LOWTAG);
37 if(thread && sym->tls_index) {
39 ((union per_thread_data *)thread)
40 ->dynamic_values[fixnum_value(sym->tls_index)];
41 if(r!=UNBOUND_MARKER_WIDETAG) return r;
45 static inline lispobj SymbolTlValue(u32 tagged_symbol_pointer, void *thread) {
46 struct symbol *sym= (struct symbol *)
47 (tagged_symbol_pointer-OTHER_POINTER_LOWTAG);
48 return ((union per_thread_data *)thread)
49 ->dynamic_values[fixnum_value(sym->tls_index)];
52 static inline void SetSymbolValue(u32 tagged_symbol_pointer,lispobj val, void *thread) {
53 struct symbol *sym= (struct symbol *)
54 (tagged_symbol_pointer-OTHER_POINTER_LOWTAG);
55 if(thread && sym->tls_index) {
56 lispobj *pr= &(((union per_thread_data *)thread)
57 ->dynamic_values[fixnum_value(sym->tls_index)]);
58 if(*pr!= UNBOUND_MARKER_WIDETAG) {
65 static inline void SetTlSymbolValue(u32 tagged_symbol_pointer,lispobj val, void *thread) {
66 struct symbol *sym= (struct symbol *)
67 (tagged_symbol_pointer-OTHER_POINTER_LOWTAG);
68 ((union per_thread_data *)thread)
69 ->dynamic_values[fixnum_value(sym->tls_index)]
75 #endif /* _INCLUDE_THREAD_H_ */