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