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