1 /* include/jemalloc/jemalloc_defs.h. Generated from jemalloc_defs.h.in by configure. */
3 * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all
4 * public APIs to be prefixed. This makes it possible, with some care, to use
5 * multiple allocators simultaneously.
7 /* #undef JEMALLOC_PREFIX */
8 /* #undef JEMALLOC_CPREFIX */
11 * Name mangling for public symbols is controlled by --with-mangling and
12 * --with-jemalloc-prefix. With default settings the je_ prefix is stripped by
13 * these macro definitions.
15 #define je_malloc_conf malloc_conf
16 #define je_malloc_message malloc_message
17 #define je_malloc malloc
18 #define je_calloc calloc
19 #define je_posix_memalign posix_memalign
20 #define je_aligned_alloc aligned_alloc
21 #define je_realloc realloc
23 #define je_malloc_usable_size malloc_usable_size
24 #define je_malloc_stats_print malloc_stats_print
25 #define je_mallctl mallctl
26 #define je_mallctlnametomib mallctlnametomib
27 #define je_mallctlbymib mallctlbymib
28 /* #undef je_memalign */
29 #define je_valloc valloc
30 #define je_allocm allocm
31 #define je_rallocm rallocm
32 #define je_sallocm sallocm
33 #define je_dallocm dallocm
34 #define je_nallocm nallocm
37 * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
38 * For shared libraries, symbol visibility mechanisms prevent these symbols
39 * from being exported, but for static libraries, naming collisions are a real
42 #define JEMALLOC_PRIVATE_NAMESPACE "__jemalloc_"
43 #define JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix) __jemalloc_##string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix
46 * Hyper-threaded CPUs may need a special instruction inside spin loops in
47 * order to yield to another virtual CPU.
49 #define CPU_SPINWAIT __asm__ volatile("pause")
51 /* Defined if the equivalent of FreeBSD's atomic(9) functions are available. */
52 #define JEMALLOC_ATOMIC9 1
55 * Defined if OSAtomic*() functions are available, as provided by Darwin, and
56 * documented in the atomic(3) manual page.
58 /* #undef JEMALLOC_OSATOMIC */
61 * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and
62 * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite
63 * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the
64 * functions are defined in libgcc instead of being inlines)
66 /* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4 */
69 * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and
70 * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite
71 * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the
72 * functions are defined in libgcc instead of being inlines)
74 /* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8 */
77 * Defined if OSSpin*() functions are available, as provided by Darwin, and
78 * documented in the spinlock(3) manual page.
80 /* #undef JEMALLOC_OSSPIN */
83 * Defined if _malloc_thread_cleanup() exists. At least in the case of
84 * FreeBSD, pthread_key_create() allocates, which if used during malloc
85 * bootstrapping will cause recursion into the pthreads library. Therefore, if
86 * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in
89 #define JEMALLOC_MALLOC_THREAD_CLEANUP
92 * Defined if threaded initialization is known to be safe on this platform.
93 * Among other things, it must be possible to initialize a mutex without
94 * triggering allocation in order for threaded allocation to be safe.
96 /* #undef JEMALLOC_THREADED_INIT */
99 * Defined if the pthreads implementation defines
100 * _pthread_mutex_init_calloc_cb(), in which case the function is used in order
101 * to avoid recursive allocation during mutex initialization.
103 #define JEMALLOC_MUTEX_INIT_CB 1
105 /* Defined if __attribute__((...)) syntax is supported. */
106 #define JEMALLOC_HAVE_ATTR
107 #ifdef JEMALLOC_HAVE_ATTR
108 # define JEMALLOC_ATTR(s) __attribute__((s))
109 # define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
110 # define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s))
111 # define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s))
112 # define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline)
114 # define JEMALLOC_ATTR(s)
116 # define JEMALLOC_EXPORT __declspec(dllexport)
118 # define JEMALLOC_EXPORT __declspec(dllimport)
120 # define JEMALLOC_ALIGNED(s) __declspec(align(s))
121 # define JEMALLOC_SECTION(s) __declspec(allocate(s))
122 # define JEMALLOC_NOINLINE __declspec(noinline)
124 # define JEMALLOC_ATTR(s)
125 # define JEMALLOC_EXPORT
126 # define JEMALLOC_ALIGNED(s)
127 # define JEMALLOC_SECTION(s)
128 # define JEMALLOC_NOINLINE
131 /* Defined if sbrk() is supported. */
132 #define JEMALLOC_HAVE_SBRK
134 /* Non-empty if the tls_model attribute is supported. */
135 #define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec")))
137 /* JEMALLOC_CC_SILENCE enables code that silences unuseful compiler warnings. */
138 #define JEMALLOC_CC_SILENCE
141 * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
144 /* #undef JEMALLOC_DEBUG */
146 /* JEMALLOC_STATS enables statistics calculation. */
147 #define JEMALLOC_STATS
149 /* JEMALLOC_PROF enables allocation profiling. */
150 /* #undef JEMALLOC_PROF */
152 /* Use libunwind for profile backtracing if defined. */
153 /* #undef JEMALLOC_PROF_LIBUNWIND */
155 /* Use libgcc for profile backtracing if defined. */
156 /* #undef JEMALLOC_PROF_LIBGCC */
158 /* Use gcc intrinsics for profile backtracing if defined. */
159 /* #undef JEMALLOC_PROF_GCC */
162 * JEMALLOC_TCACHE enables a thread-specific caching layer for small objects.
163 * This makes it possible to allocate/deallocate objects without any locking
164 * when the cache is in the steady state.
166 #define JEMALLOC_TCACHE
169 * JEMALLOC_DSS enables use of sbrk(2) to allocate chunks from the data storage
174 /* Support memory filling (junk/zero/quarantine/redzone). */
175 #define JEMALLOC_FILL
177 /* Support the experimental API. */
178 #define JEMALLOC_EXPERIMENTAL
180 /* Support utrace(2)-based tracing. */
181 #define JEMALLOC_UTRACE
183 /* Support Valgrind. */
184 /* #undef JEMALLOC_VALGRIND */
186 /* Support optional abort() on OOM. */
187 #define JEMALLOC_XMALLOC
189 /* Support lazy locking (avoid locking unless a second thread is launched). */
190 #define JEMALLOC_LAZY_LOCK
192 /* One page is 2^STATIC_PAGE_SHIFT bytes. */
193 #define STATIC_PAGE_SHIFT 12
196 * If defined, use munmap() to unmap freed chunks, rather than storing them for
197 * later reuse. This is disabled by default on Linux because common sequences
198 * of mmap()/munmap() calls will cause virtual memory map holes.
200 #define JEMALLOC_MUNMAP
203 * If defined, use mremap(...MREMAP_FIXED...) for huge realloc(). This is
204 * disabled by default because it is Linux-specific and it will cause virtual
205 * memory map holes, much like munmap(2) does.
207 /* #undef JEMALLOC_MREMAP */
209 /* TLS is used to map arenas and magazine caches to threads. */
213 * JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside
214 * within jemalloc-owned chunks before dereferencing them.
216 /* #undef JEMALLOC_IVSALLOC */
219 * Define overrides for non-standard allocator-related functions if they
220 * are present on the system.
222 /* #undef JEMALLOC_OVERRIDE_MEMALIGN */
223 #define JEMALLOC_OVERRIDE_VALLOC
226 * At least Linux omits the "const" in:
228 * size_t malloc_usable_size(const void *ptr);
230 * Match the operating system's prototype.
232 #define JEMALLOC_USABLE_SIZE_CONST const
235 * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
237 /* #undef JEMALLOC_ZONE */
238 /* #undef JEMALLOC_ZONE_VERSION */
241 * Methods for purging unused pages differ between operating systems.
243 * madvise(..., MADV_DONTNEED) : On Linux, this immediately discards pages,
244 * such that new pages will be demand-zeroed if
245 * the address region is later touched.
246 * madvise(..., MADV_FREE) : On FreeBSD and Darwin, this marks pages as being
247 * unused, such that they will be discarded rather
250 /* #undef JEMALLOC_PURGE_MADVISE_DONTNEED */
251 #define JEMALLOC_PURGE_MADVISE_FREE
254 * Define if operating system has alloca.h header.
256 /* #undef JEMALLOC_HAS_ALLOCA_H */
258 /* sizeof(void *) == 2^LG_SIZEOF_PTR. */
259 #define LG_SIZEOF_PTR 3
261 /* sizeof(int) == 2^LG_SIZEOF_INT. */
262 #define LG_SIZEOF_INT 2
264 /* sizeof(long) == 2^LG_SIZEOF_LONG. */
265 #define LG_SIZEOF_LONG 3
267 /* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
268 #define LG_SIZEOF_INTMAX_T 3