Change immobile space free pointers to alien vars
[sbcl.git] / src / runtime / validate.h
blobff5344558659598228ced965a2939f4fdd43bc59
1 /*
2 * This software is part of the SBCL system. See the README file for
3 * more information.
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.
12 #if !defined(_INCLUDE_VALIDATE_H_)
13 #define _INCLUDE_VALIDATE_H_
15 #ifndef LISP_FEATURE_GENCGC
16 /* FIXME: genesis/constants.h also defines this with a constant value */
17 #define DYNAMIC_SPACE_START current_dynamic_space
18 #endif
20 #define BINDING_STACK_SIZE (1024*1024) /* chosen at random */
21 #define ALIEN_STACK_SIZE (1024*1024) /* chosen at random */
23 /* eventually choosable per-thread: */
24 #define DEFAULT_CONTROL_STACK_SIZE (2*1024*1024)
26 /* constants derived from the fundamental constants in passed by GENESIS */
27 #ifdef LISP_FEATURE_CHENEYGC
28 #define DEFAULT_DYNAMIC_SPACE_SIZE (DYNAMIC_0_SPACE_END - DYNAMIC_0_SPACE_START)
29 #endif
30 #define READ_ONLY_SPACE_SIZE (READ_ONLY_SPACE_END - READ_ONLY_SPACE_START)
31 #define STATIC_SPACE_SIZE (STATIC_SPACE_END - STATIC_SPACE_START)
32 #define IMMOBILE_SPACE_SIZE (IMMOBILE_SPACE_END - IMMOBILE_SPACE_START)
33 #ifdef LISP_FEATURE_LINKAGE_TABLE
34 #define LINKAGE_TABLE_SPACE_SIZE \
35 (LINKAGE_TABLE_SPACE_END - LINKAGE_TABLE_SPACE_START)
36 #endif
38 #if !defined(LANGUAGE_ASSEMBLY)
39 #include "thread.h"
41 #ifdef LISP_FEATURE_STACK_GROWS_DOWNWARD_NOT_UPWARD
43 #define CONTROL_STACK_HARD_GUARD_PAGE(th) \
44 ((os_vm_address_t)(th->control_stack_start))
45 #define CONTROL_STACK_GUARD_PAGE(th) \
46 (CONTROL_STACK_HARD_GUARD_PAGE(th) + os_vm_page_size)
47 #define CONTROL_STACK_RETURN_GUARD_PAGE(th) \
48 (CONTROL_STACK_GUARD_PAGE(th) + os_vm_page_size)
49 #else
51 #define CONTROL_STACK_HARD_GUARD_PAGE(th) \
52 (((os_vm_address_t)(th->control_stack_end)) - os_vm_page_size)
53 #define CONTROL_STACK_GUARD_PAGE(th) \
54 (CONTROL_STACK_HARD_GUARD_PAGE(th) - os_vm_page_size)
55 #define CONTROL_STACK_RETURN_GUARD_PAGE(th) \
56 (CONTROL_STACK_GUARD_PAGE(th) - os_vm_page_size)
58 #endif
60 #ifdef ALIEN_STACK_GROWS_DOWNWARD
62 #define ALIEN_STACK_HARD_GUARD_PAGE(th) \
63 ((os_vm_address_t)(th->alien_stack_start))
64 #define ALIEN_STACK_GUARD_PAGE(th) \
65 (ALIEN_STACK_HARD_GUARD_PAGE(th) + os_vm_page_size)
66 #define ALIEN_STACK_RETURN_GUARD_PAGE(th) \
67 (ALIEN_STACK_GUARD_PAGE(th) + os_vm_page_size)
69 #elif defined(ALIEN_STACK_GROWS_UPWARD)
71 #define ALIEN_STACK_HARD_GUARD_PAGE(th) \
72 (((os_vm_address_t)th->alien_stack_start) + ALIEN_STACK_SIZE - \
73 os_vm_page_size)
74 #define ALIEN_STACK_GUARD_PAGE(th) \
75 (ALIEN_STACK_HARD_GUARD_PAGE(th) - os_vm_page_size)
76 #define ALIEN_STACK_RETURN_GUARD_PAGE(th) \
77 (ALIEN_STACK_GUARD_PAGE(th) - os_vm_page_size)
79 #else
80 #error ALIEN_STACK_GROWS_DOWNWARD or ALIEN_STACK_GROWS_UPWARD has to be defined
81 #endif
83 #define BINDING_STACK_HARD_GUARD_PAGE(th) \
84 (((os_vm_address_t)th->binding_stack_start) + BINDING_STACK_SIZE - \
85 os_vm_page_size)
86 #define BINDING_STACK_GUARD_PAGE(th) \
87 (BINDING_STACK_HARD_GUARD_PAGE(th) - os_vm_page_size)
88 #define BINDING_STACK_RETURN_GUARD_PAGE(th) \
89 (BINDING_STACK_GUARD_PAGE(th) - os_vm_page_size)
91 extern void allocate_spaces(void);
93 extern void
94 protect_control_stack_hard_guard_page(int protect_p, struct thread *thread);
95 extern void
96 protect_control_stack_guard_page(int protect_p, struct thread *thread);
97 extern void
98 protect_control_stack_return_guard_page(int protect_p, struct thread *thread);
99 extern void
100 protect_binding_stack_hard_guard_page(int protect_p, struct thread *thread);
101 extern void
102 protect_binding_stack_guard_page(int protect_p, struct thread *thread);
103 extern void
104 protect_binding_stack_return_guard_page(int protect_p, struct thread *thread);
105 extern void
106 protect_alien_stack_hard_guard_page(int protect_p, struct thread *thread);
107 extern void
108 protect_alien_stack_guard_page(int protect_p, struct thread *thread);
109 extern void
110 protect_alien_stack_return_guard_page(int protect_p, struct thread *thread);
111 extern os_vm_address_t undefined_alien_address;
112 #endif
114 /* note for anyone trying to port an architecture's support files
115 * from CMU CL to SBCL:
117 * CMU CL had architecture-dependent header files included here to
118 * define memory map data:
119 * #ifdef LISP_FEATURE_X86
120 * #include "x86-validate.h"
121 * #endif
122 * and so forth. In SBCL, the memory map data are defined at the Lisp
123 * level (compiler/target/parms.lisp) and stuffed into the sbcl.h file
124 * created by GENESIS, so there's no longer a need for an
125 * architecture-dependent header file of memory map data.
128 #endif