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 #define 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 #define CPU_SPINWAIT __asm__ volatile("pause") 37 /* 1 if CPU_SPINWAIT is defined, 0 otherwise. */ 38 #define HAVE_CPU_SPINWAIT 1 39 40 /* 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. 44 */ 45 #define LG_VADDR 48 46 47 /* Defined if C11 atomics are available. */ 48 #define JEMALLOC_C11_ATOMICS 49 50 /* Defined if GCC __atomic atomics are available. */ 51 #define JEMALLOC_GCC_ATOMIC_ATOMICS 52 /* and the 8-bit variant support. */ 53 #define JEMALLOC_GCC_U8_ATOMIC_ATOMICS 54 55 /* Defined if GCC __sync atomics are available. */ 56 #define JEMALLOC_GCC_SYNC_ATOMICS 57 /* and the 8-bit variant support. */ 58 #define JEMALLOC_GCC_U8_SYNC_ATOMICS 59 60 /* 61 * Defined if __builtin_clz() and __builtin_clzl() are available. 62 */ 63 #define JEMALLOC_HAVE_BUILTIN_CLZ 64 65 /* 66 * Defined if os_unfair_lock_*() functions are available, as provided by Darwin. 67 */ 68 /* #undef JEMALLOC_OS_UNFAIR_LOCK */ 69 70 /* Defined if syscall(2) is usable. */ 71 #define JEMALLOC_USE_SYSCALL 72 73 /* 74 * Defined if secure_getenv(3) is available. 75 */ 76 #define JEMALLOC_HAVE_SECURE_GETENV 77 78 /* 79 * Defined if issetugid(2) is available. 80 */ 81 #define JEMALLOC_HAVE_ISSETUGID 82 83 /* Defined if pthread_atfork(3) is available. */ 84 #define JEMALLOC_HAVE_PTHREAD_ATFORK 85 86 /* Defined if pthread_setname_np(3) is available. */ 87 #define JEMALLOC_HAVE_PTHREAD_SETNAME_NP 88 89 /* Defined if pthread_getname_np(3) is available. */ 90 #define JEMALLOC_HAVE_PTHREAD_GETNAME_NP 91 92 /* Defined if pthread_get_name_np(3) is available. */ 93 #define JEMALLOC_HAVE_PTHREAD_GET_NAME_NP 94 95 /* 96 * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available. 97 */ 98 #define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE 99 100 /* 101 * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available. 102 */ 103 #define JEMALLOC_HAVE_CLOCK_MONOTONIC 104 105 /* 106 * Defined if mach_absolute_time() is available. 107 */ 108 /* #undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME */ 109 110 /* 111 * Defined if clock_gettime(CLOCK_REALTIME, ...) is available. 112 */ 113 #define JEMALLOC_HAVE_CLOCK_REALTIME 114 115 /* 116 * Defined if _malloc_thread_cleanup() exists. At least in the case of 117 * FreeBSD, pthread_key_create() allocates, which if used during malloc 118 * bootstrapping will cause recursion into the pthreads library. Therefore, if 119 * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in 120 * malloc_tsd. 121 */ 122 #define JEMALLOC_MALLOC_THREAD_CLEANUP 123 124 /* 125 * Defined if threaded initialization is known to be safe on this platform. 126 * Among other things, it must be possible to initialize a mutex without 127 * triggering allocation in order for threaded allocation to be safe. 128 */ 129 /* #undef JEMALLOC_THREADED_INIT */ 130 131 /* 132 * Defined if the pthreads implementation defines 133 * _pthread_mutex_init_calloc_cb(), in which case the function is used in order 134 * to avoid recursive allocation during mutex initialization. 135 */ 136 #define JEMALLOC_MUTEX_INIT_CB 137 138 /* Non-empty if the tls_model attribute is supported. */ 139 #define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec"))) 140 141 /* 142 * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables 143 * inline functions. 144 */ 145 /* #undef JEMALLOC_DEBUG */ 146 147 /* JEMALLOC_STATS enables statistics calculation. */ 148 #define JEMALLOC_STATS 149 150 /* JEMALLOC_EXPERIMENTAL_SMALLOCX_API enables experimental smallocx API. */ 151 /* #undef JEMALLOC_EXPERIMENTAL_SMALLOCX_API */ 152 153 /* JEMALLOC_PROF enables allocation profiling. */ 154 /* #undef JEMALLOC_PROF */ 155 156 /* Use libunwind for profile backtracing if defined. */ 157 /* #undef JEMALLOC_PROF_LIBUNWIND */ 158 159 /* Use libgcc for profile backtracing if defined. */ 160 /* #undef JEMALLOC_PROF_LIBGCC */ 161 162 /* Use gcc intrinsics for profile backtracing if defined. */ 163 /* #undef JEMALLOC_PROF_GCC */ 164 165 /* 166 * JEMALLOC_DSS enables use of sbrk(2) to allocate extents from the data storage 167 * segment (DSS). 168 */ 169 #define JEMALLOC_DSS 170 171 /* Support memory filling (junk/zero). */ 172 #define JEMALLOC_FILL 173 174 /* Support utrace(2)-based tracing. */ 175 #define JEMALLOC_UTRACE 176 177 /* Support utrace(2)-based tracing (label based signature). */ 178 /* #undef JEMALLOC_UTRACE_LABEL */ 179 180 /* Support optional abort() on OOM. */ 181 #define JEMALLOC_XMALLOC 182 183 /* Support lazy locking (avoid locking unless a second thread is launched). */ 184 #define JEMALLOC_LAZY_LOCK 185 186 /* 187 * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size 188 * classes). 189 */ 190 /* #undef LG_QUANTUM */ 191 192 /* One page is 2^LG_PAGE bytes. */ 193 #define LG_PAGE 12 194 195 /* Maximum number of regions in a slab. */ 196 /* #undef CONFIG_LG_SLAB_MAXREGS */ 197 198 /* 199 * One huge page is 2^LG_HUGEPAGE bytes. Note that this is defined even if the 200 * system does not explicitly support huge pages; system calls that require 201 * explicit huge page support are separately configured. 202 */ 203 #define LG_HUGEPAGE 21 204 205 /* 206 * If defined, adjacent virtual memory mappings with identical attributes 207 * automatically coalesce, and they fragment when changes are made to subranges. 208 * This is the normal order of things for mmap()/munmap(), but on Windows 209 * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e. 210 * mappings do *not* coalesce/fragment. 211 */ 212 #define JEMALLOC_MAPS_COALESCE 213 214 /* 215 * If defined, retain memory for later reuse by default rather than using e.g. 216 * munmap() to unmap freed extents. This is enabled on 64-bit Linux because 217 * common sequences of mmap()/munmap() calls will cause virtual memory map 218 * holes. 219 */ 220 /* #undef JEMALLOC_RETAIN */ 221 222 /* TLS is used to map arenas and magazine caches to threads. */ 223 #define JEMALLOC_TLS 224 225 /* 226 * Used to mark unreachable code to quiet "end of non-void" compiler warnings. 227 * Don't use this directly; instead use unreachable() from util.h 228 */ 229 #define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable 230 231 /* 232 * ffs*() functions to use for bitmapping. Don't use these directly; instead, 233 * use ffs_*() from util.h. 234 */ 235 #define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll 236 #define JEMALLOC_INTERNAL_FFSL __builtin_ffsl 237 #define JEMALLOC_INTERNAL_FFS __builtin_ffs 238 239 /* 240 * popcount*() functions to use for bitmapping. 241 */ 242 #define JEMALLOC_INTERNAL_POPCOUNTL __builtin_popcountl 243 #define JEMALLOC_INTERNAL_POPCOUNT __builtin_popcount 244 245 /* 246 * If defined, explicitly attempt to more uniformly distribute large allocation 247 * pointer alignments across all cache indices. 248 */ 249 #define JEMALLOC_CACHE_OBLIVIOUS 250 251 /* 252 * If defined, enable logging facilities. We make this a configure option to 253 * avoid taking extra branches everywhere. 254 */ 255 /* #undef JEMALLOC_LOG */ 256 257 /* 258 * If defined, use readlinkat() (instead of readlink()) to follow 259 * /etc/malloc_conf. 260 */ 261 /* #undef JEMALLOC_READLINKAT */ 262 263 /* 264 * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings. 265 */ 266 /* #undef JEMALLOC_ZONE */ 267 268 /* 269 * Methods for determining whether the OS overcommits. 270 * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's 271 * /proc/sys/vm.overcommit_memory file. 272 * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl. 273 */ 274 #define JEMALLOC_SYSCTL_VM_OVERCOMMIT 275 /* #undef JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY */ 276 277 /* Defined if madvise(2) is available. */ 278 #define JEMALLOC_HAVE_MADVISE 279 280 /* 281 * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE 282 * arguments to madvise(2). 283 */ 284 /* #undef JEMALLOC_HAVE_MADVISE_HUGE */ 285 286 /* 287 * Methods for purging unused pages differ between operating systems. 288 * 289 * madvise(..., MADV_FREE) : This marks pages as being unused, such that they 290 * will be discarded rather than swapped out. 291 * madvise(..., MADV_DONTNEED) : If JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS is 292 * defined, this immediately discards pages, 293 * such that new pages will be demand-zeroed if 294 * the address region is later touched; 295 * otherwise this behaves similarly to 296 * MADV_FREE, though typically with higher 297 * system overhead. 298 */ 299 #define JEMALLOC_PURGE_MADVISE_FREE 300 #define JEMALLOC_PURGE_MADVISE_DONTNEED 301 /* #undef JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS */ 302 303 /* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */ 304 /* #undef JEMALLOC_DEFINE_MADVISE_FREE */ 305 306 /* 307 * Defined if MADV_DO[NT]DUMP is supported as an argument to madvise. 308 */ 309 /* #undef JEMALLOC_MADVISE_DONTDUMP */ 310 311 /* 312 * Defined if MADV_[NO]CORE is supported as an argument to madvise. 313 */ 314 #define JEMALLOC_MADVISE_NOCORE 315 316 /* Defined if mprotect(2) is available. */ 317 #define JEMALLOC_HAVE_MPROTECT 318 319 /* 320 * Defined if transparent huge pages (THPs) are supported via the 321 * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled. 322 */ 323 /* #undef JEMALLOC_THP */ 324 325 /* Defined if posix_madvise is available. */ 326 /* #undef JEMALLOC_HAVE_POSIX_MADVISE */ 327 328 /* 329 * Method for purging unused pages using posix_madvise. 330 * 331 * posix_madvise(..., POSIX_MADV_DONTNEED) 332 */ 333 /* #undef JEMALLOC_PURGE_POSIX_MADVISE_DONTNEED */ 334 /* #undef JEMALLOC_PURGE_POSIX_MADVISE_DONTNEED_ZEROS */ 335 336 /* 337 * Defined if memcntl page admin call is supported 338 */ 339 /* #undef JEMALLOC_HAVE_MEMCNTL */ 340 341 /* 342 * Defined if malloc_size is supported 343 */ 344 /* #undef JEMALLOC_HAVE_MALLOC_SIZE */ 345 346 /* Define if operating system has alloca.h header. */ 347 /* #undef JEMALLOC_HAS_ALLOCA_H */ 348 349 /* C99 restrict keyword supported. */ 350 #define JEMALLOC_HAS_RESTRICT 351 352 /* For use by hash code. */ 353 /* #undef JEMALLOC_BIG_ENDIAN */ 354 355 /* sizeof(int) == 2^LG_SIZEOF_INT. */ 356 #define LG_SIZEOF_INT 2 357 358 /* sizeof(long) == 2^LG_SIZEOF_LONG. */ 359 #define LG_SIZEOF_LONG 3 360 361 /* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */ 362 #define LG_SIZEOF_LONG_LONG 3 363 364 /* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */ 365 #define LG_SIZEOF_INTMAX_T 3 366 367 /* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */ 368 /* #undef JEMALLOC_GLIBC_MALLOC_HOOK */ 369 370 /* glibc memalign hook. */ 371 /* #undef JEMALLOC_GLIBC_MEMALIGN_HOOK */ 372 373 /* pthread support */ 374 #define JEMALLOC_HAVE_PTHREAD 375 376 /* dlsym() support */ 377 #define JEMALLOC_HAVE_DLSYM 378 379 /* Adaptive mutex support in pthreads. */ 380 #define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP 381 382 /* GNU specific sched_getcpu support */ 383 #define JEMALLOC_HAVE_SCHED_GETCPU 384 385 /* GNU specific sched_setaffinity support */ 386 #define JEMALLOC_HAVE_SCHED_SETAFFINITY 387 388 /* 389 * If defined, all the features necessary for background threads are present. 390 */ 391 #define JEMALLOC_BACKGROUND_THREAD 392 393 /* 394 * If defined, jemalloc symbols are not exported (doesn't work when 395 * JEMALLOC_PREFIX is not defined). 396 */ 397 /* #undef JEMALLOC_EXPORT */ 398 399 /* config.malloc_conf options string. */ 400 #define JEMALLOC_CONFIG_MALLOC_CONF "abort_conf:false" 401 402 /* If defined, jemalloc takes the malloc/free/etc. symbol names. */ 403 #define JEMALLOC_IS_MALLOC 404 405 /* 406 * Defined if strerror_r returns char * if _GNU_SOURCE is defined. 407 */ 408 /* #undef JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE */ 409 410 /* Performs additional safety checks when defined. */ 411 /* #undef JEMALLOC_OPT_SAFETY_CHECKS */ 412 413 /* Is C++ support being built? */ 414 #define JEMALLOC_ENABLE_CXX 415 416 /* Performs additional size checks when defined. */ 417 /* #undef JEMALLOC_OPT_SIZE_CHECKS */ 418 419 /* Allows sampled junk and stash for checking use-after-free when defined. */ 420 /* #undef JEMALLOC_UAF_DETECTION */ 421 422 /* Darwin VM_MAKE_TAG support */ 423 /* #undef JEMALLOC_HAVE_VM_MAKE_TAG */ 424 425 /* If defined, realloc(ptr, 0) defaults to "free" instead of "alloc". */ 426 /* #undef JEMALLOC_ZERO_REALLOC_DEFAULT_FREE */ 427 428 #endif /* JEMALLOC_INTERNAL_DEFS_H_ */ 429