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