1*1208bc7eSAndroid Build Coastguard Worker #ifndef JEMALLOC_H_ 2*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_H_ 3*1208bc7eSAndroid Build Coastguard Worker #ifdef __cplusplus 4*1208bc7eSAndroid Build Coastguard Worker extern "C" { 5*1208bc7eSAndroid Build Coastguard Worker #endif 6*1208bc7eSAndroid Build Coastguard Worker 7*1208bc7eSAndroid Build Coastguard Worker /* Defined if __attribute__((...)) syntax is supported. */ 8*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_HAVE_ATTR 9*1208bc7eSAndroid Build Coastguard Worker 10*1208bc7eSAndroid Build Coastguard Worker /* Defined if alloc_size attribute is supported. */ 11*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_HAVE_ATTR_ALLOC_SIZE 12*1208bc7eSAndroid Build Coastguard Worker 13*1208bc7eSAndroid Build Coastguard Worker /* Defined if format(gnu_printf, ...) attribute is supported. */ 14*1208bc7eSAndroid Build Coastguard Worker /* #undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF */ 15*1208bc7eSAndroid Build Coastguard Worker 16*1208bc7eSAndroid Build Coastguard Worker /* Defined if format(printf, ...) attribute is supported. */ 17*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF 18*1208bc7eSAndroid Build Coastguard Worker 19*1208bc7eSAndroid Build Coastguard Worker /* 20*1208bc7eSAndroid Build Coastguard Worker * Define overrides for non-standard allocator-related functions if they are 21*1208bc7eSAndroid Build Coastguard Worker * present on the system. 22*1208bc7eSAndroid Build Coastguard Worker */ 23*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_OVERRIDE_MEMALIGN 24*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_OVERRIDE_VALLOC 25*1208bc7eSAndroid Build Coastguard Worker 26*1208bc7eSAndroid Build Coastguard Worker /* 27*1208bc7eSAndroid Build Coastguard Worker * At least Linux omits the "const" in: 28*1208bc7eSAndroid Build Coastguard Worker * 29*1208bc7eSAndroid Build Coastguard Worker * size_t malloc_usable_size(const void *ptr); 30*1208bc7eSAndroid Build Coastguard Worker * 31*1208bc7eSAndroid Build Coastguard Worker * Match the operating system's prototype. 32*1208bc7eSAndroid Build Coastguard Worker */ 33*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_USABLE_SIZE_CONST const 34*1208bc7eSAndroid Build Coastguard Worker 35*1208bc7eSAndroid Build Coastguard Worker /* 36*1208bc7eSAndroid Build Coastguard Worker * If defined, specify throw() for the public function prototypes when compiling 37*1208bc7eSAndroid Build Coastguard Worker * with C++. The only justification for this is to match the prototypes that 38*1208bc7eSAndroid Build Coastguard Worker * glibc defines. 39*1208bc7eSAndroid Build Coastguard Worker */ 40*1208bc7eSAndroid Build Coastguard Worker /* #undef JEMALLOC_USE_CXX_THROW */ 41*1208bc7eSAndroid Build Coastguard Worker 42*1208bc7eSAndroid Build Coastguard Worker #ifdef _MSC_VER 43*1208bc7eSAndroid Build Coastguard Worker # ifdef _WIN64 44*1208bc7eSAndroid Build Coastguard Worker # define LG_SIZEOF_PTR_WIN 3 45*1208bc7eSAndroid Build Coastguard Worker # else 46*1208bc7eSAndroid Build Coastguard Worker # define LG_SIZEOF_PTR_WIN 2 47*1208bc7eSAndroid Build Coastguard Worker # endif 48*1208bc7eSAndroid Build Coastguard Worker #endif 49*1208bc7eSAndroid Build Coastguard Worker 50*1208bc7eSAndroid Build Coastguard Worker /* sizeof(void *) == 2^LG_SIZEOF_PTR. */ 51*1208bc7eSAndroid Build Coastguard Worker #if defined(__LP64__) 52*1208bc7eSAndroid Build Coastguard Worker #define LG_SIZEOF_PTR 3 53*1208bc7eSAndroid Build Coastguard Worker #else 54*1208bc7eSAndroid Build Coastguard Worker #define LG_SIZEOF_PTR 2 55*1208bc7eSAndroid Build Coastguard Worker #endif 56*1208bc7eSAndroid Build Coastguard Worker 57*1208bc7eSAndroid Build Coastguard Worker /* 58*1208bc7eSAndroid Build Coastguard Worker * Name mangling for public symbols is controlled by --with-mangling and 59*1208bc7eSAndroid Build Coastguard Worker * --with-jemalloc-prefix. With default settings the je_ prefix is stripped by 60*1208bc7eSAndroid Build Coastguard Worker * these macro definitions. 61*1208bc7eSAndroid Build Coastguard Worker */ 62*1208bc7eSAndroid Build Coastguard Worker #include "jemalloc_rename.h" 63*1208bc7eSAndroid Build Coastguard Worker 64*1208bc7eSAndroid Build Coastguard Worker #include <stdlib.h> 65*1208bc7eSAndroid Build Coastguard Worker #include <stdbool.h> 66*1208bc7eSAndroid Build Coastguard Worker #include <stdint.h> 67*1208bc7eSAndroid Build Coastguard Worker #include <limits.h> 68*1208bc7eSAndroid Build Coastguard Worker #include <strings.h> 69*1208bc7eSAndroid Build Coastguard Worker 70*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_VERSION "5.1.0-0-g61efbda7098de6fe64c362d309824864308c36d4" 71*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_VERSION_MAJOR 5 72*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_VERSION_MINOR 1 73*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_VERSION_BUGFIX 0 74*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_VERSION_NREV 0 75*1208bc7eSAndroid Build Coastguard Worker #define JEMALLOC_VERSION_GID "61efbda7098de6fe64c362d309824864308c36d4" 76*1208bc7eSAndroid Build Coastguard Worker 77*1208bc7eSAndroid Build Coastguard Worker #define MALLOCX_LG_ALIGN(la) ((int)(la)) 78*1208bc7eSAndroid Build Coastguard Worker #if LG_SIZEOF_PTR == 2 79*1208bc7eSAndroid Build Coastguard Worker # define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1)) 80*1208bc7eSAndroid Build Coastguard Worker #else 81*1208bc7eSAndroid Build Coastguard Worker # define MALLOCX_ALIGN(a) \ 82*1208bc7eSAndroid Build Coastguard Worker ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \ 83*1208bc7eSAndroid Build Coastguard Worker ffs((int)(((size_t)(a))>>32))+31)) 84*1208bc7eSAndroid Build Coastguard Worker #endif 85*1208bc7eSAndroid Build Coastguard Worker #define MALLOCX_ZERO ((int)0x40) 86*1208bc7eSAndroid Build Coastguard Worker /* 87*1208bc7eSAndroid Build Coastguard Worker * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1 88*1208bc7eSAndroid Build Coastguard Worker * encodes MALLOCX_TCACHE_NONE. 89*1208bc7eSAndroid Build Coastguard Worker */ 90*1208bc7eSAndroid Build Coastguard Worker #define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8)) 91*1208bc7eSAndroid Build Coastguard Worker #define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1) 92*1208bc7eSAndroid Build Coastguard Worker /* 93*1208bc7eSAndroid Build Coastguard Worker * Bias arena index bits so that 0 encodes "use an automatically chosen arena". 94*1208bc7eSAndroid Build Coastguard Worker */ 95*1208bc7eSAndroid Build Coastguard Worker #define MALLOCX_ARENA(a) ((((int)(a))+1) << 20) 96*1208bc7eSAndroid Build Coastguard Worker 97*1208bc7eSAndroid Build Coastguard Worker /* 98*1208bc7eSAndroid Build Coastguard Worker * Use as arena index in "arena.<i>.{purge,decay,dss}" and 99*1208bc7eSAndroid Build Coastguard Worker * "stats.arenas.<i>.*" mallctl interfaces to select all arenas. This 100*1208bc7eSAndroid Build Coastguard Worker * definition is intentionally specified in raw decimal format to support 101*1208bc7eSAndroid Build Coastguard Worker * cpp-based string concatenation, e.g. 102*1208bc7eSAndroid Build Coastguard Worker * 103*1208bc7eSAndroid Build Coastguard Worker * #define STRINGIFY_HELPER(x) #x 104*1208bc7eSAndroid Build Coastguard Worker * #define STRINGIFY(x) STRINGIFY_HELPER(x) 105*1208bc7eSAndroid Build Coastguard Worker * 106*1208bc7eSAndroid Build Coastguard Worker * mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL, 107*1208bc7eSAndroid Build Coastguard Worker * 0); 108*1208bc7eSAndroid Build Coastguard Worker */ 109*1208bc7eSAndroid Build Coastguard Worker #define MALLCTL_ARENAS_ALL 4096 110*1208bc7eSAndroid Build Coastguard Worker /* 111*1208bc7eSAndroid Build Coastguard Worker * Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select 112*1208bc7eSAndroid Build Coastguard Worker * destroyed arenas. 113*1208bc7eSAndroid Build Coastguard Worker */ 114*1208bc7eSAndroid Build Coastguard Worker #define MALLCTL_ARENAS_DESTROYED 4097 115*1208bc7eSAndroid Build Coastguard Worker 116*1208bc7eSAndroid Build Coastguard Worker #if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW) 117*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_CXX_THROW throw() 118*1208bc7eSAndroid Build Coastguard Worker #else 119*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_CXX_THROW 120*1208bc7eSAndroid Build Coastguard Worker #endif 121*1208bc7eSAndroid Build Coastguard Worker 122*1208bc7eSAndroid Build Coastguard Worker #if defined(_MSC_VER) 123*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ATTR(s) 124*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALIGNED(s) __declspec(align(s)) 125*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOC_SIZE(s) 126*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOC_SIZE2(s1, s2) 127*1208bc7eSAndroid Build Coastguard Worker # ifndef JEMALLOC_EXPORT 128*1208bc7eSAndroid Build Coastguard Worker # ifdef DLLEXPORT 129*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_EXPORT __declspec(dllexport) 130*1208bc7eSAndroid Build Coastguard Worker # else 131*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_EXPORT __declspec(dllimport) 132*1208bc7eSAndroid Build Coastguard Worker # endif 133*1208bc7eSAndroid Build Coastguard Worker # endif 134*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_FORMAT_PRINTF(s, i) 135*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_NOINLINE __declspec(noinline) 136*1208bc7eSAndroid Build Coastguard Worker # ifdef __cplusplus 137*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_NOTHROW __declspec(nothrow) 138*1208bc7eSAndroid Build Coastguard Worker # else 139*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_NOTHROW 140*1208bc7eSAndroid Build Coastguard Worker # endif 141*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_SECTION(s) __declspec(allocate(s)) 142*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_RESTRICT_RETURN __declspec(restrict) 143*1208bc7eSAndroid Build Coastguard Worker # if _MSC_VER >= 1900 && !defined(__EDG__) 144*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOCATOR __declspec(allocator) 145*1208bc7eSAndroid Build Coastguard Worker # else 146*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOCATOR 147*1208bc7eSAndroid Build Coastguard Worker # endif 148*1208bc7eSAndroid Build Coastguard Worker #elif defined(JEMALLOC_HAVE_ATTR) 149*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ATTR(s) __attribute__((s)) 150*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s)) 151*1208bc7eSAndroid Build Coastguard Worker # ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE 152*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s)) 153*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2)) 154*1208bc7eSAndroid Build Coastguard Worker # else 155*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOC_SIZE(s) 156*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOC_SIZE2(s1, s2) 157*1208bc7eSAndroid Build Coastguard Worker # endif 158*1208bc7eSAndroid Build Coastguard Worker # ifndef JEMALLOC_EXPORT 159*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default")) 160*1208bc7eSAndroid Build Coastguard Worker # endif 161*1208bc7eSAndroid Build Coastguard Worker # ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF 162*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i)) 163*1208bc7eSAndroid Build Coastguard Worker # elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF) 164*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i)) 165*1208bc7eSAndroid Build Coastguard Worker # else 166*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_FORMAT_PRINTF(s, i) 167*1208bc7eSAndroid Build Coastguard Worker # endif 168*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline) 169*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow) 170*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s)) 171*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_RESTRICT_RETURN 172*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOCATOR 173*1208bc7eSAndroid Build Coastguard Worker #else 174*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ATTR(s) 175*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALIGNED(s) 176*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOC_SIZE(s) 177*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOC_SIZE2(s1, s2) 178*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_EXPORT 179*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_FORMAT_PRINTF(s, i) 180*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_NOINLINE 181*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_NOTHROW 182*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_SECTION(s) 183*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_RESTRICT_RETURN 184*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_ALLOCATOR 185*1208bc7eSAndroid Build Coastguard Worker #endif 186*1208bc7eSAndroid Build Coastguard Worker 187*1208bc7eSAndroid Build Coastguard Worker /* 188*1208bc7eSAndroid Build Coastguard Worker * The je_ prefix on the following public symbol declarations is an artifact 189*1208bc7eSAndroid Build Coastguard Worker * of namespace management, and should be omitted in application code unless 190*1208bc7eSAndroid Build Coastguard Worker * JEMALLOC_NO_DEMANGLE is defined (see jemalloc_mangle.h). 191*1208bc7eSAndroid Build Coastguard Worker */ 192*1208bc7eSAndroid Build Coastguard Worker extern JEMALLOC_EXPORT const char *je_malloc_conf; 193*1208bc7eSAndroid Build Coastguard Worker extern JEMALLOC_EXPORT void (*je_malloc_message)(void *cbopaque, 194*1208bc7eSAndroid Build Coastguard Worker const char *s); 195*1208bc7eSAndroid Build Coastguard Worker 196*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN 197*1208bc7eSAndroid Build Coastguard Worker void JEMALLOC_NOTHROW *je_malloc(size_t size) 198*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1); 199*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN 200*1208bc7eSAndroid Build Coastguard Worker void JEMALLOC_NOTHROW *je_calloc(size_t num, size_t size) 201*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE2(1, 2); 202*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_posix_memalign(void **memptr, 203*1208bc7eSAndroid Build Coastguard Worker size_t alignment, size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(nonnull(1)); 204*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN 205*1208bc7eSAndroid Build Coastguard Worker void JEMALLOC_NOTHROW *je_aligned_alloc(size_t alignment, 206*1208bc7eSAndroid Build Coastguard Worker size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) 207*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_ALLOC_SIZE(2); 208*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN 209*1208bc7eSAndroid Build Coastguard Worker void JEMALLOC_NOTHROW *je_realloc(void *ptr, size_t size) 210*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_CXX_THROW JEMALLOC_ALLOC_SIZE(2); 211*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_free(void *ptr) 212*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_CXX_THROW; 213*1208bc7eSAndroid Build Coastguard Worker 214*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN 215*1208bc7eSAndroid Build Coastguard Worker void JEMALLOC_NOTHROW *je_mallocx(size_t size, int flags) 216*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1); 217*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN 218*1208bc7eSAndroid Build Coastguard Worker void JEMALLOC_NOTHROW *je_rallocx(void *ptr, size_t size, 219*1208bc7eSAndroid Build Coastguard Worker int flags) JEMALLOC_ALLOC_SIZE(2); 220*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_xallocx(void *ptr, size_t size, 221*1208bc7eSAndroid Build Coastguard Worker size_t extra, int flags); 222*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_sallocx(const void *ptr, 223*1208bc7eSAndroid Build Coastguard Worker int flags) JEMALLOC_ATTR(pure); 224*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_dallocx(void *ptr, int flags); 225*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_sdallocx(void *ptr, size_t size, 226*1208bc7eSAndroid Build Coastguard Worker int flags); 227*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_nallocx(size_t size, int flags) 228*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_ATTR(pure); 229*1208bc7eSAndroid Build Coastguard Worker 230*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctl(const char *name, 231*1208bc7eSAndroid Build Coastguard Worker void *oldp, size_t *oldlenp, void *newp, size_t newlen); 232*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlnametomib(const char *name, 233*1208bc7eSAndroid Build Coastguard Worker size_t *mibp, size_t *miblenp); 234*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlbymib(const size_t *mib, 235*1208bc7eSAndroid Build Coastguard Worker size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); 236*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_malloc_stats_print( 237*1208bc7eSAndroid Build Coastguard Worker void (*write_cb)(void *, const char *), void *je_cbopaque, 238*1208bc7eSAndroid Build Coastguard Worker const char *opts); 239*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_malloc_usable_size( 240*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_USABLE_SIZE_CONST void *ptr) JEMALLOC_CXX_THROW; 241*1208bc7eSAndroid Build Coastguard Worker 242*1208bc7eSAndroid Build Coastguard Worker #ifdef JEMALLOC_OVERRIDE_MEMALIGN 243*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN 244*1208bc7eSAndroid Build Coastguard Worker void JEMALLOC_NOTHROW *je_memalign(size_t alignment, size_t size) 245*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc); 246*1208bc7eSAndroid Build Coastguard Worker #endif 247*1208bc7eSAndroid Build Coastguard Worker 248*1208bc7eSAndroid Build Coastguard Worker #ifdef JEMALLOC_OVERRIDE_VALLOC 249*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN 250*1208bc7eSAndroid Build Coastguard Worker void JEMALLOC_NOTHROW *je_valloc(size_t size) JEMALLOC_CXX_THROW 251*1208bc7eSAndroid Build Coastguard Worker JEMALLOC_ATTR(malloc); 252*1208bc7eSAndroid Build Coastguard Worker #endif 253*1208bc7eSAndroid Build Coastguard Worker 254*1208bc7eSAndroid Build Coastguard Worker typedef struct extent_hooks_s extent_hooks_t; 255*1208bc7eSAndroid Build Coastguard Worker 256*1208bc7eSAndroid Build Coastguard Worker /* 257*1208bc7eSAndroid Build Coastguard Worker * void * 258*1208bc7eSAndroid Build Coastguard Worker * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size, 259*1208bc7eSAndroid Build Coastguard Worker * size_t alignment, bool *zero, bool *commit, unsigned arena_ind); 260*1208bc7eSAndroid Build Coastguard Worker */ 261*1208bc7eSAndroid Build Coastguard Worker typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *, 262*1208bc7eSAndroid Build Coastguard Worker bool *, unsigned); 263*1208bc7eSAndroid Build Coastguard Worker 264*1208bc7eSAndroid Build Coastguard Worker /* 265*1208bc7eSAndroid Build Coastguard Worker * bool 266*1208bc7eSAndroid Build Coastguard Worker * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size, 267*1208bc7eSAndroid Build Coastguard Worker * bool committed, unsigned arena_ind); 268*1208bc7eSAndroid Build Coastguard Worker */ 269*1208bc7eSAndroid Build Coastguard Worker typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool, 270*1208bc7eSAndroid Build Coastguard Worker unsigned); 271*1208bc7eSAndroid Build Coastguard Worker 272*1208bc7eSAndroid Build Coastguard Worker /* 273*1208bc7eSAndroid Build Coastguard Worker * void 274*1208bc7eSAndroid Build Coastguard Worker * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size, 275*1208bc7eSAndroid Build Coastguard Worker * bool committed, unsigned arena_ind); 276*1208bc7eSAndroid Build Coastguard Worker */ 277*1208bc7eSAndroid Build Coastguard Worker typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool, 278*1208bc7eSAndroid Build Coastguard Worker unsigned); 279*1208bc7eSAndroid Build Coastguard Worker 280*1208bc7eSAndroid Build Coastguard Worker /* 281*1208bc7eSAndroid Build Coastguard Worker * bool 282*1208bc7eSAndroid Build Coastguard Worker * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size, 283*1208bc7eSAndroid Build Coastguard Worker * size_t offset, size_t length, unsigned arena_ind); 284*1208bc7eSAndroid Build Coastguard Worker */ 285*1208bc7eSAndroid Build Coastguard Worker typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t, 286*1208bc7eSAndroid Build Coastguard Worker unsigned); 287*1208bc7eSAndroid Build Coastguard Worker 288*1208bc7eSAndroid Build Coastguard Worker /* 289*1208bc7eSAndroid Build Coastguard Worker * bool 290*1208bc7eSAndroid Build Coastguard Worker * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size, 291*1208bc7eSAndroid Build Coastguard Worker * size_t offset, size_t length, unsigned arena_ind); 292*1208bc7eSAndroid Build Coastguard Worker */ 293*1208bc7eSAndroid Build Coastguard Worker typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t, 294*1208bc7eSAndroid Build Coastguard Worker size_t, unsigned); 295*1208bc7eSAndroid Build Coastguard Worker 296*1208bc7eSAndroid Build Coastguard Worker /* 297*1208bc7eSAndroid Build Coastguard Worker * bool 298*1208bc7eSAndroid Build Coastguard Worker * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size, 299*1208bc7eSAndroid Build Coastguard Worker * size_t offset, size_t length, unsigned arena_ind); 300*1208bc7eSAndroid Build Coastguard Worker */ 301*1208bc7eSAndroid Build Coastguard Worker typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t, 302*1208bc7eSAndroid Build Coastguard Worker unsigned); 303*1208bc7eSAndroid Build Coastguard Worker 304*1208bc7eSAndroid Build Coastguard Worker /* 305*1208bc7eSAndroid Build Coastguard Worker * bool 306*1208bc7eSAndroid Build Coastguard Worker * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size, 307*1208bc7eSAndroid Build Coastguard Worker * size_t size_a, size_t size_b, bool committed, unsigned arena_ind); 308*1208bc7eSAndroid Build Coastguard Worker */ 309*1208bc7eSAndroid Build Coastguard Worker typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t, 310*1208bc7eSAndroid Build Coastguard Worker bool, unsigned); 311*1208bc7eSAndroid Build Coastguard Worker 312*1208bc7eSAndroid Build Coastguard Worker /* 313*1208bc7eSAndroid Build Coastguard Worker * bool 314*1208bc7eSAndroid Build Coastguard Worker * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a, 315*1208bc7eSAndroid Build Coastguard Worker * void *addr_b, size_t size_b, bool committed, unsigned arena_ind); 316*1208bc7eSAndroid Build Coastguard Worker */ 317*1208bc7eSAndroid Build Coastguard Worker typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t, 318*1208bc7eSAndroid Build Coastguard Worker bool, unsigned); 319*1208bc7eSAndroid Build Coastguard Worker 320*1208bc7eSAndroid Build Coastguard Worker struct extent_hooks_s { 321*1208bc7eSAndroid Build Coastguard Worker extent_alloc_t *alloc; 322*1208bc7eSAndroid Build Coastguard Worker extent_dalloc_t *dalloc; 323*1208bc7eSAndroid Build Coastguard Worker extent_destroy_t *destroy; 324*1208bc7eSAndroid Build Coastguard Worker extent_commit_t *commit; 325*1208bc7eSAndroid Build Coastguard Worker extent_decommit_t *decommit; 326*1208bc7eSAndroid Build Coastguard Worker extent_purge_t *purge_lazy; 327*1208bc7eSAndroid Build Coastguard Worker extent_purge_t *purge_forced; 328*1208bc7eSAndroid Build Coastguard Worker extent_split_t *split; 329*1208bc7eSAndroid Build Coastguard Worker extent_merge_t *merge; 330*1208bc7eSAndroid Build Coastguard Worker }; 331*1208bc7eSAndroid Build Coastguard Worker 332*1208bc7eSAndroid Build Coastguard Worker /* 333*1208bc7eSAndroid Build Coastguard Worker * By default application code must explicitly refer to mangled symbol names, 334*1208bc7eSAndroid Build Coastguard Worker * so that it is possible to use jemalloc in conjunction with another allocator 335*1208bc7eSAndroid Build Coastguard Worker * in the same application. Define JEMALLOC_MANGLE in order to cause automatic 336*1208bc7eSAndroid Build Coastguard Worker * name mangling that matches the API prefixing that happened as a result of 337*1208bc7eSAndroid Build Coastguard Worker * --with-mangling and/or --with-jemalloc-prefix configuration settings. 338*1208bc7eSAndroid Build Coastguard Worker */ 339*1208bc7eSAndroid Build Coastguard Worker #ifdef JEMALLOC_MANGLE 340*1208bc7eSAndroid Build Coastguard Worker # ifndef JEMALLOC_NO_DEMANGLE 341*1208bc7eSAndroid Build Coastguard Worker # define JEMALLOC_NO_DEMANGLE 342*1208bc7eSAndroid Build Coastguard Worker # endif 343*1208bc7eSAndroid Build Coastguard Worker # define aligned_alloc je_aligned_alloc 344*1208bc7eSAndroid Build Coastguard Worker # define calloc je_calloc 345*1208bc7eSAndroid Build Coastguard Worker # define dallocx je_dallocx 346*1208bc7eSAndroid Build Coastguard Worker # define free je_free 347*1208bc7eSAndroid Build Coastguard Worker # define mallctl je_mallctl 348*1208bc7eSAndroid Build Coastguard Worker # define mallctlbymib je_mallctlbymib 349*1208bc7eSAndroid Build Coastguard Worker # define mallctlnametomib je_mallctlnametomib 350*1208bc7eSAndroid Build Coastguard Worker # define malloc je_malloc 351*1208bc7eSAndroid Build Coastguard Worker # define malloc_conf je_malloc_conf 352*1208bc7eSAndroid Build Coastguard Worker # define malloc_message je_malloc_message 353*1208bc7eSAndroid Build Coastguard Worker # define malloc_stats_print je_malloc_stats_print 354*1208bc7eSAndroid Build Coastguard Worker # define malloc_usable_size je_malloc_usable_size 355*1208bc7eSAndroid Build Coastguard Worker # define mallocx je_mallocx 356*1208bc7eSAndroid Build Coastguard Worker # define nallocx je_nallocx 357*1208bc7eSAndroid Build Coastguard Worker # define posix_memalign je_posix_memalign 358*1208bc7eSAndroid Build Coastguard Worker # define rallocx je_rallocx 359*1208bc7eSAndroid Build Coastguard Worker # define realloc je_realloc 360*1208bc7eSAndroid Build Coastguard Worker # define sallocx je_sallocx 361*1208bc7eSAndroid Build Coastguard Worker # define sdallocx je_sdallocx 362*1208bc7eSAndroid Build Coastguard Worker # define xallocx je_xallocx 363*1208bc7eSAndroid Build Coastguard Worker # define memalign je_memalign 364*1208bc7eSAndroid Build Coastguard Worker # define valloc je_valloc 365*1208bc7eSAndroid Build Coastguard Worker #endif 366*1208bc7eSAndroid Build Coastguard Worker 367*1208bc7eSAndroid Build Coastguard Worker /* 368*1208bc7eSAndroid Build Coastguard Worker * The je_* macros can be used as stable alternative names for the 369*1208bc7eSAndroid Build Coastguard Worker * public jemalloc API if JEMALLOC_NO_DEMANGLE is defined. This is primarily 370*1208bc7eSAndroid Build Coastguard Worker * meant for use in jemalloc itself, but it can be used by application code to 371*1208bc7eSAndroid Build Coastguard Worker * provide isolation from the name mangling specified via --with-mangling 372*1208bc7eSAndroid Build Coastguard Worker * and/or --with-jemalloc-prefix. 373*1208bc7eSAndroid Build Coastguard Worker */ 374*1208bc7eSAndroid Build Coastguard Worker #ifndef JEMALLOC_NO_DEMANGLE 375*1208bc7eSAndroid Build Coastguard Worker # undef je_aligned_alloc 376*1208bc7eSAndroid Build Coastguard Worker # undef je_calloc 377*1208bc7eSAndroid Build Coastguard Worker # undef je_dallocx 378*1208bc7eSAndroid Build Coastguard Worker # undef je_free 379*1208bc7eSAndroid Build Coastguard Worker # undef je_mallctl 380*1208bc7eSAndroid Build Coastguard Worker # undef je_mallctlbymib 381*1208bc7eSAndroid Build Coastguard Worker # undef je_mallctlnametomib 382*1208bc7eSAndroid Build Coastguard Worker # undef je_malloc 383*1208bc7eSAndroid Build Coastguard Worker # undef je_malloc_conf 384*1208bc7eSAndroid Build Coastguard Worker # undef je_malloc_message 385*1208bc7eSAndroid Build Coastguard Worker # undef je_malloc_stats_print 386*1208bc7eSAndroid Build Coastguard Worker # undef je_malloc_usable_size 387*1208bc7eSAndroid Build Coastguard Worker # undef je_mallocx 388*1208bc7eSAndroid Build Coastguard Worker # undef je_nallocx 389*1208bc7eSAndroid Build Coastguard Worker # undef je_posix_memalign 390*1208bc7eSAndroid Build Coastguard Worker # undef je_rallocx 391*1208bc7eSAndroid Build Coastguard Worker # undef je_realloc 392*1208bc7eSAndroid Build Coastguard Worker # undef je_sallocx 393*1208bc7eSAndroid Build Coastguard Worker # undef je_sdallocx 394*1208bc7eSAndroid Build Coastguard Worker # undef je_xallocx 395*1208bc7eSAndroid Build Coastguard Worker # undef je_memalign 396*1208bc7eSAndroid Build Coastguard Worker # undef je_valloc 397*1208bc7eSAndroid Build Coastguard Worker #endif 398*1208bc7eSAndroid Build Coastguard Worker 399*1208bc7eSAndroid Build Coastguard Worker #ifdef __cplusplus 400*1208bc7eSAndroid Build Coastguard Worker } 401*1208bc7eSAndroid Build Coastguard Worker #endif 402*1208bc7eSAndroid Build Coastguard Worker #endif /* JEMALLOC_H_ */ 403