fc8ad968452cdda1b696c212d88277948b1361e0
[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 # include "runtime-options.h"
20 #endif
21
22 #include "sbcl.h"
23
24 #ifndef LANGUAGE_ASSEMBLY
25
26 #ifdef LISP_FEATURE_SB_THREAD
27 #define foreign_function_call_active_p(thread) \
28     (thread->foreign_function_call_active)
29 #else
30 extern int foreign_function_call_active;
31 #define foreign_function_call_active_p(thread) \
32     foreign_function_call_active
33 #endif
34
35 extern os_vm_size_t dynamic_space_size;
36 extern os_vm_size_t thread_control_stack_size;
37
38 extern struct runtime_options *runtime_options;
39
40 #ifdef LISP_FEATURE_WIN32
41 #define ENVIRON _environ
42 #else
43 #define ENVIRON environ
44 #endif
45 extern char **ENVIRON;
46
47 #if defined(LISP_FEATURE_SB_THREAD) && !defined(LISP_FEATURE_GCC_TLS)
48 extern pthread_key_t specials;
49 #endif
50
51 #if !defined(LISP_FEATURE_SB_THREAD)
52 extern lispobj *current_control_stack_pointer;
53 #endif
54 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64) || !defined(LISP_FEATURE_SB_THREAD)
55 extern lispobj *current_control_frame_pointer;
56 #endif
57 #if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64) && !defined(LISP_FEATURE_SB_THREAD)
58 extern lispobj *current_binding_stack_pointer;
59 #endif
60
61 #if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64)
62 /* This is unused on X86 and X86_64, but is used as the global
63  *  allocation pointer by the cheney GC, and, in some instances, as
64  *  the global allocation pointer on PPC/GENCGC. This should probably
65  *  be cleaned up such that it only needs to exist on cheney. At the
66  *  moment, it is also used by the GENCGC, to hold the pseudo_atomic
67  *  bits, and is tightly coupled to reg_ALLOC by the assembly
68  *  routines. */
69 extern lispobj *dynamic_space_free_pointer;
70 #endif
71
72 # ifndef LISP_FEATURE_GENCGC
73 extern lispobj *current_auto_gc_trigger;
74 # endif
75
76 extern lispobj *current_dynamic_space;
77
78 extern void globals_init(void);
79
80 #ifdef LISP_FEATURE_SB_SAFEPOINT
81 # define GC_SAFEPOINT_PAGE_ADDR ((lispobj) gc_safepoint_page)
82 extern char gc_safepoint_page[];
83 #endif
84
85 #else /* LANGUAGE_ASSEMBLY */
86
87 # ifdef LISP_FEATURE_MIPS
88 #  ifdef __linux__
89 #   define EXTERN(name,bytes) .globl name
90 #  else
91 #   define EXTERN(name,bytes) .extern name bytes
92 #  endif
93 # endif
94 /**/
95 # ifdef LISP_FEATURE_SPARC
96 #  ifdef SVR4
97 #   define EXTERN(name,bytes) .global name
98 #  else
99 #   define EXTERN(name,bytes) .global _ ## name
100 #  endif
101 # endif
102 /**/
103 # ifdef LISP_FEATURE_ALPHA
104 #  ifdef __linux__
105 #   define EXTERN(name,bytes) .globl name
106 #  endif
107 # endif
108 /**/
109 # ifdef LISP_FEATURE_PPC
110 #  ifdef LISP_FEATURE_DARWIN
111 #   define EXTERN(name,bytes) .globl _ ## name
112 #  else
113 #   define EXTERN(name,bytes) .globl name
114 #  endif
115 # endif
116 /**/
117 # if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
118 #  define EXTERN(name,bytes) .global name
119 # endif
120
121 # if defined(LISP_FEATURE_ALPHA) || defined(LISP_FEATURE_X86_64)
122 #  define POINTERSIZE 8
123 # else
124 #  define POINTERSIZE 4
125 # endif
126
127 #ifndef LISP_FEATURE_SB_THREAD
128 EXTERN(foreign_function_call_active, 4)
129 #endif
130
131 #if !defined(LISP_FEATURE_SB_THREAD) && !defined(LISP_FEATURE_C_STACK_IS_CONTROL_STACK)
132 EXTERN(current_control_stack_pointer, POINTERSIZE)
133 #endif
134 EXTERN(current_control_frame_pointer, POINTERSIZE)
135 # if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64)
136 EXTERN(current_binding_stack_pointer, POINTERSIZE)
137 # endif
138 # ifndef LISP_FEATURE_GENCGC
139 EXTERN(dynamic_space_free_pointer, POINTERSIZE)
140 # endif
141
142 #endif /* LANGUAGE_ASSEMBLY */
143
144 #endif /* _INCLUDED_GLOBALS_H_ */