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 /* TODO: Fix compile issues with the atomics. */
     32 #undef JEMALLOC_C11ATOMICS
     33 
     34 /* Defined if the equivalent of FreeBSD's atomic(9) functions are available. */
     35 /* #undef JEMALLOC_ATOMIC9 */
     36 
     37 /*
     38  * Defined if OSAtomic*() functions are available, as provided by Darwin, and
     39  * documented in the atomic(3) manual page.
     40  */
     41 /* #undef JEMALLOC_OSATOMIC */
     42 
     43 /*
     44  * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and
     45  * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite
     46  * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the
     47  * functions are defined in libgcc instead of being inlines).
     48  */
     49 /* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4 */
     50 
     51 /*
     52  * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and
     53  * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite
     54  * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the
     55  * functions are defined in libgcc instead of being inlines).
     56  */
     57 /* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8 */
     58 
     59 /*
     60  * Defined if __builtin_clz() and __builtin_clzl() are available.
     61  */
     62 #define JEMALLOC_HAVE_BUILTIN_CLZ
     63 
     64 /*
     65  * Defined if madvise(2) is available.
     66  */
     67 #define JEMALLOC_HAVE_MADVISE
     68 
     69 /*
     70  * Defined if OSSpin*() functions are available, as provided by Darwin, and
     71  * documented in the spinlock(3) manual page.
     72  */
     73 /* #undef JEMALLOC_OSSPIN */
     74 
     75 /*
     76  * Defined if secure_getenv(3) is available.
     77  */
     78 /* #undef JEMALLOC_HAVE_SECURE_GETENV */
     79 
     80 /*
     81  * Defined if issetugid(2) is available.
     82  */
     83 /* #undef JEMALLOC_HAVE_ISSETUGID */
     84 
     85 /*
     86  * Defined if _malloc_thread_cleanup() exists.  At least in the case of
     87  * FreeBSD, pthread_key_create() allocates, which if used during malloc
     88  * bootstrapping will cause recursion into the pthreads library.  Therefore, if
     89  * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in
     90  * malloc_tsd.
     91  */
     92 /* #undef JEMALLOC_MALLOC_THREAD_CLEANUP */
     93 
     94 /*
     95  * Defined if threaded initialization is known to be safe on this platform.
     96  * Among other things, it must be possible to initialize a mutex without
     97  * triggering allocation in order for threaded allocation to be safe.
     98  */
     99 #define JEMALLOC_THREADED_INIT
    100 
    101 /*
    102  * Defined if the pthreads implementation defines
    103  * _pthread_mutex_init_calloc_cb(), in which case the function is used in order
    104  * to avoid recursive allocation during mutex initialization.
    105  */
    106 /* #undef JEMALLOC_MUTEX_INIT_CB */
    107 
    108 /* Non-empty if the tls_model attribute is supported. */
    109 #define JEMALLOC_TLS_MODEL
    110 
    111 /* JEMALLOC_CC_SILENCE enables code that silences unuseful compiler warnings. */
    112 #define JEMALLOC_CC_SILENCE
    113 
    114 /* JEMALLOC_CODE_COVERAGE enables test code coverage analysis. */
    115 /* #undef JEMALLOC_CODE_COVERAGE */
    116 
    117 /*
    118  * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
    119  * inline functions.
    120  */
    121 /* #undef JEMALLOC_DEBUG */
    122 
    123 /* JEMALLOC_STATS enables statistics calculation. */
    124 #define JEMALLOC_STATS
    125 
    126 /* JEMALLOC_PROF enables allocation profiling. */
    127 /* #undef JEMALLOC_PROF */
    128 
    129 /* Use libunwind for profile backtracing if defined. */
    130 /* #undef JEMALLOC_PROF_LIBUNWIND */
    131 
    132 /* Use libgcc for profile backtracing if defined. */
    133 /* #undef JEMALLOC_PROF_LIBGCC */
    134 
    135 /* Use gcc intrinsics for profile backtracing if defined. */
    136 /* #undef JEMALLOC_PROF_GCC */
    137 
    138 /*
    139  * JEMALLOC_TCACHE enables a thread-specific caching layer for small objects.
    140  * This makes it possible to allocate/deallocate objects without any locking
    141  * when the cache is in the steady state.
    142  */
    143 #define JEMALLOC_TCACHE
    144 
    145 /*
    146  * JEMALLOC_DSS enables use of sbrk(2) to allocate chunks from the data storage
    147  * segment (DSS).
    148  */
    149 #define JEMALLOC_DSS
    150 
    151 /* Support memory filling (junk/zero/quarantine/redzone). */
    152 #define JEMALLOC_FILL
    153 
    154 /* Support utrace(2)-based tracing. */
    155 /* #undef JEMALLOC_UTRACE */
    156 
    157 /* Support Valgrind. */
    158 /* #undef JEMALLOC_VALGRIND */
    159 
    160 /* Support optional abort() on OOM. */
    161 /* #undef JEMALLOC_XMALLOC */
    162 
    163 /* Support lazy locking (avoid locking unless a second thread is launched). */
    164 /* #undef JEMALLOC_LAZY_LOCK */
    165 
    166 /* Minimum size class to support is 2^LG_TINY_MIN bytes. */
    167 #define LG_TINY_MIN 3
    168 
    169 /*
    170  * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size
    171  * classes).
    172  */
    173 /* #undef LG_QUANTUM */
    174 
    175 /* One page is 2^LG_PAGE bytes. */
    176 #define LG_PAGE 12
    177 
    178 /*
    179  * If defined, use munmap() to unmap freed chunks, rather than storing them for
    180  * later reuse.  This is disabled by default on Linux because common sequences
    181  * of mmap()/munmap() calls will cause virtual memory map holes.
    182  */
    183 /* #undef JEMALLOC_MUNMAP */
    184 
    185 /* TLS is used to map arenas and magazine caches to threads. */
    186 /* #undef JEMALLOC_TLS */
    187 
    188 /*
    189  * ffs()/ffsl() functions to use for bitmapping.  Don't use these directly;
    190  * instead, use jemalloc_ffs() or jemalloc_ffsl() from util.h.
    191  */
    192 #define JEMALLOC_INTERNAL_FFSL __builtin_ffsl
    193 #define JEMALLOC_INTERNAL_FFS __builtin_ffs
    194 
    195 /*
    196  * JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside
    197  * within jemalloc-owned chunks before dereferencing them.
    198  */
    199 /* #undef JEMALLOC_IVSALLOC */
    200 
    201 /*
    202  * If defined, explicitly attempt to more uniformly distribute large allocation
    203  * pointer alignments across all cache indices.
    204  */
    205 /* #undef JEMALLOC_CACHE_OBLIVIOUS */
    206 
    207 /*
    208  * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
    209  */
    210 /* #undef JEMALLOC_ZONE */
    211 /* #undef JEMALLOC_ZONE_VERSION */
    212 
    213 /*
    214  * Methods for purging unused pages differ between operating systems.
    215  *
    216  *   madvise(..., MADV_DONTNEED) : On Linux, this immediately discards pages,
    217  *                                 such that new pages will be demand-zeroed if
    218  *                                 the address region is later touched.
    219  *   madvise(..., MADV_FREE) : On FreeBSD and Darwin, this marks pages as being
    220  *                             unused, such that they will be discarded rather
    221  *                             than swapped out.
    222  */
    223 #define JEMALLOC_PURGE_MADVISE_DONTNEED
    224 /* #undef JEMALLOC_PURGE_MADVISE_FREE */
    225 
    226 /* Define if operating system has alloca.h header. */
    227 #define JEMALLOC_HAS_ALLOCA_H 1
    228 
    229 /* C99 restrict keyword supported. */
    230 #define JEMALLOC_HAS_RESTRICT 1
    231 
    232 /* For use by hash code. */
    233 /* #undef JEMALLOC_BIG_ENDIAN */
    234 
    235 /* sizeof(int) == 2^LG_SIZEOF_INT. */
    236 #define LG_SIZEOF_INT 2
    237 
    238 /* sizeof(long) == 2^LG_SIZEOF_LONG. */
    239 #ifdef __LP64__
    240 #define LG_SIZEOF_LONG 3
    241 #else
    242 #define LG_SIZEOF_LONG 2
    243 #endif
    244 
    245 /* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
    246 #define LG_SIZEOF_INTMAX_T 3
    247 
    248 /* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */
    249 /* #undef JEMALLOC_GLIBC_MALLOC_HOOK */
    250 
    251 /* glibc memalign hook. */
    252 /* #undef JEMALLOC_GLIBC_MEMALIGN_HOOK */
    253 
    254 /* Adaptive mutex support in pthreads. */
    255 /* #undef JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
    256 
    257 /*
    258  * If defined, jemalloc symbols are not exported (doesn't work when
    259  * JEMALLOC_PREFIX is not defined).
    260  */
    261 #define JEMALLOC_EXPORT
    262 
    263 #endif /* JEMALLOC_INTERNAL_DEFS_H_ */
    264