1 /* include/jemalloc/internal/jemalloc_internal_defs.h. Generated from jemalloc_internal_defs.h.in by configure. */
2 #ifndef JEMALLOC_INTERNAL_DEFS_H_
3 #define JEMALLOC_INTERNAL_DEFS_H_
5 * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all
6 * public APIs to be prefixed. This makes it possible, with some care, to use
7 * multiple allocators simultaneously.
9 /* #undef JEMALLOC_PREFIX */
10 /* #undef JEMALLOC_CPREFIX */
13 * Define overrides for non-standard allocator-related functions if they are
14 * present on the system.
16 /* #undef JEMALLOC_OVERRIDE___LIBC_CALLOC */
17 /* #undef JEMALLOC_OVERRIDE___LIBC_FREE */
18 /* #undef JEMALLOC_OVERRIDE___LIBC_MALLOC */
19 /* #undef JEMALLOC_OVERRIDE___LIBC_MEMALIGN */
20 /* #undef JEMALLOC_OVERRIDE___LIBC_REALLOC */
21 /* #undef JEMALLOC_OVERRIDE___LIBC_VALLOC */
22 #define JEMALLOC_OVERRIDE___POSIX_MEMALIGN
25 * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
26 * For shared libraries, symbol visibility mechanisms prevent these symbols
27 * from being exported, but for static libraries, naming collisions are a real
30 #define JEMALLOC_PRIVATE_NAMESPACE __je_
33 * Hyper-threaded CPUs may need a special instruction inside spin loops in
34 * order to yield to another virtual CPU.
36 #define CPU_SPINWAIT __asm__ volatile("pause")
37 /* 1 if CPU_SPINWAIT is defined, 0 otherwise. */
38 #define HAVE_CPU_SPINWAIT 1
41 * Number of significant bits in virtual addresses. This may be less than the
42 * total number of bits in a pointer, e.g. on x64, for which the uppermost 16
43 * bits are the same as bit 47.
47 /* Defined if C11 atomics are available. */
48 /* #undef JEMALLOC_C11_ATOMICS */
50 /* Defined if GCC __atomic atomics are available. */
51 /* #undef JEMALLOC_GCC_ATOMIC_ATOMICS */
53 /* Defined if GCC __sync atomics are available. */
54 #define JEMALLOC_GCC_SYNC_ATOMICS 1
57 * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and
58 * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite
59 * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the
60 * functions are defined in libgcc instead of being inlines).
62 #define JE_FORCE_SYNC_COMPARE_AND_SWAP_4
65 * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and
66 * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite
67 * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the
68 * functions are defined in libgcc instead of being inlines).
70 #define JE_FORCE_SYNC_COMPARE_AND_SWAP_8
73 * Defined if __builtin_clz() and __builtin_clzl() are available.
75 #define JEMALLOC_HAVE_BUILTIN_CLZ
78 * Defined if os_unfair_lock_*() functions are available, as provided by Darwin.
80 /* #undef JEMALLOC_OS_UNFAIR_LOCK */
83 * Defined if OSSpin*() functions are available, as provided by Darwin, and
84 * documented in the spinlock(3) manual page.
86 /* #undef JEMALLOC_OSSPIN */
88 /* Defined if syscall(2) is usable. */
89 #define JEMALLOC_USE_SYSCALL
92 * Defined if secure_getenv(3) is available.
94 /* #undef JEMALLOC_HAVE_SECURE_GETENV */
97 * Defined if issetugid(2) is available.
99 #define JEMALLOC_HAVE_ISSETUGID
101 /* Defined if pthread_atfork(3) is available. */
102 #define JEMALLOC_HAVE_PTHREAD_ATFORK
104 /* Defined if pthread_setname_np(3) is available. */
105 /* #undef JEMALLOC_HAVE_PTHREAD_SETNAME_NP */
108 * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available.
110 /* #undef JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE */
113 * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available.
115 #define JEMALLOC_HAVE_CLOCK_MONOTONIC 1
118 * Defined if mach_absolute_time() is available.
120 /* #undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME */
123 * Defined if _malloc_thread_cleanup() exists. At least in the case of
124 * FreeBSD, pthread_key_create() allocates, which if used during malloc
125 * bootstrapping will cause recursion into the pthreads library. Therefore, if
126 * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in
129 #define JEMALLOC_MALLOC_THREAD_CLEANUP
132 * Defined if threaded initialization is known to be safe on this platform.
133 * Among other things, it must be possible to initialize a mutex without
134 * triggering allocation in order for threaded allocation to be safe.
136 /* #undef JEMALLOC_THREADED_INIT */
139 * Defined if the pthreads implementation defines
140 * _pthread_mutex_init_calloc_cb(), in which case the function is used in order
141 * to avoid recursive allocation during mutex initialization.
143 #define JEMALLOC_MUTEX_INIT_CB 1
145 /* Non-empty if the tls_model attribute is supported. */
146 #define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec")))
149 * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
152 /* #undef JEMALLOC_DEBUG */
154 /* JEMALLOC_STATS enables statistics calculation. */
155 #define JEMALLOC_STATS
157 /* JEMALLOC_PROF enables allocation profiling. */
158 /* #undef JEMALLOC_PROF */
160 /* Use libunwind for profile backtracing if defined. */
161 /* #undef JEMALLOC_PROF_LIBUNWIND */
163 /* Use libgcc for profile backtracing if defined. */
164 /* #undef JEMALLOC_PROF_LIBGCC */
166 /* Use gcc intrinsics for profile backtracing if defined. */
167 /* #undef JEMALLOC_PROF_GCC */
170 * JEMALLOC_DSS enables use of sbrk(2) to allocate extents from the data storage
175 /* Support memory filling (junk/zero). */
176 #define JEMALLOC_FILL
178 /* Support utrace(2)-based tracing. */
179 #define JEMALLOC_UTRACE
181 /* Support optional abort() on OOM. */
182 #define JEMALLOC_XMALLOC
184 /* Support lazy locking (avoid locking unless a second thread is launched). */
185 #define JEMALLOC_LAZY_LOCK
188 * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size
191 /* #undef LG_QUANTUM */
193 /* One page is 2^LG_PAGE bytes. */
197 * One huge page is 2^LG_HUGEPAGE bytes. Note that this is defined even if the
198 * system does not explicitly support huge pages; system calls that require
199 * explicit huge page support are separately configured.
201 #define LG_HUGEPAGE 21
204 * If defined, adjacent virtual memory mappings with identical attributes
205 * automatically coalesce, and they fragment when changes are made to subranges.
206 * This is the normal order of things for mmap()/munmap(), but on Windows
207 * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e.
208 * mappings do *not* coalesce/fragment.
210 #define JEMALLOC_MAPS_COALESCE
213 * If defined, retain memory for later reuse by default rather than using e.g.
214 * munmap() to unmap freed extents. This is enabled on 64-bit Linux because
215 * common sequences of mmap()/munmap() calls will cause virtual memory map
218 /* #undef JEMALLOC_RETAIN */
220 /* TLS is used to map arenas and magazine caches to threads. */
224 * Used to mark unreachable code to quiet "end of non-void" compiler warnings.
225 * Don't use this directly; instead use unreachable() from util.h
227 #define JEMALLOC_INTERNAL_UNREACHABLE abort
230 * ffs*() functions to use for bitmapping. Don't use these directly; instead,
231 * use ffs_*() from util.h.
233 #define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll
234 #define JEMALLOC_INTERNAL_FFSL __builtin_ffsl
235 #define JEMALLOC_INTERNAL_FFS __builtin_ffs
238 * If defined, explicitly attempt to more uniformly distribute large allocation
239 * pointer alignments across all cache indices.
241 #define JEMALLOC_CACHE_OBLIVIOUS
244 * If defined, enable logging facilities. We make this a configure option to
245 * avoid taking extra branches everywhere.
247 /* #undef JEMALLOC_LOG */
250 * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
252 /* #undef JEMALLOC_ZONE */
255 * Methods for determining whether the OS overcommits.
256 * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's
257 * /proc/sys/vm.overcommit_memory file.
258 * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl.
260 #define JEMALLOC_SYSCTL_VM_OVERCOMMIT
261 /* #undef JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY */
263 /* Defined if madvise(2) is available. */
264 #define JEMALLOC_HAVE_MADVISE
267 * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE
268 * arguments to madvise(2).
270 /* #undef JEMALLOC_HAVE_MADVISE_HUGE */
273 * Methods for purging unused pages differ between operating systems.
275 * madvise(..., MADV_FREE) : This marks pages as being unused, such that they
276 * will be discarded rather than swapped out.
277 * madvise(..., MADV_DONTNEED) : If JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS is
278 * defined, this immediately discards pages,
279 * such that new pages will be demand-zeroed if
280 * the address region is later touched;
281 * otherwise this behaves similarly to
282 * MADV_FREE, though typically with higher
285 #define JEMALLOC_PURGE_MADVISE_FREE
286 #define JEMALLOC_PURGE_MADVISE_DONTNEED
287 /* #undef JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS */
289 /* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */
290 /* #undef JEMALLOC_DEFINE_MADVISE_FREE */
293 * Defined if MADV_DO[NT]DUMP is supported as an argument to madvise.
295 /* #undef JEMALLOC_MADVISE_DONTDUMP */
298 * Defined if transparent huge pages (THPs) are supported via the
299 * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled.
301 /* #undef JEMALLOC_THP */
303 /* Define if operating system has alloca.h header. */
304 /* #undef JEMALLOC_HAS_ALLOCA_H */
306 /* C99 restrict keyword supported. */
307 #define JEMALLOC_HAS_RESTRICT 1
309 /* For use by hash code. */
310 /* #undef JEMALLOC_BIG_ENDIAN */
312 /* sizeof(int) == 2^LG_SIZEOF_INT. */
313 #define LG_SIZEOF_INT 2
315 /* sizeof(long) == 2^LG_SIZEOF_LONG. */
316 #define LG_SIZEOF_LONG 3
318 /* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */
319 #define LG_SIZEOF_LONG_LONG 3
321 /* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
322 #define LG_SIZEOF_INTMAX_T 3
324 /* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */
325 /* #undef JEMALLOC_GLIBC_MALLOC_HOOK */
327 /* glibc memalign hook. */
328 /* #undef JEMALLOC_GLIBC_MEMALIGN_HOOK */
330 /* pthread support */
331 #define JEMALLOC_HAVE_PTHREAD
333 /* dlsym() support */
334 #define JEMALLOC_HAVE_DLSYM
336 /* Adaptive mutex support in pthreads. */
337 #define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
339 /* GNU specific sched_getcpu support */
340 /* #undef JEMALLOC_HAVE_SCHED_GETCPU */
342 /* GNU specific sched_setaffinity support */
343 /* #undef JEMALLOC_HAVE_SCHED_SETAFFINITY */
346 * If defined, all the features necessary for background threads are present.
348 #define JEMALLOC_BACKGROUND_THREAD 1
351 * If defined, jemalloc symbols are not exported (doesn't work when
352 * JEMALLOC_PREFIX is not defined).
354 /* #undef JEMALLOC_EXPORT */
356 /* config.malloc_conf options string. */
357 #define JEMALLOC_CONFIG_MALLOC_CONF "abort_conf:false"
359 /* If defined, jemalloc takes the malloc/free/etc. symbol names. */
360 #define JEMALLOC_IS_MALLOC 1
363 * Defined if strerror_r returns char * if _GNU_SOURCE is defined.
365 /* #undef JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE */
367 #endif /* JEMALLOC_INTERNAL_DEFS_H_ */