1*8e33eff8Schristos #include <stdlib.h> 2*8e33eff8Schristos #include <stdbool.h> 3*8e33eff8Schristos #include <stdint.h> 4*8e33eff8Schristos #include <limits.h> 5*8e33eff8Schristos #include <strings.h> 6*8e33eff8Schristos 7*8e33eff8Schristos #define JEMALLOC_VERSION "5.1.0-0-g61efbda7098de6fe64c362d309824864308c36d4" 8*8e33eff8Schristos #define JEMALLOC_VERSION_MAJOR 5 9*8e33eff8Schristos #define JEMALLOC_VERSION_MINOR 1 10*8e33eff8Schristos #define JEMALLOC_VERSION_BUGFIX 0 11*8e33eff8Schristos #define JEMALLOC_VERSION_NREV 0 12*8e33eff8Schristos #define JEMALLOC_VERSION_GID "61efbda7098de6fe64c362d309824864308c36d4" 13*8e33eff8Schristos 14*8e33eff8Schristos #define MALLOCX_LG_ALIGN(la) ((int)(la)) 15*8e33eff8Schristos #if LG_SIZEOF_PTR == 2 16*8e33eff8Schristos # define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1)) 17*8e33eff8Schristos #else 18*8e33eff8Schristos # define MALLOCX_ALIGN(a) \ 19*8e33eff8Schristos ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \ 20*8e33eff8Schristos ffs((int)(((size_t)(a))>>32))+31)) 21*8e33eff8Schristos #endif 22*8e33eff8Schristos #define MALLOCX_ZERO ((int)0x40) 23*8e33eff8Schristos /* 24*8e33eff8Schristos * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1 25*8e33eff8Schristos * encodes MALLOCX_TCACHE_NONE. 26*8e33eff8Schristos */ 27*8e33eff8Schristos #define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8)) 28*8e33eff8Schristos #define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1) 29*8e33eff8Schristos /* 30*8e33eff8Schristos * Bias arena index bits so that 0 encodes "use an automatically chosen arena". 31*8e33eff8Schristos */ 32*8e33eff8Schristos #define MALLOCX_ARENA(a) ((((int)(a))+1) << 20) 33*8e33eff8Schristos 34*8e33eff8Schristos /* 35*8e33eff8Schristos * Use as arena index in "arena.<i>.{purge,decay,dss}" and 36*8e33eff8Schristos * "stats.arenas.<i>.*" mallctl interfaces to select all arenas. This 37*8e33eff8Schristos * definition is intentionally specified in raw decimal format to support 38*8e33eff8Schristos * cpp-based string concatenation, e.g. 39*8e33eff8Schristos * 40*8e33eff8Schristos * #define STRINGIFY_HELPER(x) #x 41*8e33eff8Schristos * #define STRINGIFY(x) STRINGIFY_HELPER(x) 42*8e33eff8Schristos * 43*8e33eff8Schristos * mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL, 44*8e33eff8Schristos * 0); 45*8e33eff8Schristos */ 46*8e33eff8Schristos #define MALLCTL_ARENAS_ALL 4096 47*8e33eff8Schristos /* 48*8e33eff8Schristos * Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select 49*8e33eff8Schristos * destroyed arenas. 50*8e33eff8Schristos */ 51*8e33eff8Schristos #define MALLCTL_ARENAS_DESTROYED 4097 52*8e33eff8Schristos 53*8e33eff8Schristos #if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW) 54*8e33eff8Schristos # define JEMALLOC_CXX_THROW throw() 55*8e33eff8Schristos #else 56*8e33eff8Schristos # define JEMALLOC_CXX_THROW 57*8e33eff8Schristos #endif 58*8e33eff8Schristos 59*8e33eff8Schristos #if defined(_MSC_VER) 60*8e33eff8Schristos # define JEMALLOC_ATTR(s) 61*8e33eff8Schristos # define JEMALLOC_ALIGNED(s) __declspec(align(s)) 62*8e33eff8Schristos # define JEMALLOC_ALLOC_SIZE(s) 63*8e33eff8Schristos # define JEMALLOC_ALLOC_SIZE2(s1, s2) 64*8e33eff8Schristos # ifndef JEMALLOC_EXPORT 65*8e33eff8Schristos # ifdef DLLEXPORT 66*8e33eff8Schristos # define JEMALLOC_EXPORT __declspec(dllexport) 67*8e33eff8Schristos # else 68*8e33eff8Schristos # define JEMALLOC_EXPORT __declspec(dllimport) 69*8e33eff8Schristos # endif 70*8e33eff8Schristos # endif 71*8e33eff8Schristos # define JEMALLOC_FORMAT_PRINTF(s, i) 72*8e33eff8Schristos # define JEMALLOC_NOINLINE __declspec(noinline) 73*8e33eff8Schristos # ifdef __cplusplus 74*8e33eff8Schristos # define JEMALLOC_NOTHROW __declspec(nothrow) 75*8e33eff8Schristos # else 76*8e33eff8Schristos # define JEMALLOC_NOTHROW 77*8e33eff8Schristos # endif 78*8e33eff8Schristos # define JEMALLOC_SECTION(s) __declspec(allocate(s)) 79*8e33eff8Schristos # define JEMALLOC_RESTRICT_RETURN __declspec(restrict) 80*8e33eff8Schristos # if _MSC_VER >= 1900 && !defined(__EDG__) 81*8e33eff8Schristos # define JEMALLOC_ALLOCATOR __declspec(allocator) 82*8e33eff8Schristos # else 83*8e33eff8Schristos # define JEMALLOC_ALLOCATOR 84*8e33eff8Schristos # endif 85*8e33eff8Schristos #elif defined(JEMALLOC_HAVE_ATTR) 86*8e33eff8Schristos # define JEMALLOC_ATTR(s) __attribute__((s)) 87*8e33eff8Schristos # define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s)) 88*8e33eff8Schristos # ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE 89*8e33eff8Schristos # define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s)) 90*8e33eff8Schristos # define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2)) 91*8e33eff8Schristos # else 92*8e33eff8Schristos # define JEMALLOC_ALLOC_SIZE(s) 93*8e33eff8Schristos # define JEMALLOC_ALLOC_SIZE2(s1, s2) 94*8e33eff8Schristos # endif 95*8e33eff8Schristos # ifndef JEMALLOC_EXPORT 96*8e33eff8Schristos # define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default")) 97*8e33eff8Schristos # endif 98*8e33eff8Schristos # ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF 99*8e33eff8Schristos # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i)) 100*8e33eff8Schristos # elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF) 101*8e33eff8Schristos # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i)) 102*8e33eff8Schristos # else 103*8e33eff8Schristos # define JEMALLOC_FORMAT_PRINTF(s, i) 104*8e33eff8Schristos # endif 105*8e33eff8Schristos # define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline) 106*8e33eff8Schristos # define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow) 107*8e33eff8Schristos # define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s)) 108*8e33eff8Schristos # define JEMALLOC_RESTRICT_RETURN 109*8e33eff8Schristos # define JEMALLOC_ALLOCATOR 110*8e33eff8Schristos #else 111*8e33eff8Schristos # define JEMALLOC_ATTR(s) 112*8e33eff8Schristos # define JEMALLOC_ALIGNED(s) 113*8e33eff8Schristos # define JEMALLOC_ALLOC_SIZE(s) 114*8e33eff8Schristos # define JEMALLOC_ALLOC_SIZE2(s1, s2) 115*8e33eff8Schristos # define JEMALLOC_EXPORT 116*8e33eff8Schristos # define JEMALLOC_FORMAT_PRINTF(s, i) 117*8e33eff8Schristos # define JEMALLOC_NOINLINE 118*8e33eff8Schristos # define JEMALLOC_NOTHROW 119*8e33eff8Schristos # define JEMALLOC_SECTION(s) 120*8e33eff8Schristos # define JEMALLOC_RESTRICT_RETURN 121*8e33eff8Schristos # define JEMALLOC_ALLOCATOR 122*8e33eff8Schristos #endif 123