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