• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#ifndef JEMALLOC_INTERNAL_DEFS_H_
2#define JEMALLOC_INTERNAL_DEFS_H_
3/*
4 * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all
5 * public APIs to be prefixed.  This makes it possible, with some care, to use
6 * multiple allocators simultaneously.
7 */
8#undef JEMALLOC_PREFIX
9#undef JEMALLOC_CPREFIX
10
11/*
12 * Define overrides for non-standard allocator-related functions if they are
13 * present on the system.
14 */
15#undef JEMALLOC_OVERRIDE___LIBC_CALLOC
16#undef JEMALLOC_OVERRIDE___LIBC_FREE
17#undef JEMALLOC_OVERRIDE___LIBC_MALLOC
18#undef JEMALLOC_OVERRIDE___LIBC_MEMALIGN
19#undef JEMALLOC_OVERRIDE___LIBC_REALLOC
20#undef JEMALLOC_OVERRIDE___LIBC_VALLOC
21#undef JEMALLOC_OVERRIDE___POSIX_MEMALIGN
22
23/*
24 * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
25 * For shared libraries, symbol visibility mechanisms prevent these symbols
26 * from being exported, but for static libraries, naming collisions are a real
27 * possibility.
28 */
29#undef JEMALLOC_PRIVATE_NAMESPACE
30
31/*
32 * Hyper-threaded CPUs may need a special instruction inside spin loops in
33 * order to yield to another virtual CPU.
34 */
35#undef CPU_SPINWAIT
36/* 1 if CPU_SPINWAIT is defined, 0 otherwise. */
37#undef HAVE_CPU_SPINWAIT
38
39/*
40 * Number of significant bits in virtual addresses.  This may be less than the
41 * total number of bits in a pointer, e.g. on x64, for which the uppermost 16
42 * bits are the same as bit 47.
43 */
44#undef LG_VADDR
45
46/* Defined if C11 atomics are available. */
47#undef JEMALLOC_C11_ATOMICS
48
49/* Defined if GCC __atomic atomics are available. */
50#undef JEMALLOC_GCC_ATOMIC_ATOMICS
51
52/* Defined if GCC __sync atomics are available. */
53#undef JEMALLOC_GCC_SYNC_ATOMICS
54
55/*
56 * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and
57 * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite
58 * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the
59 * functions are defined in libgcc instead of being inlines).
60 */
61#undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4
62
63/*
64 * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and
65 * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite
66 * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the
67 * functions are defined in libgcc instead of being inlines).
68 */
69#undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8
70
71/*
72 * Defined if __builtin_clz() and __builtin_clzl() are available.
73 */
74#undef JEMALLOC_HAVE_BUILTIN_CLZ
75
76/*
77 * Defined if os_unfair_lock_*() functions are available, as provided by Darwin.
78 */
79#undef JEMALLOC_OS_UNFAIR_LOCK
80
81/*
82 * Defined if OSSpin*() functions are available, as provided by Darwin, and
83 * documented in the spinlock(3) manual page.
84 */
85#undef JEMALLOC_OSSPIN
86
87/* Defined if syscall(2) is usable. */
88#undef JEMALLOC_USE_SYSCALL
89
90/*
91 * Defined if secure_getenv(3) is available.
92 */
93#undef JEMALLOC_HAVE_SECURE_GETENV
94
95/*
96 * Defined if issetugid(2) is available.
97 */
98#undef JEMALLOC_HAVE_ISSETUGID
99
100/* Defined if pthread_atfork(3) is available. */
101#undef JEMALLOC_HAVE_PTHREAD_ATFORK
102
103/* Defined if pthread_setname_np(3) is available. */
104#undef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
105
106/*
107 * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available.
108 */
109#undef JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE
110
111/*
112 * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available.
113 */
114#undef JEMALLOC_HAVE_CLOCK_MONOTONIC
115
116/*
117 * Defined if mach_absolute_time() is available.
118 */
119#undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME
120
121/*
122 * Defined if _malloc_thread_cleanup() exists.  At least in the case of
123 * FreeBSD, pthread_key_create() allocates, which if used during malloc
124 * bootstrapping will cause recursion into the pthreads library.  Therefore, if
125 * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in
126 * malloc_tsd.
127 */
128#undef JEMALLOC_MALLOC_THREAD_CLEANUP
129
130/*
131 * Defined if threaded initialization is known to be safe on this platform.
132 * Among other things, it must be possible to initialize a mutex without
133 * triggering allocation in order for threaded allocation to be safe.
134 */
135#undef JEMALLOC_THREADED_INIT
136
137/*
138 * Defined if the pthreads implementation defines
139 * _pthread_mutex_init_calloc_cb(), in which case the function is used in order
140 * to avoid recursive allocation during mutex initialization.
141 */
142#undef JEMALLOC_MUTEX_INIT_CB
143
144/* Non-empty if the tls_model attribute is supported. */
145#undef JEMALLOC_TLS_MODEL
146
147/*
148 * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
149 * inline functions.
150 */
151#undef JEMALLOC_DEBUG
152
153/* JEMALLOC_STATS enables statistics calculation. */
154#undef JEMALLOC_STATS
155
156/* JEMALLOC_PROF enables allocation profiling. */
157#undef JEMALLOC_PROF
158
159/* Use libunwind for profile backtracing if defined. */
160#undef JEMALLOC_PROF_LIBUNWIND
161
162/* Use libgcc for profile backtracing if defined. */
163#undef JEMALLOC_PROF_LIBGCC
164
165/* Use gcc intrinsics for profile backtracing if defined. */
166#undef JEMALLOC_PROF_GCC
167
168/*
169 * JEMALLOC_DSS enables use of sbrk(2) to allocate extents from the data storage
170 * segment (DSS).
171 */
172#undef JEMALLOC_DSS
173
174/* Support memory filling (junk/zero). */
175#undef JEMALLOC_FILL
176
177/* Support utrace(2)-based tracing. */
178#undef JEMALLOC_UTRACE
179
180/* Support optional abort() on OOM. */
181#undef JEMALLOC_XMALLOC
182
183/* Support lazy locking (avoid locking unless a second thread is launched). */
184#undef JEMALLOC_LAZY_LOCK
185
186/*
187 * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size
188 * classes).
189 */
190#undef LG_QUANTUM
191
192/* One page is 2^LG_PAGE bytes. */
193#undef LG_PAGE
194
195/*
196 * One huge page is 2^LG_HUGEPAGE bytes.  Note that this is defined even if the
197 * system does not explicitly support huge pages; system calls that require
198 * explicit huge page support are separately configured.
199 */
200#undef LG_HUGEPAGE
201
202/*
203 * If defined, adjacent virtual memory mappings with identical attributes
204 * automatically coalesce, and they fragment when changes are made to subranges.
205 * This is the normal order of things for mmap()/munmap(), but on Windows
206 * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e.
207 * mappings do *not* coalesce/fragment.
208 */
209#undef JEMALLOC_MAPS_COALESCE
210
211/*
212 * If defined, retain memory for later reuse by default rather than using e.g.
213 * munmap() to unmap freed extents.  This is enabled on 64-bit Linux because
214 * common sequences of mmap()/munmap() calls will cause virtual memory map
215 * holes.
216 */
217#undef JEMALLOC_RETAIN
218
219/* TLS is used to map arenas and magazine caches to threads. */
220#undef JEMALLOC_TLS
221
222/*
223 * Used to mark unreachable code to quiet "end of non-void" compiler warnings.
224 * Don't use this directly; instead use unreachable() from util.h
225 */
226#undef JEMALLOC_INTERNAL_UNREACHABLE
227
228/*
229 * ffs*() functions to use for bitmapping.  Don't use these directly; instead,
230 * use ffs_*() from util.h.
231 */
232#undef JEMALLOC_INTERNAL_FFSLL
233#undef JEMALLOC_INTERNAL_FFSL
234#undef JEMALLOC_INTERNAL_FFS
235
236/*
237 * If defined, explicitly attempt to more uniformly distribute large allocation
238 * pointer alignments across all cache indices.
239 */
240#undef JEMALLOC_CACHE_OBLIVIOUS
241
242/*
243 * If defined, enable logging facilities.  We make this a configure option to
244 * avoid taking extra branches everywhere.
245 */
246#undef JEMALLOC_LOG
247
248/*
249 * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
250 */
251#undef JEMALLOC_ZONE
252
253/*
254 * Methods for determining whether the OS overcommits.
255 * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's
256 *                                         /proc/sys/vm.overcommit_memory file.
257 * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl.
258 */
259#undef JEMALLOC_SYSCTL_VM_OVERCOMMIT
260#undef JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY
261
262/* Defined if madvise(2) is available. */
263#undef JEMALLOC_HAVE_MADVISE
264
265/*
266 * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE
267 * arguments to madvise(2).
268 */
269#undef JEMALLOC_HAVE_MADVISE_HUGE
270
271/*
272 * Methods for purging unused pages differ between operating systems.
273 *
274 *   madvise(..., MADV_FREE) : This marks pages as being unused, such that they
275 *                             will be discarded rather than swapped out.
276 *   madvise(..., MADV_DONTNEED) : If JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS is
277 *                                 defined, this immediately discards pages,
278 *                                 such that new pages will be demand-zeroed if
279 *                                 the address region is later touched;
280 *                                 otherwise this behaves similarly to
281 *                                 MADV_FREE, though typically with higher
282 *                                 system overhead.
283 */
284#undef JEMALLOC_PURGE_MADVISE_FREE
285#undef JEMALLOC_PURGE_MADVISE_DONTNEED
286#undef JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS
287
288/* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */
289#undef JEMALLOC_DEFINE_MADVISE_FREE
290
291/*
292 * Defined if MADV_DO[NT]DUMP is supported as an argument to madvise.
293 */
294#undef JEMALLOC_MADVISE_DONTDUMP
295
296/*
297 * Defined if transparent huge pages (THPs) are supported via the
298 * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled.
299 */
300#undef JEMALLOC_THP
301
302/* Define if operating system has alloca.h header. */
303#undef JEMALLOC_HAS_ALLOCA_H
304
305/* C99 restrict keyword supported. */
306#undef JEMALLOC_HAS_RESTRICT
307
308/* For use by hash code. */
309#undef JEMALLOC_BIG_ENDIAN
310
311/* sizeof(int) == 2^LG_SIZEOF_INT. */
312#undef LG_SIZEOF_INT
313
314/* sizeof(long) == 2^LG_SIZEOF_LONG. */
315#undef LG_SIZEOF_LONG
316
317/* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */
318#undef LG_SIZEOF_LONG_LONG
319
320/* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
321#undef LG_SIZEOF_INTMAX_T
322
323/* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */
324#undef JEMALLOC_GLIBC_MALLOC_HOOK
325
326/* glibc memalign hook. */
327#undef JEMALLOC_GLIBC_MEMALIGN_HOOK
328
329/* pthread support */
330#undef JEMALLOC_HAVE_PTHREAD
331
332/* dlsym() support */
333#undef JEMALLOC_HAVE_DLSYM
334
335/* Adaptive mutex support in pthreads. */
336#undef JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
337
338/* GNU specific sched_getcpu support */
339#undef JEMALLOC_HAVE_SCHED_GETCPU
340
341/* GNU specific sched_setaffinity support */
342#undef JEMALLOC_HAVE_SCHED_SETAFFINITY
343
344/*
345 * If defined, all the features necessary for background threads are present.
346 */
347#undef JEMALLOC_BACKGROUND_THREAD
348
349/*
350 * If defined, jemalloc symbols are not exported (doesn't work when
351 * JEMALLOC_PREFIX is not defined).
352 */
353#undef JEMALLOC_EXPORT
354
355/* config.malloc_conf options string. */
356#undef JEMALLOC_CONFIG_MALLOC_CONF
357
358/* If defined, jemalloc takes the malloc/free/etc. symbol names. */
359#undef JEMALLOC_IS_MALLOC
360
361/*
362 * Defined if strerror_r returns char * if _GNU_SOURCE is defined.
363 */
364#undef JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE
365
366#endif /* JEMALLOC_INTERNAL_DEFS_H_ */
367