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