1.0.41.21: runtime: Current stack and frame pointers are per-thread data.
[sbcl.git] / src / runtime / globals.h
1 /*
2  * This software is part of the SBCL system. See the README file for
3  * more information.
4  *
5  * This software is derived from the CMU CL system, which was
6  * written at Carnegie Mellon University and released into the
7  * public domain. The software is in the public domain and is
8  * provided with absolutely no warranty. See the COPYING and CREDITS
9  * files for more information.
10  */
11
12 #ifndef _INCLUDED_GLOBALS_H_
13 #define _INCLUDED_GLOBALS_H_
14
15 #ifndef LANGUAGE_ASSEMBLY
16 # include <sys/types.h>
17 # include <unistd.h>
18 # include "runtime.h"
19 #endif
20
21 #include "sbcl.h"
22
23 #ifndef LANGUAGE_ASSEMBLY
24
25 #ifdef LISP_FEATURE_SB_THREAD
26 #define foreign_function_call_active_p(thread) \
27     (thread->foreign_function_call_active)
28 #else
29 extern int foreign_function_call_active;
30 #define foreign_function_call_active_p(thread) \
31     foreign_function_call_active
32 #endif
33
34 extern size_t dynamic_space_size;
35 extern size_t thread_control_stack_size;
36
37 extern struct runtime_options *runtime_options;
38
39 #ifdef LISP_FEATURE_WIN32
40 #define ENVIRON _environ
41 #else
42 #define ENVIRON environ
43 #endif
44 extern char **ENVIRON;
45
46 #if defined(LISP_FEATURE_SB_THREAD) && !defined(LISP_FEATURE_GCC_TLS)
47 extern pthread_key_t specials;
48 #endif
49
50 #if !defined(LISP_FEATURE_SB_THREAD) && !defined(LISP_FEATURE_C_STACK_IS_CONTROL_STACK)
51 extern lispobj *current_control_stack_pointer;
52 #endif
53 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64) || !defined(LISP_FEATURE_SB_THREAD)
54 extern lispobj *current_control_frame_pointer;
55 #endif
56 #if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64) && !defined(LISP_FEATURE_SB_THREAD)
57 extern lispobj *current_binding_stack_pointer;
58 #endif
59
60 #if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64)
61 /* This is unused on X86 and X86_64, but is used as the global
62  *  allocation pointer by the cheney GC, and, in some instances, as
63  *  the global allocation pointer on PPC/GENCGC. This should probably
64  *  be cleaned up such that it only needs to exist on cheney. At the
65  *  moment, it is also used by the GENCGC, to hold the pseudo_atomic
66  *  bits, and is tightly coupled to reg_ALLOC by the assembly
67  *  routines. */
68 extern lispobj *dynamic_space_free_pointer;
69 #endif
70
71 # ifndef LISP_FEATURE_GENCGC
72 extern lispobj *current_auto_gc_trigger;
73 # endif
74
75 extern lispobj *current_dynamic_space;
76
77 extern void globals_init(void);
78
79 #else /* LANGUAGE_ASSEMBLY */
80
81 # ifdef LISP_FEATURE_MIPS
82 #  ifdef __linux__
83 #   define EXTERN(name,bytes) .globl name
84 #  else
85 #   define EXTERN(name,bytes) .extern name bytes
86 #  endif
87 # endif
88 /**/
89 # ifdef LISP_FEATURE_SPARC
90 #  ifdef SVR4
91 #   define EXTERN(name,bytes) .global name
92 #  else
93 #   define EXTERN(name,bytes) .global _ ## name
94 #  endif
95 # endif
96 /**/
97 # ifdef LISP_FEATURE_ALPHA
98 #  ifdef __linux__
99 #   define EXTERN(name,bytes) .globl name
100 #  endif
101 # endif
102 /**/
103 # ifdef LISP_FEATURE_PPC
104 #  ifdef LISP_FEATURE_DARWIN
105 #   define EXTERN(name,bytes) .globl _ ## name
106 #  else
107 #   define EXTERN(name,bytes) .globl name
108 #  endif
109 # endif
110 /**/
111 # if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
112 #  define EXTERN(name,bytes) .global name
113 # endif
114
115 # if defined(LISP_FEATURE_ALPHA) || defined(LISP_FEATURE_X86_64)
116 #  define POINTERSIZE 8
117 # else
118 #  define POINTERSIZE 4
119 # endif
120
121 #ifndef LISP_FEATURE_SB_THREAD
122 EXTERN(foreign_function_call_active, 4)
123 #endif
124
125 #if !defined(LISP_FEATURE_SB_THREAD) && !defined(LISP_FEATURE_C_STACK_IS_CONTROL_STACK)
126 EXTERN(current_control_stack_pointer, POINTERSIZE)
127 #endif
128 EXTERN(current_control_frame_pointer, POINTERSIZE)
129 # if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64)
130 EXTERN(current_binding_stack_pointer, POINTERSIZE)
131 # endif
132 # ifndef LISP_FEATURE_GENCGC
133 EXTERN(dynamic_space_free_pointer, POINTERSIZE)
134 # endif
135
136 #endif /* LANGUAGE_ASSEMBLY */
137
138 #endif /* _INCLUDED_GLOBALS_H_ */