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