Home | History | Annotate | Download | only in internal
      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 #define JEMALLOC_PREFIX "je_"
     10 #define JEMALLOC_CPREFIX "JE_"
     11 
     12 /*
     13  * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
     14  * For shared libraries, symbol visibility mechanisms prevent these symbols
     15  * from being exported, but for static libraries, naming collisions are a real
     16  * possibility.
     17  */
     18 #define JEMALLOC_PRIVATE_NAMESPACE je_
     19 
     20 /*
     21  * Hyper-threaded CPUs may need a special instruction inside spin loops in
     22  * order to yield to another virtual CPU.
     23  */
     24 #ifdef __x86_64__
     25 #define CPU_SPINWAIT __asm__ volatile("pause")
     26 #else
     27 #define CPU_SPINWAIT
     28 #endif
     29 
     30 /* Defined if C11 atomics are available. */
     31 #define JEMALLOC_C11ATOMICS 1
     32 
     33 /* Defined if the equivalent of FreeBSD's atomic(9) functions are available. */
     34 /* #undef JEMALLOC_ATOMIC9 */
     35 
     36 /*
     37  * Defined if OSAtomic*() functions are available, as provided by Darwin, and
     38  * documented in the atomic(3) manual page.
     39  */
     40 /* #undef JEMALLOC_OSATOMIC */
     41 
     42 /*
     43  * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and
     44  * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite
     45  * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the
     46  * functions are defined in libgcc instead of being inlines).
     47  */
     48 /* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4 */
     49 
     50 /*
     51  * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and
     52  * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite
     53  * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the
     54  * functions are defined in libgcc instead of being inlines).
     55  */
     56 /* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8 */
     57 
     58 /*
     59  * Defined if __builtin_clz() and __builtin_clzl() are available.
     60  */
     61 #define JEMALLOC_HAVE_BUILTIN_CLZ
     62 
     63 /*
     64  * Defined if os_unfair_lock_*() functions are available, as provided by Darwin.
     65  */
     66 /* #undef JEMALLOC_OS_UNFAIR_LOCK */
     67 
     68 /*
     69  * Defined if OSSpin*() functions are available, as provided by Darwin, and
     70  * documented in the spinlock(3) manual page.
     71  */
     72 /* #undef JEMALLOC_OSSPIN */
     73 
     74 /* Defined if syscall(2) is usable. */
     75 /* Syscalls are available in Android, but avoid them for security reasons. */
     76 /* #undef JEMALLOC_USE_SYSCALL */
     77 
     78 /*
     79  * Defined if secure_getenv(3) is available.
     80  */
     81 /* #undef JEMALLOC_HAVE_SECURE_GETENV */
     82 
     83 /*
     84  * Defined if issetugid(2) is available.
     85  */
     86 /* #undef JEMALLOC_HAVE_ISSETUGID */
     87 
     88 /* Defined if pthread_atfork(3) is available. */
     89 #define JEMALLOC_HAVE_PTHREAD_ATFORK
     90 
     91 /*
     92  * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available.
     93  */
     94 #define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE 1
     95 
     96 /*
     97  * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available.
     98  */
     99 #define JEMALLOC_HAVE_CLOCK_MONOTONIC 1
    100 
    101 /*
    102  * Defined if mach_absolute_time() is available.
    103  */
    104 /* #undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME */
    105 
    106 /*
    107  * Defined if _malloc_thread_cleanup() exists.  At least in the case of
    108  * FreeBSD, pthread_key_create() allocates, which if used during malloc
    109  * bootstrapping will cause recursion into the pthreads library.  Therefore, if
    110  * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in
    111  * malloc_tsd.
    112  */
    113 /* #undef JEMALLOC_MALLOC_THREAD_CLEANUP */
    114 
    115 /*
    116  * Defined if threaded initialization is known to be safe on this platform.
    117  * Among other things, it must be possible to initialize a mutex without
    118  * triggering allocation in order for threaded allocation to be safe.
    119  */
    120 #define JEMALLOC_THREADED_INIT
    121 
    122 /*
    123  * Defined if the pthreads implementation defines
    124  * _pthread_mutex_init_calloc_cb(), in which case the function is used in order
    125  * to avoid recursive allocation during mutex initialization.
    126  */
    127 /* #undef JEMALLOC_MUTEX_INIT_CB */
    128 
    129 /* Non-empty if the tls_model attribute is supported. */
    130 #define JEMALLOC_TLS_MODEL
    131 
    132 /* JEMALLOC_CC_SILENCE enables code that silences unuseful compiler warnings. */
    133 #define JEMALLOC_CC_SILENCE
    134 
    135 /* JEMALLOC_CODE_COVERAGE enables test code coverage analysis. */
    136 /* #undef JEMALLOC_CODE_COVERAGE */
    137 
    138 /*
    139  * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
    140  * inline functions.
    141  */
    142 /* #undef JEMALLOC_DEBUG */
    143 
    144 /* JEMALLOC_STATS enables statistics calculation. */
    145 #define JEMALLOC_STATS
    146 
    147 /* JEMALLOC_PROF enables allocation profiling. */
    148 /* #undef JEMALLOC_PROF */
    149 
    150 /* Use libunwind for profile backtracing if defined. */
    151 /* #undef JEMALLOC_PROF_LIBUNWIND */
    152 
    153 /* Use libgcc for profile backtracing if defined. */
    154 /* #undef JEMALLOC_PROF_LIBGCC */
    155 
    156 /* Use gcc intrinsics for profile backtracing if defined. */
    157 /* #undef JEMALLOC_PROF_GCC */
    158 
    159 /*
    160  * JEMALLOC_TCACHE enables a thread-specific caching layer for small objects.
    161  * This makes it possible to allocate/deallocate objects without any locking
    162  * when the cache is in the steady state.
    163  */
    164 /* ANDROID: The tcache is enabled/disabled in the Makefile, not here. */
    165 /* #undef JEMALLOC_TCACHE */
    166 
    167 /*
    168  * JEMALLOC_DSS enables use of sbrk(2) to allocate chunks from the data storage
    169  * segment (DSS).
    170  */
    171 /* #undef JEMALLOC_DSS */
    172 
    173 /* Support memory filling (junk/zero/quarantine/redzone). */
    174 #define JEMALLOC_FILL
    175 
    176 /* Support utrace(2)-based tracing. */
    177 /* #undef JEMALLOC_UTRACE */
    178 
    179 /* Support Valgrind. */
    180 /* #undef JEMALLOC_VALGRIND */
    181 
    182 /* Support optional abort() on OOM. */
    183 /* #undef JEMALLOC_XMALLOC */
    184 
    185 /* Support lazy locking (avoid locking unless a second thread is launched). */
    186 /* #undef JEMALLOC_LAZY_LOCK */
    187 
    188 /* Minimum size class to support is 2^LG_TINY_MIN bytes. */
    189 #define LG_TINY_MIN 3
    190 
    191 /*
    192  * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size
    193  * classes).
    194  */
    195 /* #undef LG_QUANTUM */
    196 
    197 /* One page is 2^LG_PAGE bytes. */
    198 #define LG_PAGE 12
    199 
    200 /*
    201  * If defined, adjacent virtual memory mappings with identical attributes
    202  * automatically coalesce, and they fragment when changes are made to subranges.
    203  * This is the normal order of things for mmap()/munmap(), but on Windows
    204  * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e.
    205  * mappings do *not* coalesce/fragment.
    206  */
    207 #define JEMALLOC_MAPS_COALESCE
    208 
    209 /*
    210  * If defined, use munmap() to unmap freed chunks, rather than storing them for
    211  * later reuse.  This is disabled by default on Linux because common sequences
    212  * of mmap()/munmap() calls will cause virtual memory map holes.
    213  */
    214 /* #undef JEMALLOC_MUNMAP */
    215 
    216 /* TLS is used to map arenas and magazine caches to threads. */
    217 /* #undef JEMALLOC_TLS */
    218 
    219 /*
    220  * Used to mark unreachable code to quiet "end of non-void" compiler warnings.
    221  * Don't use this directly; instead use unreachable() from util.h
    222  */
    223 #define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable
    224 
    225 /*
    226  * ffs*() functions to use for bitmapping.  Don't use these directly; instead,
    227  * use ffs_*() from util.h.
    228  */
    229 #define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll
    230 #define JEMALLOC_INTERNAL_FFSL __builtin_ffsl
    231 #define JEMALLOC_INTERNAL_FFS __builtin_ffs
    232 
    233 /*
    234  * JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside
    235  * within jemalloc-owned chunks before dereferencing them.
    236  */
    237 /* #undef JEMALLOC_IVSALLOC */
    238 
    239 /*
    240  * If defined, explicitly attempt to more uniformly distribute large allocation
    241  * pointer alignments across all cache indices.
    242  */
    243 #define JEMALLOC_CACHE_OBLIVIOUS
    244 
    245 /*
    246  * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
    247  */
    248 /* #undef JEMALLOC_ZONE */
    249 /* #undef JEMALLOC_ZONE_VERSION */
    250 
    251 /*
    252  * Methods for determining whether the OS overcommits.
    253  * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's
    254  *                                         /proc/sys/vm.overcommit_memory file.
    255  * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl.
    256  */
    257 /* #undef JEMALLOC_SYSCTL_VM_OVERCOMMIT */
    258 #define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY
    259 
    260 /* Defined if madvise(2) is available. */
    261 #define JEMALLOC_HAVE_MADVISE
    262 
    263 /*
    264  * Methods for purging unused pages differ between operating systems.
    265  *
    266  *   madvise(..., MADV_FREE) : This marks pages as being unused, such that they
    267  *                             will be discarded rather than swapped out.
    268  *   madvise(..., MADV_DONTNEED) : This immediately discards pages, such that
    269  *                                 new pages will be demand-zeroed if the
    270  *                                 address region is later touched.
    271  */
    272 /* #undef JEMALLOC_PURGE_MADVISE_FREE */
    273 #define JEMALLOC_PURGE_MADVISE_DONTNEED
    274 
    275 /*
    276  * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE
    277  * arguments to madvise(2).
    278  */
    279 /* ANDROID: Do not enable huge pages because it can increase PSS. */
    280 /* #undef JEMALLOC_THP */
    281 
    282 /* Define if operating system has alloca.h header. */
    283 #define JEMALLOC_HAS_ALLOCA_H 1
    284 
    285 /* C99 restrict keyword supported. */
    286 #define JEMALLOC_HAS_RESTRICT 1
    287 
    288 /* For use by hash code. */
    289 /* #undef JEMALLOC_BIG_ENDIAN */
    290 
    291 /* sizeof(int) == 2^LG_SIZEOF_INT. */
    292 #define LG_SIZEOF_INT 2
    293 
    294 /* sizeof(long) == 2^LG_SIZEOF_LONG. */
    295 #ifdef __LP64__
    296 #define LG_SIZEOF_LONG 3
    297 #else
    298 #define LG_SIZEOF_LONG 2
    299 #endif
    300 
    301 /* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */
    302 #define LG_SIZEOF_LONG_LONG 3
    303 
    304 /* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
    305 #define LG_SIZEOF_INTMAX_T 3
    306 
    307 /* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */
    308 /* #undef JEMALLOC_GLIBC_MALLOC_HOOK */
    309 
    310 /* glibc memalign hook. */
    311 /* #undef JEMALLOC_GLIBC_MEMALIGN_HOOK */
    312 
    313 /* Adaptive mutex support in pthreads. */
    314 /* #undef JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
    315 
    316 /*
    317  * If defined, jemalloc symbols are not exported (doesn't work when
    318  * JEMALLOC_PREFIX is not defined).
    319  */
    320 #define JEMALLOC_EXPORT
    321 
    322 /* config.malloc_conf options string. */
    323 #define JEMALLOC_CONFIG_MALLOC_CONF ""
    324 
    325 #endif /* JEMALLOC_INTERNAL_DEFS_H_ */
    326