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