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