7372b15a31
Convert configuration-related cpp conditional logic to use static constant variables, e.g.: #ifdef JEMALLOC_DEBUG [...] #endif becomes: if (config_debug) { [...] } The advantage is clearer, more concise code. The main disadvantage is that data structures no longer have conditionally defined fields, so they pay the cost of all fields regardless of whether they are used. In practice, this is only a minor concern; config_stats will go away in an upcoming change, and config_prof is the only other major feature that depends on more than a few special-purpose fields.
170 lines
4.7 KiB
C
170 lines
4.7 KiB
C
#ifndef JEMALLOC_DEFS_H_
|
|
#define JEMALLOC_DEFS_H_
|
|
|
|
/*
|
|
* If JEMALLOC_PREFIX is defined, it will cause all public APIs to be prefixed.
|
|
* This makes it possible, with some care, to use multiple allocators
|
|
* simultaneously.
|
|
*
|
|
* In many cases it is more convenient to manually prefix allocator function
|
|
* calls than to let macros do it automatically, particularly when using
|
|
* multiple allocators simultaneously. Define JEMALLOC_MANGLE before
|
|
* #include'ing jemalloc.h in order to cause name mangling that corresponds to
|
|
* the API prefixing.
|
|
*/
|
|
#undef JEMALLOC_PREFIX
|
|
#undef JEMALLOC_CPREFIX
|
|
#if (defined(JEMALLOC_PREFIX) && defined(JEMALLOC_MANGLE))
|
|
#undef JEMALLOC_P
|
|
#endif
|
|
|
|
/*
|
|
* JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
|
|
* For shared libraries, symbol visibility mechanisms prevent these symbols
|
|
* from being exported, but for static libraries, naming collisions are a real
|
|
* possibility.
|
|
*/
|
|
#undef JEMALLOC_PRIVATE_NAMESPACE
|
|
#undef JEMALLOC_N
|
|
|
|
/*
|
|
* Hyper-threaded CPUs may need a special instruction inside spin loops in
|
|
* order to yield to another virtual CPU.
|
|
*/
|
|
#undef CPU_SPINWAIT
|
|
|
|
/*
|
|
* Defined if OSAtomic*() functions are available, as provided by Darwin, and
|
|
* documented in the atomic(3) manual page.
|
|
*/
|
|
#undef JEMALLOC_OSATOMIC
|
|
|
|
/*
|
|
* Defined if OSSpin*() functions are available, as provided by Darwin, and
|
|
* documented in the spinlock(3) manual page.
|
|
*/
|
|
#undef JEMALLOC_OSSPIN
|
|
|
|
/* Defined if __attribute__((...)) syntax is supported. */
|
|
#undef JEMALLOC_HAVE_ATTR
|
|
#ifdef JEMALLOC_HAVE_ATTR
|
|
# define JEMALLOC_CATTR(s, a) __attribute__((s))
|
|
# define JEMALLOC_ATTR(s) JEMALLOC_CATTR(s,)
|
|
#else
|
|
# define JEMALLOC_CATTR(s, a) a
|
|
# define JEMALLOC_ATTR(s) JEMALLOC_CATTR(s,)
|
|
#endif
|
|
|
|
/* JEMALLOC_CC_SILENCE enables code that silences unuseful compiler warnings. */
|
|
#undef JEMALLOC_CC_SILENCE
|
|
|
|
/*
|
|
* JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
|
|
* inline functions.
|
|
*/
|
|
#undef JEMALLOC_DEBUG
|
|
|
|
/* JEMALLOC_STATS enables statistics calculation. */
|
|
#undef JEMALLOC_STATS
|
|
|
|
/* JEMALLOC_PROF enables allocation profiling. */
|
|
#undef JEMALLOC_PROF
|
|
|
|
/* Use libunwind for profile backtracing if defined. */
|
|
#undef JEMALLOC_PROF_LIBUNWIND
|
|
|
|
/* Use libgcc for profile backtracing if defined. */
|
|
#undef JEMALLOC_PROF_LIBGCC
|
|
|
|
/* Use gcc intrinsics for profile backtracing if defined. */
|
|
#undef JEMALLOC_PROF_GCC
|
|
|
|
/*
|
|
* JEMALLOC_TINY enables support for tiny objects, which are smaller than one
|
|
* quantum.
|
|
*/
|
|
#undef JEMALLOC_TINY
|
|
|
|
/*
|
|
* JEMALLOC_TCACHE enables a thread-specific caching layer for small objects.
|
|
* This makes it possible to allocate/deallocate objects without any locking
|
|
* when the cache is in the steady state.
|
|
*/
|
|
#undef JEMALLOC_TCACHE
|
|
|
|
/*
|
|
* JEMALLOC_DSS enables use of sbrk(2) to allocate chunks from the data storage
|
|
* segment (DSS).
|
|
*/
|
|
#undef JEMALLOC_DSS
|
|
|
|
/* JEMALLOC_SWAP enables mmap()ed swap file support. */
|
|
#undef JEMALLOC_SWAP
|
|
|
|
/* Support memory filling (junk/zero). */
|
|
#undef JEMALLOC_FILL
|
|
|
|
/* Support optional abort() on OOM. */
|
|
#undef JEMALLOC_XMALLOC
|
|
|
|
/* Support SYSV semantics. */
|
|
#undef JEMALLOC_SYSV
|
|
|
|
/* Support lazy locking (avoid locking unless a second thread is launched). */
|
|
#undef JEMALLOC_LAZY_LOCK
|
|
|
|
/* Determine page size at run time if defined. */
|
|
#undef DYNAMIC_PAGE_SHIFT
|
|
|
|
/* One page is 2^STATIC_PAGE_SHIFT bytes. */
|
|
#undef STATIC_PAGE_SHIFT
|
|
|
|
/* TLS is used to map arenas and magazine caches to threads. */
|
|
#undef NO_TLS
|
|
|
|
/*
|
|
* JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside
|
|
* within jemalloc-owned chunks before dereferencing them.
|
|
*/
|
|
#undef JEMALLOC_IVSALLOC
|
|
|
|
/*
|
|
* Define overrides for non-standard allocator-related functions if they
|
|
* are present on the system.
|
|
*/
|
|
#undef JEMALLOC_OVERRIDE_MEMALIGN
|
|
#undef JEMALLOC_OVERRIDE_VALLOC
|
|
|
|
/*
|
|
* Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
|
|
*/
|
|
#undef JEMALLOC_ZONE
|
|
#undef JEMALLOC_ZONE_VERSION
|
|
|
|
/* If defined, use mremap(...MREMAP_FIXED...) for huge realloc(). */
|
|
#undef JEMALLOC_MREMAP_FIXED
|
|
|
|
/*
|
|
* Methods for purging unused pages differ between operating systems.
|
|
*
|
|
* madvise(..., MADV_DONTNEED) : On Linux, this immediately discards pages,
|
|
* such that new pages will be demand-zeroed if
|
|
* the address region is later touched.
|
|
* madvise(..., MADV_FREE) : On FreeBSD and Darwin, this marks pages as being
|
|
* unused, such that they will be discarded rather
|
|
* than swapped out.
|
|
*/
|
|
#undef JEMALLOC_PURGE_MADVISE_DONTNEED
|
|
#undef JEMALLOC_PURGE_MADVISE_FREE
|
|
|
|
/* sizeof(void *) == 2^LG_SIZEOF_PTR. */
|
|
#undef LG_SIZEOF_PTR
|
|
|
|
/* sizeof(int) == 2^LG_SIZEOF_INT. */
|
|
#undef LG_SIZEOF_INT
|
|
|
|
/* sizeof(long) == 2^LG_SIZEOF_LONG. */
|
|
#undef LG_SIZEOF_LONG
|
|
|
|
#endif /* JEMALLOC_DEFS_H_ */
|