b0e812ba494a7d4d9ff7def4f620a6c2589f86a2
[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 #else /* LANGUAGE_ASSEMBLY */
81
82 # ifdef LISP_FEATURE_MIPS
83 #  ifdef __linux__
84 #   define EXTERN(name,bytes) .globl name
85 #  else
86 #   define EXTERN(name,bytes) .extern name bytes
87 #  endif
88 # endif
89 /**/
90 # ifdef LISP_FEATURE_SPARC
91 #  ifdef SVR4
92 #   define EXTERN(name,bytes) .global name
93 #  else
94 #   define EXTERN(name,bytes) .global _ ## name
95 #  endif
96 # endif
97 /**/
98 # ifdef LISP_FEATURE_ALPHA
99 #  ifdef __linux__
100 #   define EXTERN(name,bytes) .globl name
101 #  endif
102 # endif
103 /**/
104 # ifdef LISP_FEATURE_PPC
105 #  ifdef LISP_FEATURE_DARWIN
106 #   define EXTERN(name,bytes) .globl _ ## name
107 #  else
108 #   define EXTERN(name,bytes) .globl name
109 #  endif
110 # endif
111 /**/
112 # if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
113 #  define EXTERN(name,bytes) .global name
114 # endif
115
116 # if defined(LISP_FEATURE_ALPHA) || defined(LISP_FEATURE_X86_64)
117 #  define POINTERSIZE 8
118 # else
119 #  define POINTERSIZE 4
120 # endif
121
122 #ifndef LISP_FEATURE_SB_THREAD
123 EXTERN(foreign_function_call_active, 4)
124 #endif
125
126 #if !defined(LISP_FEATURE_SB_THREAD) && !defined(LISP_FEATURE_C_STACK_IS_CONTROL_STACK)
127 EXTERN(current_control_stack_pointer, POINTERSIZE)
128 #endif
129 EXTERN(current_control_frame_pointer, POINTERSIZE)
130 # if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64)
131 EXTERN(current_binding_stack_pointer, POINTERSIZE)
132 # endif
133 # ifndef LISP_FEATURE_GENCGC
134 EXTERN(dynamic_space_free_pointer, POINTERSIZE)
135 # endif
136
137 #endif /* LANGUAGE_ASSEMBLY */
138
139 #endif /* _INCLUDED_GLOBALS_H_ */