Jason Evans | 0f4f1ef | 2013-12-12 14:41:02 -0800 | [diff] [blame] | 1 | #ifndef JEMALLOC_INTERNAL_DEFS_H_ |
| 2 | #define JEMALLOC_INTERNAL_DEFS_H_ |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 3 | /* |
| 4 | * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all |
| 5 | * public APIs to be prefixed. This makes it possible, with some care, to use |
| 6 | * multiple allocators simultaneously. |
| 7 | */ |
| 8 | #undef JEMALLOC_PREFIX |
| 9 | #undef JEMALLOC_CPREFIX |
| 10 | |
| 11 | /* |
| 12 | * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs. |
| 13 | * For shared libraries, symbol visibility mechanisms prevent these symbols |
| 14 | * from being exported, but for static libraries, naming collisions are a real |
| 15 | * possibility. |
| 16 | */ |
| 17 | #undef JEMALLOC_PRIVATE_NAMESPACE |
| 18 | |
| 19 | /* |
| 20 | * Hyper-threaded CPUs may need a special instruction inside spin loops in |
| 21 | * order to yield to another virtual CPU. |
| 22 | */ |
| 23 | #undef CPU_SPINWAIT |
| 24 | |
Chih-hung Hsieh | 59cd80e | 2014-12-05 17:42:41 -0800 | [diff] [blame] | 25 | /* Defined if C11 atomics are available. */ |
| 26 | #undef JEMALLOC_C11ATOMICS |
| 27 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 28 | /* Defined if the equivalent of FreeBSD's atomic(9) functions are available. */ |
| 29 | #undef JEMALLOC_ATOMIC9 |
| 30 | |
| 31 | /* |
| 32 | * Defined if OSAtomic*() functions are available, as provided by Darwin, and |
| 33 | * documented in the atomic(3) manual page. |
| 34 | */ |
| 35 | #undef JEMALLOC_OSATOMIC |
| 36 | |
| 37 | /* |
| 38 | * Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and |
| 39 | * __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite |
| 40 | * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the |
Jason Evans | e12eaf9 | 2014-12-08 14:40:14 -0800 | [diff] [blame^] | 41 | * functions are defined in libgcc instead of being inlines). |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 42 | */ |
| 43 | #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4 |
| 44 | |
| 45 | /* |
| 46 | * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and |
| 47 | * __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite |
| 48 | * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the |
Jason Evans | e12eaf9 | 2014-12-08 14:40:14 -0800 | [diff] [blame^] | 49 | * functions are defined in libgcc instead of being inlines). |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 50 | */ |
| 51 | #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8 |
| 52 | |
| 53 | /* |
Jason Evans | d04047c | 2014-05-28 16:11:55 -0700 | [diff] [blame] | 54 | * Defined if __builtin_clz() and __builtin_clzl() are available. |
| 55 | */ |
| 56 | #undef JEMALLOC_HAVE_BUILTIN_CLZ |
| 57 | |
| 58 | /* |
Richard Diamond | 994fad9 | 2014-06-03 02:39:18 -0500 | [diff] [blame] | 59 | * Defined if madvise(2) is available. |
| 60 | */ |
| 61 | #undef JEMALLOC_HAVE_MADVISE |
| 62 | |
| 63 | /* |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 64 | * Defined if OSSpin*() functions are available, as provided by Darwin, and |
| 65 | * documented in the spinlock(3) manual page. |
| 66 | */ |
| 67 | #undef JEMALLOC_OSSPIN |
| 68 | |
| 69 | /* |
| 70 | * Defined if _malloc_thread_cleanup() exists. At least in the case of |
| 71 | * FreeBSD, pthread_key_create() allocates, which if used during malloc |
| 72 | * bootstrapping will cause recursion into the pthreads library. Therefore, if |
| 73 | * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in |
| 74 | * malloc_tsd. |
| 75 | */ |
| 76 | #undef JEMALLOC_MALLOC_THREAD_CLEANUP |
| 77 | |
| 78 | /* |
| 79 | * Defined if threaded initialization is known to be safe on this platform. |
| 80 | * Among other things, it must be possible to initialize a mutex without |
| 81 | * triggering allocation in order for threaded allocation to be safe. |
| 82 | */ |
| 83 | #undef JEMALLOC_THREADED_INIT |
| 84 | |
| 85 | /* |
| 86 | * Defined if the pthreads implementation defines |
| 87 | * _pthread_mutex_init_calloc_cb(), in which case the function is used in order |
| 88 | * to avoid recursive allocation during mutex initialization. |
| 89 | */ |
| 90 | #undef JEMALLOC_MUTEX_INIT_CB |
| 91 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 92 | /* Non-empty if the tls_model attribute is supported. */ |
| 93 | #undef JEMALLOC_TLS_MODEL |
| 94 | |
| 95 | /* JEMALLOC_CC_SILENCE enables code that silences unuseful compiler warnings. */ |
| 96 | #undef JEMALLOC_CC_SILENCE |
| 97 | |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 98 | /* JEMALLOC_CODE_COVERAGE enables test code coverage analysis. */ |
| 99 | #undef JEMALLOC_CODE_COVERAGE |
| 100 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 101 | /* |
| 102 | * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables |
| 103 | * inline functions. |
| 104 | */ |
| 105 | #undef JEMALLOC_DEBUG |
| 106 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 107 | /* JEMALLOC_STATS enables statistics calculation. */ |
| 108 | #undef JEMALLOC_STATS |
| 109 | |
| 110 | /* JEMALLOC_PROF enables allocation profiling. */ |
| 111 | #undef JEMALLOC_PROF |
| 112 | |
| 113 | /* Use libunwind for profile backtracing if defined. */ |
| 114 | #undef JEMALLOC_PROF_LIBUNWIND |
| 115 | |
| 116 | /* Use libgcc for profile backtracing if defined. */ |
| 117 | #undef JEMALLOC_PROF_LIBGCC |
| 118 | |
| 119 | /* Use gcc intrinsics for profile backtracing if defined. */ |
| 120 | #undef JEMALLOC_PROF_GCC |
| 121 | |
| 122 | /* |
| 123 | * JEMALLOC_TCACHE enables a thread-specific caching layer for small objects. |
| 124 | * This makes it possible to allocate/deallocate objects without any locking |
| 125 | * when the cache is in the steady state. |
| 126 | */ |
| 127 | #undef JEMALLOC_TCACHE |
| 128 | |
| 129 | /* |
| 130 | * JEMALLOC_DSS enables use of sbrk(2) to allocate chunks from the data storage |
| 131 | * segment (DSS). |
| 132 | */ |
| 133 | #undef JEMALLOC_DSS |
| 134 | |
| 135 | /* Support memory filling (junk/zero/quarantine/redzone). */ |
| 136 | #undef JEMALLOC_FILL |
| 137 | |
| 138 | /* Support utrace(2)-based tracing. */ |
| 139 | #undef JEMALLOC_UTRACE |
| 140 | |
| 141 | /* Support Valgrind. */ |
| 142 | #undef JEMALLOC_VALGRIND |
| 143 | |
| 144 | /* Support optional abort() on OOM. */ |
| 145 | #undef JEMALLOC_XMALLOC |
| 146 | |
| 147 | /* Support lazy locking (avoid locking unless a second thread is launched). */ |
| 148 | #undef JEMALLOC_LAZY_LOCK |
| 149 | |
Jason Evans | 81e5475 | 2014-10-10 22:34:25 -0700 | [diff] [blame] | 150 | /* Minimum size class to support is 2^LG_TINY_MIN bytes. */ |
| 151 | #undef LG_TINY_MIN |
| 152 | |
Jason Evans | fc0b3b7 | 2014-10-09 17:54:06 -0700 | [diff] [blame] | 153 | /* |
| 154 | * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size |
| 155 | * classes). |
| 156 | */ |
| 157 | #undef LG_QUANTUM |
| 158 | |
| 159 | /* One page is 2^LG_PAGE bytes. */ |
| 160 | #undef LG_PAGE |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 161 | |
| 162 | /* |
| 163 | * If defined, use munmap() to unmap freed chunks, rather than storing them for |
| 164 | * later reuse. This is disabled by default on Linux because common sequences |
| 165 | * of mmap()/munmap() calls will cause virtual memory map holes. |
| 166 | */ |
| 167 | #undef JEMALLOC_MUNMAP |
| 168 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 169 | /* TLS is used to map arenas and magazine caches to threads. */ |
| 170 | #undef JEMALLOC_TLS |
| 171 | |
| 172 | /* |
Richard Diamond | 9c3a10f | 2014-05-28 21:37:02 -0500 | [diff] [blame] | 173 | * ffs()/ffsl() functions to use for bitmapping. Don't use these directly; |
| 174 | * instead, use jemalloc_ffs() or jemalloc_ffsl() from util.h. |
| 175 | */ |
| 176 | #undef JEMALLOC_INTERNAL_FFSL |
| 177 | #undef JEMALLOC_INTERNAL_FFS |
| 178 | |
| 179 | /* |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 180 | * JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside |
| 181 | * within jemalloc-owned chunks before dereferencing them. |
| 182 | */ |
| 183 | #undef JEMALLOC_IVSALLOC |
| 184 | |
| 185 | /* |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 186 | * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings. |
| 187 | */ |
| 188 | #undef JEMALLOC_ZONE |
| 189 | #undef JEMALLOC_ZONE_VERSION |
| 190 | |
| 191 | /* |
| 192 | * Methods for purging unused pages differ between operating systems. |
| 193 | * |
| 194 | * madvise(..., MADV_DONTNEED) : On Linux, this immediately discards pages, |
| 195 | * such that new pages will be demand-zeroed if |
| 196 | * the address region is later touched. |
| 197 | * madvise(..., MADV_FREE) : On FreeBSD and Darwin, this marks pages as being |
| 198 | * unused, such that they will be discarded rather |
| 199 | * than swapped out. |
| 200 | */ |
| 201 | #undef JEMALLOC_PURGE_MADVISE_DONTNEED |
| 202 | #undef JEMALLOC_PURGE_MADVISE_FREE |
| 203 | |
Jason Evans | e12eaf9 | 2014-12-08 14:40:14 -0800 | [diff] [blame^] | 204 | /* Define if operating system has alloca.h header. */ |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 205 | #undef JEMALLOC_HAS_ALLOCA_H |
| 206 | |
Jason Evans | 99b0fbb | 2014-02-24 16:08:38 -0800 | [diff] [blame] | 207 | /* C99 restrict keyword supported. */ |
| 208 | #undef JEMALLOC_HAS_RESTRICT |
| 209 | |
Jason Evans | df3f270 | 2014-03-30 16:27:08 -0700 | [diff] [blame] | 210 | /* For use by hash code. */ |
| 211 | #undef JEMALLOC_BIG_ENDIAN |
| 212 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 213 | /* sizeof(int) == 2^LG_SIZEOF_INT. */ |
| 214 | #undef LG_SIZEOF_INT |
| 215 | |
| 216 | /* sizeof(long) == 2^LG_SIZEOF_LONG. */ |
| 217 | #undef LG_SIZEOF_LONG |
| 218 | |
| 219 | /* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */ |
| 220 | #undef LG_SIZEOF_INTMAX_T |
Jason Evans | 0f4f1ef | 2013-12-12 14:41:02 -0800 | [diff] [blame] | 221 | |
Jason Evans | e12eaf9 | 2014-12-08 14:40:14 -0800 | [diff] [blame^] | 222 | /* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */ |
Sara Golemon | 3e24afa | 2014-08-18 13:06:39 -0700 | [diff] [blame] | 223 | #undef JEMALLOC_GLIBC_MALLOC_HOOK |
| 224 | |
Jason Evans | e12eaf9 | 2014-12-08 14:40:14 -0800 | [diff] [blame^] | 225 | /* glibc memalign hook. */ |
Sara Golemon | 3e24afa | 2014-08-18 13:06:39 -0700 | [diff] [blame] | 226 | #undef JEMALLOC_GLIBC_MEMALIGN_HOOK |
| 227 | |
Jason Evans | e12eaf9 | 2014-12-08 14:40:14 -0800 | [diff] [blame^] | 228 | /* Adaptive mutex support in pthreads. */ |
Eric Wong | 4dcf04b | 2014-08-31 03:57:06 +0000 | [diff] [blame] | 229 | #undef JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP |
| 230 | |
Jason Evans | 0f4f1ef | 2013-12-12 14:41:02 -0800 | [diff] [blame] | 231 | #endif /* JEMALLOC_INTERNAL_DEFS_H_ */ |