1.0.41.20: runtime: Straighten out access to binding stack pointers.
[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 extern lispobj *current_control_stack_pointer;
51 extern lispobj *current_control_frame_pointer;
52 #if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64) && !defined(LISP_FEATURE_SB_THREAD)
53 extern lispobj *current_binding_stack_pointer;
54 #endif
55
56 #if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64)
57 /* This is unused on X86 and X86_64, but is used as the global
58  *  allocation pointer by the cheney GC, and, in some instances, as
59  *  the global allocation pointer on PPC/GENCGC. This should probably
60  *  be cleaned up such that it only needs to exist on cheney. At the
61  *  moment, it is also used by the GENCGC, to hold the pseudo_atomic
62  *  bits, and is tightly coupled to reg_ALLOC by the assembly
63  *  routines. */
64 extern lispobj *dynamic_space_free_pointer;
65 #endif
66
67 # ifndef LISP_FEATURE_GENCGC
68 extern lispobj *current_auto_gc_trigger;
69 # endif
70
71 extern lispobj *current_dynamic_space;
72
73 extern void globals_init(void);
74
75 #else /* LANGUAGE_ASSEMBLY */
76
77 # ifdef LISP_FEATURE_MIPS
78 #  ifdef __linux__
79 #   define EXTERN(name,bytes) .globl name
80 #  else
81 #   define EXTERN(name,bytes) .extern name bytes
82 #  endif
83 # endif
84 /**/
85 # ifdef LISP_FEATURE_SPARC
86 #  ifdef SVR4
87 #   define EXTERN(name,bytes) .global name
88 #  else
89 #   define EXTERN(name,bytes) .global _ ## name
90 #  endif
91 # endif
92 /**/
93 # ifdef LISP_FEATURE_ALPHA
94 #  ifdef __linux__
95 #   define EXTERN(name,bytes) .globl name
96 #  endif
97 # endif
98 /**/
99 # ifdef LISP_FEATURE_PPC
100 #  ifdef LISP_FEATURE_DARWIN
101 #   define EXTERN(name,bytes) .globl _ ## name
102 #  else
103 #   define EXTERN(name,bytes) .globl name
104 #  endif
105 # endif
106 /**/
107 # if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
108 #  define EXTERN(name,bytes) .global name
109 # endif
110
111 # if defined(LISP_FEATURE_ALPHA) || defined(LISP_FEATURE_X86_64)
112 #  define POINTERSIZE 8
113 # else
114 #  define POINTERSIZE 4
115 # endif
116
117 #ifndef LISP_FEATURE_SB_THREAD
118 EXTERN(foreign_function_call_active, 4)
119 #endif
120
121 EXTERN(current_control_stack_pointer, POINTERSIZE)
122 EXTERN(current_control_frame_pointer, POINTERSIZE)
123 # if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64)
124 EXTERN(current_binding_stack_pointer, POINTERSIZE)
125 # endif
126 # ifndef LISP_FEATURE_GENCGC
127 EXTERN(dynamic_space_free_pointer, POINTERSIZE)
128 # endif
129
130 #endif /* LANGUAGE_ASSEMBLY */
131
132 #endif /* _INCLUDED_GLOBALS_H_ */