1234370Sjasone/* include/jemalloc/jemalloc_defs.h. Generated from jemalloc_defs.h.in by configure. */ 2234370Sjasone/* 3234370Sjasone * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all 4234370Sjasone * public APIs to be prefixed. This makes it possible, with some care, to use 5234370Sjasone * multiple allocators simultaneously. 6234370Sjasone */ 7234370Sjasone/* #undef JEMALLOC_PREFIX */ 8234370Sjasone/* #undef JEMALLOC_CPREFIX */ 9234370Sjasone 10234370Sjasone/* 11234370Sjasone * Name mangling for public symbols is controlled by --with-mangling and 12234370Sjasone * --with-jemalloc-prefix. With default settings the je_ prefix is stripped by 13234370Sjasone * these macro definitions. 14234370Sjasone */ 15234370Sjasone#define je_malloc_conf malloc_conf 16234370Sjasone#define je_malloc_message malloc_message 17234370Sjasone#define je_malloc malloc 18234370Sjasone#define je_calloc calloc 19234370Sjasone#define je_posix_memalign posix_memalign 20234370Sjasone#define je_aligned_alloc aligned_alloc 21234370Sjasone#define je_realloc realloc 22234370Sjasone#define je_free free 23234370Sjasone#define je_malloc_usable_size malloc_usable_size 24234370Sjasone#define je_malloc_stats_print malloc_stats_print 25234370Sjasone#define je_mallctl mallctl 26234370Sjasone#define je_mallctlnametomib mallctlnametomib 27234370Sjasone#define je_mallctlbymib mallctlbymib 28234370Sjasone/* #undef je_memalign */ 29234370Sjasone#define je_valloc valloc 30234370Sjasone#define je_allocm allocm 31234370Sjasone#define je_rallocm rallocm 32234370Sjasone#define je_sallocm sallocm 33234370Sjasone#define je_dallocm dallocm 34234370Sjasone#define je_nallocm nallocm 35234370Sjasone 36234370Sjasone/* 37234370Sjasone * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs. 38234370Sjasone * For shared libraries, symbol visibility mechanisms prevent these symbols 39234370Sjasone * from being exported, but for static libraries, naming collisions are a real 40234370Sjasone * possibility. 41234370Sjasone */ 42234543Sjasone#define JEMALLOC_PRIVATE_NAMESPACE "__jemalloc_" 43234543Sjasone#define JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix) __jemalloc_##string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix 44234370Sjasone 45234370Sjasone/* 46234370Sjasone * Hyper-threaded CPUs may need a special instruction inside spin loops in 47234370Sjasone * order to yield to another virtual CPU. 48234370Sjasone */ 49234370Sjasone#define CPU_SPINWAIT __asm__ volatile("pause") 50234370Sjasone 51234402Sjasone/* Defined if the equivalent of FreeBSD's atomic(9) functions are available. */ 52234402Sjasone#define JEMALLOC_ATOMIC9 1 53234402Sjasone 54234370Sjasone/* 55234370Sjasone * Defined if OSAtomic*() functions are available, as provided by Darwin, and 56234370Sjasone * documented in the atomic(3) manual page. 57234370Sjasone */ 58234370Sjasone/* #undef JEMALLOC_OSATOMIC */ 59234370Sjasone 60234370Sjasone/* 61234370Sjasone * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and 62234370Sjasone * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite 63234370Sjasone * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the 64234370Sjasone * functions are defined in libgcc instead of being inlines) 65234370Sjasone */ 66234402Sjasone/* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4 */ 67234370Sjasone 68234370Sjasone/* 69234370Sjasone * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and 70234370Sjasone * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite 71234370Sjasone * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the 72234370Sjasone * functions are defined in libgcc instead of being inlines) 73234370Sjasone */ 74234402Sjasone/* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8 */ 75234370Sjasone 76234370Sjasone/* 77234370Sjasone * Defined if OSSpin*() functions are available, as provided by Darwin, and 78234370Sjasone * documented in the spinlock(3) manual page. 79234370Sjasone */ 80234370Sjasone/* #undef JEMALLOC_OSSPIN */ 81234370Sjasone 82234370Sjasone/* 83234370Sjasone * Defined if _malloc_thread_cleanup() exists. At least in the case of 84234370Sjasone * FreeBSD, pthread_key_create() allocates, which if used during malloc 85234370Sjasone * bootstrapping will cause recursion into the pthreads library. Therefore, if 86234370Sjasone * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in 87234370Sjasone * malloc_tsd. 88234370Sjasone */ 89234370Sjasone#define JEMALLOC_MALLOC_THREAD_CLEANUP 90234370Sjasone 91234370Sjasone/* 92234370Sjasone * Defined if threaded initialization is known to be safe on this platform. 93234370Sjasone * Among other things, it must be possible to initialize a mutex without 94234370Sjasone * triggering allocation in order for threaded allocation to be safe. 95234370Sjasone */ 96234370Sjasone/* #undef JEMALLOC_THREADED_INIT */ 97234370Sjasone 98234370Sjasone/* 99234370Sjasone * Defined if the pthreads implementation defines 100234370Sjasone * _pthread_mutex_init_calloc_cb(), in which case the function is used in order 101234370Sjasone * to avoid recursive allocation during mutex initialization. 102234370Sjasone */ 103234370Sjasone#define JEMALLOC_MUTEX_INIT_CB 1 104234370Sjasone 105234370Sjasone/* Defined if __attribute__((...)) syntax is supported. */ 106234370Sjasone#define JEMALLOC_HAVE_ATTR 107234370Sjasone#ifdef JEMALLOC_HAVE_ATTR 108235238Sjasone# define JEMALLOC_ATTR(s) __attribute__((s)) 109235238Sjasone# define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default")) 110235238Sjasone# define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s)) 111235238Sjasone# define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s)) 112235238Sjasone# define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline) 113235238Sjasone#elif _MSC_VER 114235238Sjasone# define JEMALLOC_ATTR(s) 115235238Sjasone# ifdef DLLEXPORT 116235238Sjasone# define JEMALLOC_EXPORT __declspec(dllexport) 117235238Sjasone# else 118235238Sjasone# define JEMALLOC_EXPORT __declspec(dllimport) 119235238Sjasone# endif 120235238Sjasone# define JEMALLOC_ALIGNED(s) __declspec(align(s)) 121235238Sjasone# define JEMALLOC_SECTION(s) __declspec(allocate(s)) 122235238Sjasone# define JEMALLOC_NOINLINE __declspec(noinline) 123234370Sjasone#else 124235238Sjasone# define JEMALLOC_ATTR(s) 125235238Sjasone# define JEMALLOC_EXPORT 126235238Sjasone# define JEMALLOC_ALIGNED(s) 127235238Sjasone# define JEMALLOC_SECTION(s) 128235238Sjasone# define JEMALLOC_NOINLINE 129234370Sjasone#endif 130234370Sjasone 131234370Sjasone/* Defined if sbrk() is supported. */ 132234370Sjasone#define JEMALLOC_HAVE_SBRK 133234370Sjasone 134234370Sjasone/* Non-empty if the tls_model attribute is supported. */ 135234370Sjasone#define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec"))) 136234370Sjasone 137234370Sjasone/* JEMALLOC_CC_SILENCE enables code that silences unuseful compiler warnings. */ 138234370Sjasone#define JEMALLOC_CC_SILENCE 139234370Sjasone 140234370Sjasone/* 141234370Sjasone * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables 142234370Sjasone * inline functions. 143234370Sjasone */ 144234370Sjasone/* #undef JEMALLOC_DEBUG */ 145234370Sjasone 146234370Sjasone/* JEMALLOC_STATS enables statistics calculation. */ 147234370Sjasone#define JEMALLOC_STATS 148234370Sjasone 149234370Sjasone/* JEMALLOC_PROF enables allocation profiling. */ 150234370Sjasone/* #undef JEMALLOC_PROF */ 151234370Sjasone 152234370Sjasone/* Use libunwind for profile backtracing if defined. */ 153234370Sjasone/* #undef JEMALLOC_PROF_LIBUNWIND */ 154234370Sjasone 155234370Sjasone/* Use libgcc for profile backtracing if defined. */ 156234370Sjasone/* #undef JEMALLOC_PROF_LIBGCC */ 157234370Sjasone 158234370Sjasone/* Use gcc intrinsics for profile backtracing if defined. */ 159234370Sjasone/* #undef JEMALLOC_PROF_GCC */ 160234370Sjasone 161234370Sjasone/* 162234370Sjasone * JEMALLOC_TCACHE enables a thread-specific caching layer for small objects. 163234370Sjasone * This makes it possible to allocate/deallocate objects without any locking 164234370Sjasone * when the cache is in the steady state. 165234370Sjasone */ 166234370Sjasone#define JEMALLOC_TCACHE 167234370Sjasone 168234370Sjasone/* 169234370Sjasone * JEMALLOC_DSS enables use of sbrk(2) to allocate chunks from the data storage 170234370Sjasone * segment (DSS). 171234370Sjasone */ 172234370Sjasone#define JEMALLOC_DSS 173234370Sjasone 174234370Sjasone/* Support memory filling (junk/zero/quarantine/redzone). */ 175234370Sjasone#define JEMALLOC_FILL 176234370Sjasone 177234370Sjasone/* Support the experimental API. */ 178234370Sjasone#define JEMALLOC_EXPERIMENTAL 179234370Sjasone 180234370Sjasone/* Support utrace(2)-based tracing. */ 181234370Sjasone#define JEMALLOC_UTRACE 182234370Sjasone 183234370Sjasone/* Support Valgrind. */ 184234370Sjasone/* #undef JEMALLOC_VALGRIND */ 185234370Sjasone 186234370Sjasone/* Support optional abort() on OOM. */ 187234370Sjasone#define JEMALLOC_XMALLOC 188234370Sjasone 189234370Sjasone/* Support lazy locking (avoid locking unless a second thread is launched). */ 190234370Sjasone#define JEMALLOC_LAZY_LOCK 191234370Sjasone 192234370Sjasone/* One page is 2^STATIC_PAGE_SHIFT bytes. */ 193234370Sjasone#define STATIC_PAGE_SHIFT 12 194234370Sjasone 195234370Sjasone/* 196234370Sjasone * If defined, use munmap() to unmap freed chunks, rather than storing them for 197235238Sjasone * later reuse. This is disabled by default on Linux because common sequences 198235238Sjasone * of mmap()/munmap() calls will cause virtual memory map holes. 199234370Sjasone */ 200234370Sjasone#define JEMALLOC_MUNMAP 201234370Sjasone 202235238Sjasone/* 203235238Sjasone * If defined, use mremap(...MREMAP_FIXED...) for huge realloc(). This is 204235238Sjasone * disabled by default because it is Linux-specific and it will cause virtual 205235238Sjasone * memory map holes, much like munmap(2) does. 206235238Sjasone */ 207235238Sjasone/* #undef JEMALLOC_MREMAP */ 208235238Sjasone 209234370Sjasone/* TLS is used to map arenas and magazine caches to threads. */ 210234370Sjasone#define JEMALLOC_TLS 211234370Sjasone 212234370Sjasone/* 213234370Sjasone * JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside 214234370Sjasone * within jemalloc-owned chunks before dereferencing them. 215234370Sjasone */ 216234370Sjasone/* #undef JEMALLOC_IVSALLOC */ 217234370Sjasone 218234370Sjasone/* 219234370Sjasone * Define overrides for non-standard allocator-related functions if they 220234370Sjasone * are present on the system. 221234370Sjasone */ 222234370Sjasone/* #undef JEMALLOC_OVERRIDE_MEMALIGN */ 223234370Sjasone#define JEMALLOC_OVERRIDE_VALLOC 224234370Sjasone 225234370Sjasone/* 226242844Sjasone * At least Linux omits the "const" in: 227242844Sjasone * 228242844Sjasone * size_t malloc_usable_size(const void *ptr); 229242844Sjasone * 230242844Sjasone * Match the operating system's prototype. 231242844Sjasone */ 232242844Sjasone#define JEMALLOC_USABLE_SIZE_CONST const 233242844Sjasone 234242844Sjasone/* 235234370Sjasone * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings. 236234370Sjasone */ 237234370Sjasone/* #undef JEMALLOC_ZONE */ 238234370Sjasone/* #undef JEMALLOC_ZONE_VERSION */ 239234370Sjasone 240234370Sjasone/* 241234370Sjasone * Methods for purging unused pages differ between operating systems. 242234370Sjasone * 243234370Sjasone * madvise(..., MADV_DONTNEED) : On Linux, this immediately discards pages, 244234370Sjasone * such that new pages will be demand-zeroed if 245234370Sjasone * the address region is later touched. 246234370Sjasone * madvise(..., MADV_FREE) : On FreeBSD and Darwin, this marks pages as being 247234370Sjasone * unused, such that they will be discarded rather 248234370Sjasone * than swapped out. 249234370Sjasone */ 250234370Sjasone/* #undef JEMALLOC_PURGE_MADVISE_DONTNEED */ 251234370Sjasone#define JEMALLOC_PURGE_MADVISE_FREE 252234370Sjasone 253245868Sjasone/* 254245868Sjasone * Define if operating system has alloca.h header. 255245868Sjasone */ 256245868Sjasone/* #undef JEMALLOC_HAS_ALLOCA_H */ 257245868Sjasone 258234370Sjasone/* sizeof(void *) == 2^LG_SIZEOF_PTR. */ 259234370Sjasone#define LG_SIZEOF_PTR 3 260234370Sjasone 261234370Sjasone/* sizeof(int) == 2^LG_SIZEOF_INT. */ 262234370Sjasone#define LG_SIZEOF_INT 2 263234370Sjasone 264234370Sjasone/* sizeof(long) == 2^LG_SIZEOF_LONG. */ 265234370Sjasone#define LG_SIZEOF_LONG 3 266234370Sjasone 267234370Sjasone/* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */ 268234370Sjasone#define LG_SIZEOF_INTMAX_T 3 269