blob: e172c661243f696091e35008faeda10813250f62 [file] [log] [blame]
Jason Evans0f4f1ef2013-12-12 14:41:02 -08001#ifndef JEMALLOC_INTERNAL_DEFS_H_
2#define JEMALLOC_INTERNAL_DEFS_H_
Jason Evans86abd0d2013-11-30 15:25:42 -08003/*
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 * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
13 * For shared libraries, symbol visibility mechanisms prevent these symbols
14 * from being exported, but for static libraries, naming collisions are a real
15 * possibility.
16 */
17#undef JEMALLOC_PRIVATE_NAMESPACE
18
19/*
20 * Hyper-threaded CPUs may need a special instruction inside spin loops in
21 * order to yield to another virtual CPU.
22 */
23#undef CPU_SPINWAIT
24
Chih-hung Hsieh59cd80e2014-12-05 17:42:41 -080025/* Defined if C11 atomics are available. */
26#undef JEMALLOC_C11ATOMICS
27
Jason Evans86abd0d2013-11-30 15:25:42 -080028/* Defined if the equivalent of FreeBSD's atomic(9) functions are available. */
29#undef JEMALLOC_ATOMIC9
30
31/*
32 * Defined if OSAtomic*() functions are available, as provided by Darwin, and
33 * documented in the atomic(3) manual page.
34 */
35#undef JEMALLOC_OSATOMIC
36
37/*
38 * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and
39 * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite
40 * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the
Jason Evanse12eaf92014-12-08 14:40:14 -080041 * functions are defined in libgcc instead of being inlines).
Jason Evans86abd0d2013-11-30 15:25:42 -080042 */
43#undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4
44
45/*
46 * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and
47 * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite
48 * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the
Jason Evanse12eaf92014-12-08 14:40:14 -080049 * functions are defined in libgcc instead of being inlines).
Jason Evans86abd0d2013-11-30 15:25:42 -080050 */
51#undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8
52
53/*
Jason Evansd04047c2014-05-28 16:11:55 -070054 * Defined if __builtin_clz() and __builtin_clzl() are available.
55 */
56#undef JEMALLOC_HAVE_BUILTIN_CLZ
57
58/*
Richard Diamond994fad92014-06-03 02:39:18 -050059 * Defined if madvise(2) is available.
60 */
61#undef JEMALLOC_HAVE_MADVISE
62
63/*
Jason Evans86abd0d2013-11-30 15:25:42 -080064 * Defined if OSSpin*() functions are available, as provided by Darwin, and
65 * documented in the spinlock(3) manual page.
66 */
67#undef JEMALLOC_OSSPIN
68
69/*
70 * Defined if _malloc_thread_cleanup() exists. At least in the case of
71 * FreeBSD, pthread_key_create() allocates, which if used during malloc
72 * bootstrapping will cause recursion into the pthreads library. Therefore, if
73 * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in
74 * malloc_tsd.
75 */
76#undef JEMALLOC_MALLOC_THREAD_CLEANUP
77
78/*
79 * Defined if threaded initialization is known to be safe on this platform.
80 * Among other things, it must be possible to initialize a mutex without
81 * triggering allocation in order for threaded allocation to be safe.
82 */
83#undef JEMALLOC_THREADED_INIT
84
85/*
86 * Defined if the pthreads implementation defines
87 * _pthread_mutex_init_calloc_cb(), in which case the function is used in order
88 * to avoid recursive allocation during mutex initialization.
89 */
90#undef JEMALLOC_MUTEX_INIT_CB
91
Jason Evans86abd0d2013-11-30 15:25:42 -080092/* Non-empty if the tls_model attribute is supported. */
93#undef JEMALLOC_TLS_MODEL
94
95/* JEMALLOC_CC_SILENCE enables code that silences unuseful compiler warnings. */
96#undef JEMALLOC_CC_SILENCE
97
Jason Evans748dfac2013-12-06 18:27:33 -080098/* JEMALLOC_CODE_COVERAGE enables test code coverage analysis. */
99#undef JEMALLOC_CODE_COVERAGE
100
Jason Evans86abd0d2013-11-30 15:25:42 -0800101/*
102 * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
103 * inline functions.
104 */
105#undef JEMALLOC_DEBUG
106
Jason Evans86abd0d2013-11-30 15:25:42 -0800107/* JEMALLOC_STATS enables statistics calculation. */
108#undef JEMALLOC_STATS
109
110/* JEMALLOC_PROF enables allocation profiling. */
111#undef JEMALLOC_PROF
112
113/* Use libunwind for profile backtracing if defined. */
114#undef JEMALLOC_PROF_LIBUNWIND
115
116/* Use libgcc for profile backtracing if defined. */
117#undef JEMALLOC_PROF_LIBGCC
118
119/* Use gcc intrinsics for profile backtracing if defined. */
120#undef JEMALLOC_PROF_GCC
121
122/*
123 * JEMALLOC_TCACHE enables a thread-specific caching layer for small objects.
124 * This makes it possible to allocate/deallocate objects without any locking
125 * when the cache is in the steady state.
126 */
127#undef JEMALLOC_TCACHE
128
129/*
130 * JEMALLOC_DSS enables use of sbrk(2) to allocate chunks from the data storage
131 * segment (DSS).
132 */
133#undef JEMALLOC_DSS
134
135/* Support memory filling (junk/zero/quarantine/redzone). */
136#undef JEMALLOC_FILL
137
138/* Support utrace(2)-based tracing. */
139#undef JEMALLOC_UTRACE
140
141/* Support Valgrind. */
142#undef JEMALLOC_VALGRIND
143
144/* Support optional abort() on OOM. */
145#undef JEMALLOC_XMALLOC
146
147/* Support lazy locking (avoid locking unless a second thread is launched). */
148#undef JEMALLOC_LAZY_LOCK
149
Jason Evans81e54752014-10-10 22:34:25 -0700150/* Minimum size class to support is 2^LG_TINY_MIN bytes. */
151#undef LG_TINY_MIN
152
Jason Evansfc0b3b72014-10-09 17:54:06 -0700153/*
154 * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size
155 * classes).
156 */
157#undef LG_QUANTUM
158
159/* One page is 2^LG_PAGE bytes. */
160#undef LG_PAGE
Jason Evans86abd0d2013-11-30 15:25:42 -0800161
162/*
163 * If defined, use munmap() to unmap freed chunks, rather than storing them for
164 * later reuse. This is disabled by default on Linux because common sequences
165 * of mmap()/munmap() calls will cause virtual memory map holes.
166 */
167#undef JEMALLOC_MUNMAP
168
Jason Evans86abd0d2013-11-30 15:25:42 -0800169/* TLS is used to map arenas and magazine caches to threads. */
170#undef JEMALLOC_TLS
171
172/*
Richard Diamond9c3a10f2014-05-28 21:37:02 -0500173 * ffs()/ffsl() functions to use for bitmapping. Don't use these directly;
174 * instead, use jemalloc_ffs() or jemalloc_ffsl() from util.h.
175 */
176#undef JEMALLOC_INTERNAL_FFSL
177#undef JEMALLOC_INTERNAL_FFS
178
179/*
Jason Evans86abd0d2013-11-30 15:25:42 -0800180 * JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside
181 * within jemalloc-owned chunks before dereferencing them.
182 */
183#undef JEMALLOC_IVSALLOC
184
185/*
Jason Evans86abd0d2013-11-30 15:25:42 -0800186 * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
187 */
188#undef JEMALLOC_ZONE
189#undef JEMALLOC_ZONE_VERSION
190
191/*
192 * Methods for purging unused pages differ between operating systems.
193 *
194 * madvise(..., MADV_DONTNEED) : On Linux, this immediately discards pages,
195 * such that new pages will be demand-zeroed if
196 * the address region is later touched.
197 * madvise(..., MADV_FREE) : On FreeBSD and Darwin, this marks pages as being
198 * unused, such that they will be discarded rather
199 * than swapped out.
200 */
201#undef JEMALLOC_PURGE_MADVISE_DONTNEED
202#undef JEMALLOC_PURGE_MADVISE_FREE
203
Jason Evanse12eaf92014-12-08 14:40:14 -0800204/* Define if operating system has alloca.h header. */
Jason Evans86abd0d2013-11-30 15:25:42 -0800205#undef JEMALLOC_HAS_ALLOCA_H
206
Jason Evans99b0fbb2014-02-24 16:08:38 -0800207/* C99 restrict keyword supported. */
208#undef JEMALLOC_HAS_RESTRICT
209
Jason Evansdf3f2702014-03-30 16:27:08 -0700210/* For use by hash code. */
211#undef JEMALLOC_BIG_ENDIAN
212
Jason Evans86abd0d2013-11-30 15:25:42 -0800213/* sizeof(int) == 2^LG_SIZEOF_INT. */
214#undef LG_SIZEOF_INT
215
216/* sizeof(long) == 2^LG_SIZEOF_LONG. */
217#undef LG_SIZEOF_LONG
218
219/* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
220#undef LG_SIZEOF_INTMAX_T
Jason Evans0f4f1ef2013-12-12 14:41:02 -0800221
Jason Evanse12eaf92014-12-08 14:40:14 -0800222/* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */
Sara Golemon3e24afa2014-08-18 13:06:39 -0700223#undef JEMALLOC_GLIBC_MALLOC_HOOK
224
Jason Evanse12eaf92014-12-08 14:40:14 -0800225/* glibc memalign hook. */
Sara Golemon3e24afa2014-08-18 13:06:39 -0700226#undef JEMALLOC_GLIBC_MEMALIGN_HOOK
227
Jason Evanse12eaf92014-12-08 14:40:14 -0800228/* Adaptive mutex support in pthreads. */
Eric Wong4dcf04b2014-08-31 03:57:06 +0000229#undef JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
230
Jason Evans0f4f1ef2013-12-12 14:41:02 -0800231#endif /* JEMALLOC_INTERNAL_DEFS_H_ */