1 | #ifndef JEMALLOC_PREAMBLE_H |
2 | #define JEMALLOC_PREAMBLE_H |
3 | |
4 | #include "jemalloc_internal_defs.h" |
5 | #include "jemalloc/internal/jemalloc_internal_decls.h" |
6 | |
7 | #if defined(JEMALLOC_UTRACE) || defined(JEMALLOC_UTRACE_LABEL) |
8 | #include <sys/ktrace.h> |
9 | # if defined(JEMALLOC_UTRACE) |
10 | # define UTRACE_CALL(p, l) utrace(p, l) |
11 | # else |
12 | # define UTRACE_CALL(p, l) utrace("jemalloc_process", p, l) |
13 | # define JEMALLOC_UTRACE |
14 | # endif |
15 | #endif |
16 | |
17 | #define JEMALLOC_NO_DEMANGLE |
18 | #ifdef JEMALLOC_JET |
19 | # undef JEMALLOC_IS_MALLOC |
20 | # define JEMALLOC_N(n) jet_##n |
21 | # include "jemalloc/internal/public_namespace.h" |
22 | # define JEMALLOC_NO_RENAME |
23 | # include "../jemalloc.h" |
24 | # undef JEMALLOC_NO_RENAME |
25 | #else |
26 | # define JEMALLOC_N(n) je_##n |
27 | # include "../jemalloc.h" |
28 | #endif |
29 | |
30 | #if defined(JEMALLOC_OSATOMIC) |
31 | #include <libkern/OSAtomic.h> |
32 | #endif |
33 | |
34 | #ifdef JEMALLOC_ZONE |
35 | #include <mach/mach_error.h> |
36 | #include <mach/mach_init.h> |
37 | #include <mach/vm_map.h> |
38 | #endif |
39 | |
40 | #include "jemalloc/internal/jemalloc_internal_macros.h" |
41 | |
42 | /* |
43 | * Note that the ordering matters here; the hook itself is name-mangled. We |
44 | * want the inclusion of hooks to happen early, so that we hook as much as |
45 | * possible. |
46 | */ |
47 | #ifndef JEMALLOC_NO_PRIVATE_NAMESPACE |
48 | # ifndef JEMALLOC_JET |
49 | # include "jemalloc/internal/private_namespace.h" |
50 | # else |
51 | # include "jemalloc/internal/private_namespace_jet.h" |
52 | # endif |
53 | #endif |
54 | #include "jemalloc/internal/test_hooks.h" |
55 | |
56 | #ifdef JEMALLOC_DEFINE_MADVISE_FREE |
57 | # define JEMALLOC_MADV_FREE 8 |
58 | #endif |
59 | |
60 | static const bool config_debug = |
61 | #ifdef JEMALLOC_DEBUG |
62 | true |
63 | #else |
64 | false |
65 | #endif |
66 | ; |
67 | static const bool have_dss = |
68 | #ifdef JEMALLOC_DSS |
69 | true |
70 | #else |
71 | false |
72 | #endif |
73 | ; |
74 | static const bool have_madvise_huge = |
75 | #ifdef JEMALLOC_HAVE_MADVISE_HUGE |
76 | true |
77 | #else |
78 | false |
79 | #endif |
80 | ; |
81 | static const bool config_fill = |
82 | #ifdef JEMALLOC_FILL |
83 | true |
84 | #else |
85 | false |
86 | #endif |
87 | ; |
88 | static const bool config_lazy_lock = |
89 | #ifdef JEMALLOC_LAZY_LOCK |
90 | true |
91 | #else |
92 | false |
93 | #endif |
94 | ; |
95 | static const char * const config_malloc_conf = JEMALLOC_CONFIG_MALLOC_CONF; |
96 | static const bool config_prof = |
97 | #ifdef JEMALLOC_PROF |
98 | true |
99 | #else |
100 | false |
101 | #endif |
102 | ; |
103 | static const bool config_prof_libgcc = |
104 | #ifdef JEMALLOC_PROF_LIBGCC |
105 | true |
106 | #else |
107 | false |
108 | #endif |
109 | ; |
110 | static const bool config_prof_libunwind = |
111 | #ifdef JEMALLOC_PROF_LIBUNWIND |
112 | true |
113 | #else |
114 | false |
115 | #endif |
116 | ; |
117 | static const bool maps_coalesce = |
118 | #ifdef JEMALLOC_MAPS_COALESCE |
119 | true |
120 | #else |
121 | false |
122 | #endif |
123 | ; |
124 | static const bool config_stats = |
125 | #ifdef JEMALLOC_STATS |
126 | true |
127 | #else |
128 | false |
129 | #endif |
130 | ; |
131 | static const bool config_tls = |
132 | #ifdef JEMALLOC_TLS |
133 | true |
134 | #else |
135 | false |
136 | #endif |
137 | ; |
138 | static const bool config_utrace = |
139 | #ifdef JEMALLOC_UTRACE |
140 | true |
141 | #else |
142 | false |
143 | #endif |
144 | ; |
145 | static const bool config_xmalloc = |
146 | #ifdef JEMALLOC_XMALLOC |
147 | true |
148 | #else |
149 | false |
150 | #endif |
151 | ; |
152 | static const bool config_cache_oblivious = |
153 | #ifdef JEMALLOC_CACHE_OBLIVIOUS |
154 | true |
155 | #else |
156 | false |
157 | #endif |
158 | ; |
159 | /* |
160 | * Undocumented, for jemalloc development use only at the moment. See the note |
161 | * in jemalloc/internal/log.h. |
162 | */ |
163 | static const bool config_log = |
164 | #ifdef JEMALLOC_LOG |
165 | true |
166 | #else |
167 | false |
168 | #endif |
169 | ; |
170 | /* |
171 | * Are extra safety checks enabled; things like checking the size of sized |
172 | * deallocations, double-frees, etc. |
173 | */ |
174 | static const bool config_opt_safety_checks = |
175 | #ifdef JEMALLOC_OPT_SAFETY_CHECKS |
176 | true |
177 | #elif defined(JEMALLOC_DEBUG) |
178 | /* |
179 | * This lets us only guard safety checks by one flag instead of two; fast |
180 | * checks can guard solely by config_opt_safety_checks and run in debug mode |
181 | * too. |
182 | */ |
183 | true |
184 | #else |
185 | false |
186 | #endif |
187 | ; |
188 | |
189 | /* |
190 | * Extra debugging of sized deallocations too onerous to be included in the |
191 | * general safety checks. |
192 | */ |
193 | static const bool config_opt_size_checks = |
194 | #if defined(JEMALLOC_OPT_SIZE_CHECKS) || defined(JEMALLOC_DEBUG) |
195 | true |
196 | #else |
197 | false |
198 | #endif |
199 | ; |
200 | |
201 | static const bool config_uaf_detection = |
202 | #if defined(JEMALLOC_UAF_DETECTION) || defined(JEMALLOC_DEBUG) |
203 | true |
204 | #else |
205 | false |
206 | #endif |
207 | ; |
208 | |
209 | /* Whether or not the C++ extensions are enabled. */ |
210 | static const bool config_enable_cxx = |
211 | #ifdef JEMALLOC_ENABLE_CXX |
212 | true |
213 | #else |
214 | false |
215 | #endif |
216 | ; |
217 | |
218 | #if defined(_WIN32) || defined(__APPLE__) || defined(JEMALLOC_HAVE_SCHED_GETCPU) |
219 | /* Currently percpu_arena depends on sched_getcpu. */ |
220 | #define JEMALLOC_PERCPU_ARENA |
221 | #endif |
222 | static const bool have_percpu_arena = |
223 | #ifdef JEMALLOC_PERCPU_ARENA |
224 | true |
225 | #else |
226 | false |
227 | #endif |
228 | ; |
229 | /* |
230 | * Undocumented, and not recommended; the application should take full |
231 | * responsibility for tracking provenance. |
232 | */ |
233 | static const bool force_ivsalloc = |
234 | #ifdef JEMALLOC_FORCE_IVSALLOC |
235 | true |
236 | #else |
237 | false |
238 | #endif |
239 | ; |
240 | static const bool have_background_thread = |
241 | #ifdef JEMALLOC_BACKGROUND_THREAD |
242 | true |
243 | #else |
244 | false |
245 | #endif |
246 | ; |
247 | static const bool config_high_res_timer = |
248 | #ifdef JEMALLOC_HAVE_CLOCK_REALTIME |
249 | true |
250 | #else |
251 | false |
252 | #endif |
253 | ; |
254 | |
255 | static const bool have_memcntl = |
256 | #ifdef JEMALLOC_HAVE_MEMCNTL |
257 | true |
258 | #else |
259 | false |
260 | #endif |
261 | ; |
262 | |
263 | #endif /* JEMALLOC_PREAMBLE_H */ |
264 | |