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